]> git.draconx.ca Git - cdecl99.git/blob - tests/randomdecl-sanity.sh
52b5534b37707175e018f754087a005751f8dbc9
[cdecl99.git] / tests / randomdecl-sanity.sh
1 #!/bin/sh
2 #
3 # Copyright © 2012 Nick Bowler
4 #
5 # Check randomdecl's output to make sure it actually generates a variety
6 # of declarations.
7 #
8 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
9 # This is free software: you are free to do what the fuck you want to.
10 # There is NO WARRANTY, to the extent permitted by law.
11
12 randomdecl=test/randomdecl$EXEEXT
13 test -x $randomdecl || exit 77
14
15 proc() {
16         sed -f tests/randomdecl-sanity.sed || { echo "result=fail"; return 1; }
17 }
18
19 printf '%s: randomized test using RANDOMSEED=%d\n' "$0" "$RANDOMSEED"
20
21 result=pass
22 eval_cmd=`exec 3>&1
23         { $randomdecl -E -s "$RANDOMSEED" 3>&-
24                 echo gen_status=$? >&3
25         } | proc >&3`
26 eval "$eval_cmd"
27
28 eval_cmd=`sed -ne 's/^\(.*\)=yes #\(.*\)$/\
29         test x"$\1" = x"yes" || { echo no \2; result=fail; }/p' \
30         tests/randomdecl-sanity.sed`
31 eval "$eval_cmd"
32
33 if test x"$result" != x"pass"; then
34         printf '%s: test failed\n' "$0"
35         exit 1
36 fi