]> git.draconx.ca Git - cdecl99.git/blob - tests/randomdecl-sanity.sh
Add missing test script to the distribution.
[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 "$srcdir/tests/randomdecl-sanity.sed" \
17                 || { echo "result=fail"; return 1; }
18 }
19
20 printf '%s: randomized test using RANDOMSEED=%d\n' "$0" "$RANDOMSEED"
21
22 result=pass
23 eval_cmd=`exec 3>&1
24         { $randomdecl -E -s "$RANDOMSEED" 3>&-
25                 echo gen_status=$? >&3
26         } | proc >&3`
27 eval "$eval_cmd"
28
29 eval_cmd=`sed -ne 's/^\(.*\)=yes #\(.*\)$/\
30         test x"$\1" = x"yes" || { echo no \2; result=fail; }/p' \
31         tests/randomdecl-sanity.sed`
32 eval "$eval_cmd"
33
34 if test x"$result" != x"pass"; then
35         printf '%s: test failed\n' "$0"
36         exit 1
37 fi