#!/bin/sh
# Smoke test: build the S4U tutorial project against the installed packages
# Please keep debian/tests/smoke-s4u/ in sync with https://framagit.org/simgrid/simgrid-template-s4u
set -e

HERE="$(cd "$(dirname "$0")" && pwd)"
BUILDDIR="${AUTOPKGTEST_TMP:-$(mktemp -d)}/smoke-s4u"

cp -r "$HERE/smoke-s4u" "$BUILDDIR"
cd "$BUILDDIR"

echo "Build directory is: `pwd`"
cmake .
make VERBOSE=1

echo 
echo "XXX Test master_workers"
echo "XXX Test the default factory"
valgrind ./master-workers small_platform.xml master-workers_d.xml
echo "XXX Test the boost factory"
valgrind ./master-workers --cfg=contexts/factory:boost small_platform.xml master-workers_d.xml
echo "XXX Test the thread factory"
valgrind ./master-workers --cfg=contexts/factory:thread small_platform.xml master-workers_d.xml

echo 
echo "XXX Test ping-pong"
./ping-pong cluster_platform.xml

echo 
echo "XXX Test python's master-worker"
python3 master-workers.py small_platform.xml master-workers_d.xml
