|
1 | 1 | #!/bin/bash |
2 | 2 |
|
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" |
5 | 12 |
|
6 | 13 | if [ ! -e $EXP_DIR ]; then |
7 | | - echo "Expectations folder not found. Exiting!" |
| 14 | + echo " Fatal: Expectations folder not found. Exiting!" |
8 | 15 | exit 1 |
9 | 16 | fi |
10 | 17 |
|
11 | | -for fn in $DIR/*.c; do |
| 18 | +for fn in $TESTS_DIR/*.c; do |
12 | 19 | fname_we=${fn##*/} # File title with extension |
13 | 20 | fname=${fname_we%%.c} # File title without extension |
14 | 21 |
|
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 |
17 | 24 | exp_file=$EXP_DIR/$fname.exp # Expectation file for test |
18 | 25 |
|
19 | | - echo "Compiling test '$fn'" |
| 26 | + echo " Compiling and running '$fn'" |
20 | 27 | gcc -Wall -Wextra $fn -o $bin_file || exit |
21 | 28 |
|
22 | | - echo "Running and matching with expectation '$exp_file'" |
23 | 29 | ./$bin_file > $out_file |
24 | 30 | diff $out_file $exp_file || exit |
25 | 31 | done |
26 | 32 |
|
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