build: Support building with Gash.
[mes.git] / build-aux / check-tcc.sh
1 #! /bin/sh
2
3 # GNU Mes --- Maxwell Equations of Software
4 # Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
5 #
6 # This file is part of GNU Mes.
7 #
8 # GNU Mes is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or (at
11 # your option) any later version.
12 #
13 # GNU Mes is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
20
21 set -e
22 . ./config.status
23 . ${srcdest}build-aux/config.sh
24 . ${srcdest}build-aux/trace.sh
25
26 tests="
27 00_assignment
28 01_comment
29 02_printf
30 03_struct
31 04_for
32 05_array
33 06_case
34 07_function
35 08_while
36 09_do_while
37
38 10_pointer
39 11_precedence
40 12_hashdefine
41 13_integer_literals
42 14_if
43 15_recursion
44 16_nesting
45 17_enum
46 18_include
47 19_pointer_arithmetic
48
49 20_pointer_comparison
50 21_char_array
51 22_floating_point
52 23_type_coercion
53 24_math_library
54 25_quicksort
55 26_character_constants
56 27_sizeof
57 28_strings
58 29_array_address
59
60 30_hanoi
61 31_args
62 32_led
63 33_ternary_op
64 34_array_assignment
65 35_sizeof
66 36_array_initialisers
67 37_sprintf
68 38_multiple_array_index
69 39_typedef
70
71 40_stdio
72 41_hashif
73 42_function_pointer
74 43_void_param
75 44_scoped_declarations
76 45_empty_for
77 47_switch_return
78 48_nested_break
79 49_bracket_evaluation
80
81 50_logical_second_arg
82 51_static
83 52_unnamed_enum
84 54_goto
85 55_lshift_type
86 "
87
88 broken="$broken
89 18_include
90
91 22_floating_point
92 23_type_coercion
93 24_math_library
94 26_character_constants
95 27_sizeof
96 28_strings
97
98 34_array_assignment
99 39_typedef
100
101 40_stdio
102 42_function_pointer
103 49_bracket_evaluation
104 55_lshift_type
105 "
106
107 #22_floating_point       ; float
108 #23_type_coercion        ; float
109 #24_math_library         ; float
110 #27_sizeof               ; float
111 #28_strings              ; TODO: strncpy strchr strrchr memset memcpy memcmp
112 #30_hanoi                ; fails with GCC
113 #34_array_assignment     ; fails with GCC
114 #39_typedef              ;unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (typename "MyFunStruct"))) (init-declr-list (init-declr (ptr-declr (pointer) (ident "MoreFunThanEver")))))
115
116 #40_stdio                ; f* functions
117 #42_function_pointer     ; f* functions
118 #49_bracket_evaluation   ; float
119
120
121 LIBC=c+gnu
122 MES_LIBS="-l c+gnu"
123
124 expect=$(echo $broken | wc -w)
125 ARGS="arg1 arg2 arg3 arg4 arg5"
126 export ARGS
127 pass=0
128 fail=0
129 total=0
130 mkdir -p scaffold/tinycc
131 set +e
132 for t in $tests; do
133     if [ ! -f $TINYCC_PREFIX/tests/tests2/"$t.c" ]; then
134         echo ' [SKIP]'
135         continue;
136     fi
137     cp $TINYCC_PREFIX/tests/tests2/$i* scaffold/tinycc
138     sh ${srcdest}build-aux/test.sh "scaffold/tinycc/$t" > scaffold/tinycc/"$t".log 2>&1
139     r=$?
140     total=$(expr $total + 1)
141     if [ $r = 0 ]; then
142         echo $t: [OK]
143         pass=$(expr $pass + 1)
144     else
145         echo $t: [FAIL]
146         fail=$(expr $fail + 1)
147     fi
148 done
149 [ $expect != 0 ] && echo "expect: $expect"
150 [ $fail != 0 ] && echo "failed: $fail"
151 [ $fail -lt $expect ] && echo "solved: $(expr $expect - $fail)"
152 echo "passed: $pass"
153 echo "total:  $total"
154 if [ $fail != 0 -a $fail -gt $expect ]; then
155     echo FAILED: $fail/$total
156     exit 1
157 elif [ $fail != 0 ]; then
158     echo PASS: $pass/$total
159 else
160     echo PASS: $total
161 fi