Skip to content

Commit b2098ed

Browse files
committed
tests/test.sh now also builds & runs examples
1 parent 82e56e9 commit b2098ed

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

tests/test.sh

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,61 @@
11
#!/bin/bash
22

3-
DIR=`dirname $0`
4-
EXP_DIR="$DIR/exps"
3+
TMP_DIR=/tmp
4+
5+
#######################################################################
6+
# Running recorded tests
7+
#######################################################################
8+
echo "Test 1/2: Running recorded tests"
9+
10+
TESTS_DIR=`dirname $0`
11+
EXP_DIR="$TESTS_DIR/exps"
512

613
if [ ! -e $EXP_DIR ]; then
7-
echo "Expectations folder not found. Exiting!"
14+
echo " Fatal: Expectations folder not found. Exiting!"
815
exit 1
916
fi
1017

11-
for fn in $DIR/*.c; do
18+
for fn in $TESTS_DIR/*.c; do
1219
fname_we=${fn##*/} # File title with extension
1320
fname=${fname_we%%.c} # File title without extension
1421

15-
bin_file=$DIR/test # Compiled test binary name
16-
out_file=$DIR/test.out # Output from running the test
22+
bin_file=$TESTS_DIR/test # Compiled test binary name
23+
out_file=$TESTS_DIR/test.out # Output from running the test
1724
exp_file=$EXP_DIR/$fname.exp # Expectation file for test
1825

19-
echo "Compiling test '$fn'"
26+
echo " Compiling and running '$fn'"
2027
gcc -Wall -Wextra $fn -o $bin_file || exit
2128

22-
echo "Running and matching with expectation '$exp_file'"
2329
./$bin_file > $out_file
2430
diff $out_file $exp_file || exit
2531
done
2632

27-
echo "[Tests passed]"
33+
#######################################################################
34+
# Compiling and running examples
35+
#######################################################################
36+
echo "Test 2/2: Running examples"
37+
38+
echo " Sensor test.."
39+
gcc example/sensor_test.c \
40+
example/suts/sensor.c \
41+
-o $TMP_DIR/test || exit
42+
$TMP_DIR/test || exit
43+
44+
echo " Basic test.."
45+
gcc example/basic_tests.c \
46+
-o $TMP_DIR/test || exit
47+
$TMP_DIR/test || exit
48+
49+
echo " Add test.."
50+
gcc example/add_test.c \
51+
example/suts/add.c \
52+
-o $TMP_DIR/test || exit
53+
$TMP_DIR/test || exit
54+
55+
echo " Add Parameterised test.."
56+
gcc example/add_parameterised_test.c \
57+
example/suts/add.c \
58+
-o $TMP_DIR/test || exit
59+
$TMP_DIR/test || exit
60+
61+
echo "[ALl tests passed]"

0 commit comments

Comments
 (0)