8e9f2ae15d7a0e8b19a7774936f246050b2a2ffc
[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 . ${srcdest}build-aux/config.sh
23 . ${srcdest}build-aux/trace.sh
24
25 MES=${MES-src/mes}
26 [ -z "$MESCC" ] && MESCC=scripts/mescc
27 GUILE=${GUILE-guile}
28 MES_PREFIX=${MES_PREFIX-mes}
29
30 HEX2=${HEX2-hex2}
31 M1=${M1-M1}
32 BLOOD_ELF=${BLOOD_ELF-blood-elf}
33 MES_SEED=${MES_SEED-../mes-seed}
34 MESCC=${MESCC-$(command -v mescc)}
35 [ -z "$MESCC" ] && MESCC=scripts/mescc
36 MES=${MES-$(command -v mes)}
37 [ -z "$MES" ] && MES=src/mes
38
39 if ! command -v $GUILE > /dev/null; then
40     GUILE=true
41 fi
42
43 tests="
44 00_assignment
45 01_comment
46 02_printf
47 03_struct
48 04_for
49 05_array
50 06_case
51 07_function
52 08_while
53 09_do_while
54
55 10_pointer
56 11_precedence
57 12_hashdefine
58 13_integer_literals
59 14_if
60 15_recursion
61 16_nesting
62 17_enum
63 18_include
64 19_pointer_arithmetic
65
66 20_pointer_comparison
67 21_char_array
68 22_floating_point
69 23_type_coercion
70 24_math_library
71 25_quicksort
72 26_character_constants
73 27_sizeof
74 28_strings
75 29_array_address
76
77 30_hanoi
78 31_args
79 32_led
80 33_ternary_op
81 34_array_assignment
82 35_sizeof
83 36_array_initialisers
84 37_sprintf
85 38_multiple_array_index
86 39_typedef
87
88 40_stdio
89 41_hashif
90 42_function_pointer
91 43_void_param
92 44_scoped_declarations
93 45_empty_for
94 47_switch_return
95 48_nested_break
96 49_bracket_evaluation
97
98 50_logical_second_arg
99 51_static
100 52_unnamed_enum
101 54_goto
102 55_lshift_type
103 "
104
105 broken="$broken
106 18_include
107
108 22_floating_point
109 23_type_coercion
110 24_math_library
111 26_character_constants
112 27_sizeof
113 28_strings
114
115 34_array_assignment
116 39_typedef
117
118 40_stdio
119 42_function_pointer
120 49_bracket_evaluation
121 55_lshift_type
122 "
123
124 #22_floating_point       ; float
125 #23_type_coercion        ; float
126 #24_math_library         ; float
127 #27_sizeof               ; float
128 #28_strings              ; TODO: strncpy strchr strrchr memset memcpy memcmp
129 #30_hanoi                ; fails with GCC
130 #34_array_assignment     ; fails with GCC
131 #39_typedef              ;unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (typename "MyFunStruct"))) (init-declr-list (init-declr (ptr-declr (pointer) (ident "MoreFunThanEver")))))
132
133 #40_stdio                ; f* functions
134 #42_function_pointer     ; f* functions
135 #49_bracket_evaluation   ; float
136
137
138 LIBC=c+gnu
139 MES_LIBS="-l c+gnu"
140
141 expect=$(echo $broken | wc -w)
142 ARGS="arg1 arg2 arg3 arg4 arg5"
143 export ARGS
144 mkdir -p scaffold/tinycc
145 for t in $tests; do
146     if [ ! -f $TINYCC_PREFIX/"$t.c" ]; then
147         echo ' [SKIP]'
148         continue;
149     fi
150     cp $TINYCC_PREFIX/tests/tests2/$i* scaffold/tinycc
151     sh ${srcdest}build-aux/test.sh "scaffold/tinycc/$t" &> scaffold/tinycc/"$t".log
152     r=$?
153     total=$((total+1))
154     if [ $r = 0 ]; then
155         echo $t: [OK]
156         pass=$((pass+1))
157     else
158         echo $t: [FAIL]
159         fail=$((fail+1))
160     fi
161 done
162 [ $expect != 0 ] && echo "expect: $expect"
163 [ $fail != 0 ] && echo "failed: $fail"
164 [ $fail -lt $expect ] && echo "solved: $(($expect - $fail))"
165 echo "passed: $pass"
166 echo "total:  $total"
167 if [ $fail != 0 -a $fail -gt $expect ]; then
168     echo FAILED: $fail/$total
169     exit 1
170 elif [ $fail != 0 ]; then
171     echo PASS: $pass/$total
172 else
173     echo PASS: $total
174 fi