core: Add equal2?.
[mes.git] / check-mescc.sh
1 #! /bin/sh
2
3 # Mes --- Maxwell Equations of Software
4 # Copyright © 2017,2018 Jan Nieuwenhuizen <janneke@gnu.org>
5 #
6 # This file is part of Mes.
7 #
8 # 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 # 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 Mes.  If not, see <http://www.gnu.org/licenses/>.
20
21 export MES=${MES-src/mes.gcc}
22 export MESCC=${MESCC-scripts/mescc.mes}
23 #export MES_ARENA=${MES_ARENA-200000000} > 12GB mem
24
25 GUILE=${GUILE-guile}
26 MES=${MES-./mes}
27 M1=${M1-M1}
28 HEX2=${HEX2-hex2}
29 MESCC=${MESCC-guile/mescc.scm}
30 MES_PREFIX=${MES_PREFIX-.}
31
32 # $MESCC -E -o lib/crt1.E lib/crt1.c
33 # $MESCC -c -o lib/crt1.M1 lib/crt1.E
34 # $M1 --LittleEndian --Architecture=1 \
35 #     -f stage0/x86.M1\
36 #     -f lib/crt1.M1\
37 #     > lib/crt1.hex2
38 # $MESCC -E -o lib/libc-mes.E lib/libc-mes.c
39 # $MESCC -c -o lib/libc-mes.M1 lib/libc-mes.E
40 # $M1 --LittleEndian --Architecture=1\
41 #     -f stage0/x86.M1\
42 #     -f lib/libc-mes.M1\
43 #     > lib/libc-mes.hex2
44
45 tests="
46 t
47 00-exit-0
48 01-return-0
49 02-return-1
50 03-call
51 04-call-0
52 05-call-1
53 06-call-!1
54 10-if-0
55 11-if-1
56 12-if-==
57 13-if-!=
58 14-if-goto
59 15-if-!f
60 16-if-t
61 20-while
62 21-char[]
63 22-while-char[]
64 23-pointer
65 30-strlen
66 31-eputs
67 32-compare
68 33-and-or
69 34-pre-post
70 35-compare-char
71 36-compare-arithmetic
72 37-compare-assign
73 38-compare-call
74 40-if-else
75 41-?
76 42-goto-label
77 43-for-do-while
78 44-switch
79 45-void-call
80 50-assert
81 51-strcmp
82 52-itoa
83 53-strcpy
84 54-argv
85 60-math
86 61-array
87 63-struct-cell
88 64-make-cell
89 65-read
90 70-printf
91 71-struct-array
92 72-typedef-struct-def
93 73-union
94 74-multi-line-string
95 75-struct-union
96 76-pointer-arithmetic
97 77-pointer-assign
98 78-union-struct
99 79-int-array
100 7a-struct-char-array
101 7b-struct-int-array
102 7c-dynarray
103 7d-cast-char
104 7e-struct-array-access
105 7f-struct-pointer-arithmetic
106 7g-struct-byte-word-field
107 7h-struct-assign
108 7i-struct-struct
109 7j-strtoull
110 7k-for-each-elem
111 7l-struct-any-size-array
112 7m-struct-char-array-assign
113 7n-struct-struct-array
114 80-setjmp
115 81-qsort
116 82-define
117 "
118
119 if [ ! -x ./i686-unknown-linux-gnu-tcc ]; then
120     tests=$(echo "$tests" | grep -Ev "02-return-1|05-call-1|80-setjmp|81-qsort")
121 fi
122
123 set +e
124 fail=0
125 total=0
126 for t in $tests; do
127     sh test.sh "$t" &> scaffold/tests/$t.log
128     r=$?
129     total=$((total+1))
130     if [ $r = 0 ]; then
131         echo $t: [OK]
132     else
133         echo $t: [FAIL]
134         fail=$((fail+1))
135     fi
136 done
137 if [ $fail != 0 ]; then
138     echo FAILED: $fail/$total
139     exit 1
140 else
141     echo PASS: $total
142 fi