2018-04-29 16:38:57 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
# Mes --- Maxwell Equations of Software
|
|
|
|
# Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
|
|
|
#
|
|
|
|
# This file is part of Mes.
|
|
|
|
#
|
|
|
|
# Mes is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
# your option) any later version.
|
|
|
|
#
|
|
|
|
# Mes is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-05-03 18:32:06 +00:00
|
|
|
export BLOOD_ELF GUILE HEX2 M1 MES MESCC
|
|
|
|
export M1FLAGS HEX2FLAGS PREPROCESS LIBC
|
|
|
|
export MES_ARENA MES_PREFIX MES_SEED
|
2018-04-29 16:38:57 +00:00
|
|
|
|
2018-05-03 18:32:06 +00:00
|
|
|
MES=${MES-src/mes}
|
|
|
|
MESCC=${MESCC-scripts/mescc}
|
|
|
|
GUILE=${GUILE-guile}
|
|
|
|
MES_PREFIX=${MES_PREFIX-.}
|
|
|
|
|
|
|
|
HEX2=${HEX2-hex2}
|
|
|
|
M1=${M1-M1}
|
|
|
|
BLOOD_ELF=${BLOOD_ELF-blood-elf}
|
|
|
|
MES_SEED=${MES_SEED-../mes-seed}
|
|
|
|
MESCC=${MESCC-$(command -v mescc)}
|
2018-04-29 16:38:57 +00:00
|
|
|
[ -z "$MESCC" ] && MESCC=scripts/mescc
|
2018-05-03 18:32:06 +00:00
|
|
|
MES=${MES-$(command -v mes)}
|
2018-04-29 16:38:57 +00:00
|
|
|
[ -z "$MES" ] && MES=src/mes
|
|
|
|
|
|
|
|
|
|
|
|
tests="
|
|
|
|
t
|
|
|
|
00-exit-0
|
|
|
|
01-return-0
|
|
|
|
02-return-1
|
|
|
|
03-call
|
|
|
|
04-call-0
|
|
|
|
05-call-1
|
|
|
|
06-call-!1
|
|
|
|
10-if-0
|
|
|
|
11-if-1
|
|
|
|
12-if-==
|
|
|
|
13-if-!=
|
|
|
|
14-if-goto
|
|
|
|
15-if-!f
|
|
|
|
16-if-t
|
|
|
|
20-while
|
|
|
|
21-char[]
|
|
|
|
22-while-char[]
|
|
|
|
23-pointer
|
|
|
|
30-strlen
|
|
|
|
31-eputs
|
|
|
|
32-compare
|
|
|
|
33-and-or
|
|
|
|
34-pre-post
|
|
|
|
35-compare-char
|
|
|
|
36-compare-arithmetic
|
|
|
|
37-compare-assign
|
|
|
|
38-compare-call
|
|
|
|
40-if-else
|
|
|
|
41-?
|
|
|
|
42-goto-label
|
|
|
|
43-for-do-while
|
|
|
|
44-switch
|
|
|
|
45-void-call
|
2018-05-04 18:45:27 +00:00
|
|
|
46-function-static
|
2018-05-04 11:58:27 +00:00
|
|
|
47-function-expression
|
|
|
|
48-function-destruct
|
2018-05-05 10:30:06 +00:00
|
|
|
49-global-static
|
2018-04-29 16:38:57 +00:00
|
|
|
50-assert
|
|
|
|
51-strcmp
|
|
|
|
52-itoa
|
|
|
|
53-strcpy
|
|
|
|
54-argv
|
|
|
|
60-math
|
|
|
|
61-array
|
2018-05-05 10:30:06 +00:00
|
|
|
62-array
|
2018-04-29 16:38:57 +00:00
|
|
|
63-struct-cell
|
|
|
|
64-make-cell
|
|
|
|
65-read
|
|
|
|
70-printf
|
|
|
|
71-struct-array
|
|
|
|
72-typedef-struct-def
|
|
|
|
73-union
|
|
|
|
74-multi-line-string
|
|
|
|
75-struct-union
|
|
|
|
76-pointer-arithmetic
|
|
|
|
77-pointer-assign
|
|
|
|
78-union-struct
|
|
|
|
79-int-array
|
|
|
|
7a-struct-char-array
|
|
|
|
7b-struct-int-array
|
|
|
|
7c-dynarray
|
|
|
|
7d-cast-char
|
|
|
|
7e-struct-array-access
|
|
|
|
7f-struct-pointer-arithmetic
|
|
|
|
7g-struct-byte-word-field
|
|
|
|
7h-struct-assign
|
|
|
|
7i-struct-struct
|
|
|
|
7j-strtoull
|
|
|
|
7k-for-each-elem
|
|
|
|
7l-struct-any-size-array
|
|
|
|
7m-struct-char-array-assign
|
|
|
|
7n-struct-struct-array
|
|
|
|
80-setjmp
|
|
|
|
81-qsort
|
|
|
|
82-define
|
2018-05-04 20:38:01 +00:00
|
|
|
83-heterogenoous-init
|
2018-05-04 22:14:47 +00:00
|
|
|
84-struct-field-list
|
2018-05-04 22:59:31 +00:00
|
|
|
85-sizeof
|
2018-04-29 16:38:57 +00:00
|
|
|
"
|
|
|
|
|
2018-05-01 14:50:29 +00:00
|
|
|
broken="$broken
|
|
|
|
"
|
2018-04-29 16:38:57 +00:00
|
|
|
|
|
|
|
set +e
|
2018-05-01 14:50:29 +00:00
|
|
|
expect=$(echo $broken | wc -w)
|
|
|
|
pass=0
|
2018-04-29 16:38:57 +00:00
|
|
|
fail=0
|
|
|
|
total=0
|
2018-05-03 18:32:06 +00:00
|
|
|
LIBC=libc/libc
|
2018-04-29 16:38:57 +00:00
|
|
|
for t in $tests; do
|
2018-05-01 14:50:29 +00:00
|
|
|
if [ -z "${t/[012][0-9]-*/}" ]; then
|
|
|
|
LIBC=lib/mini-libc;
|
|
|
|
elif [ -z "${t/8[0-9]-*/}" ]; then
|
|
|
|
LIBC=lib/libc+tcc;
|
|
|
|
else
|
|
|
|
LIBC=lib/libc;
|
|
|
|
fi
|
2018-04-29 16:38:57 +00:00
|
|
|
sh build-aux/test.sh "scaffold/tests/$t" &> scaffold/tests/"$t".log
|
|
|
|
r=$?
|
|
|
|
total=$((total+1))
|
|
|
|
if [ $r = 0 ]; then
|
|
|
|
echo $t: [OK]
|
2018-05-01 14:50:29 +00:00
|
|
|
pass=$((pass+1))
|
2018-04-29 16:38:57 +00:00
|
|
|
else
|
|
|
|
echo $t: [FAIL]
|
|
|
|
fail=$((fail+1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
tests="
|
|
|
|
00_assignment
|
|
|
|
01_comment
|
|
|
|
02_printf
|
|
|
|
03_struct
|
|
|
|
04_for
|
|
|
|
05_array
|
|
|
|
06_case
|
|
|
|
07_function
|
|
|
|
08_while
|
|
|
|
09_do_while
|
|
|
|
|
|
|
|
10_pointer
|
|
|
|
11_precedence
|
|
|
|
12_hashdefine
|
2018-05-01 14:50:29 +00:00
|
|
|
13_integer_literals
|
2018-04-29 16:38:57 +00:00
|
|
|
14_if
|
|
|
|
15_recursion
|
|
|
|
16_nesting
|
|
|
|
17_enum
|
|
|
|
18_include
|
|
|
|
19_pointer_arithmetic
|
|
|
|
|
|
|
|
20_pointer_comparison
|
|
|
|
21_char_array
|
2018-05-01 14:50:29 +00:00
|
|
|
22_floating_point
|
|
|
|
23_type_coercion
|
|
|
|
24_math_library
|
2018-04-29 16:38:57 +00:00
|
|
|
25_quicksort
|
2018-05-01 14:50:29 +00:00
|
|
|
26_character_constants
|
|
|
|
27_sizeof
|
|
|
|
28_strings
|
2018-04-29 16:38:57 +00:00
|
|
|
29_array_address
|
|
|
|
|
2018-05-01 14:50:29 +00:00
|
|
|
30_hanoi
|
2018-04-29 16:38:57 +00:00
|
|
|
31_args
|
2018-05-01 14:50:29 +00:00
|
|
|
32_led
|
2018-04-29 16:38:57 +00:00
|
|
|
33_ternary_op
|
2018-05-01 14:50:29 +00:00
|
|
|
34_array_assignment
|
2018-04-29 16:38:57 +00:00
|
|
|
35_sizeof
|
2018-05-01 14:50:29 +00:00
|
|
|
36_array_initialisers
|
|
|
|
37_sprintf
|
|
|
|
38_multiple_array_index
|
|
|
|
39_typedef
|
2018-04-29 16:38:57 +00:00
|
|
|
|
2018-05-01 14:50:29 +00:00
|
|
|
40_stdio
|
2018-04-29 16:38:57 +00:00
|
|
|
41_hashif
|
2018-05-01 14:50:29 +00:00
|
|
|
42_function_pointer
|
2018-04-29 16:38:57 +00:00
|
|
|
43_void_param
|
|
|
|
44_scoped_declarations
|
|
|
|
45_empty_for
|
2018-05-01 14:50:29 +00:00
|
|
|
46_grep
|
2018-04-29 16:38:57 +00:00
|
|
|
47_switch_return
|
|
|
|
48_nested_break
|
2018-05-01 14:50:29 +00:00
|
|
|
49_bracket_evaluation
|
2018-04-29 16:38:57 +00:00
|
|
|
|
|
|
|
50_logical_second_arg
|
2018-05-01 14:50:29 +00:00
|
|
|
51_static
|
|
|
|
52_unnamed_enum
|
2018-04-29 16:38:57 +00:00
|
|
|
54_goto
|
2018-05-05 10:30:06 +00:00
|
|
|
55_lshift_type
|
2018-05-01 14:50:29 +00:00
|
|
|
"
|
2018-04-29 16:38:57 +00:00
|
|
|
|
2018-05-01 14:50:29 +00:00
|
|
|
broken="$broken
|
|
|
|
18_include
|
|
|
|
|
|
|
|
22_floating_point
|
|
|
|
23_type_coercion
|
|
|
|
24_math_library
|
|
|
|
26_character_constants
|
|
|
|
27_sizeof
|
|
|
|
28_strings
|
|
|
|
|
2018-05-05 10:30:06 +00:00
|
|
|
31_args
|
2018-05-01 14:50:29 +00:00
|
|
|
32_led
|
|
|
|
34_array_assignment
|
|
|
|
37_sprintf
|
|
|
|
38_multiple_array_index
|
|
|
|
39_typedef
|
|
|
|
|
|
|
|
40_stdio
|
|
|
|
42_function_pointer
|
|
|
|
46_grep
|
|
|
|
49_bracket_evaluation
|
|
|
|
|
|
|
|
52_unnamed_enum
|
|
|
|
55_lshift_type
|
2018-04-29 16:38:57 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
#22_floating_point ; float
|
|
|
|
#23_type_coercion ; float
|
|
|
|
#24_math_library ; float
|
|
|
|
#27_sizeof ; float
|
|
|
|
#28_strings ; TODO: strncpy strchr strrchr memset memcpy memcmp
|
|
|
|
#30_hanoi ; fails with GCC
|
|
|
|
#32_led ; unsupported: (decl (decl-spec-list (stor-spec (static)) (type-spec (fixed-type "int"))) (init-declr-list (init-declr (array-of (ident "d") (p-expr (fixed "32"))))))
|
|
|
|
#34_array_assignment ; fails with GCC
|
|
|
|
#36_array_initialisers ; unspported: (decl (decl-spec-list (type-spec (fixed-type "int"))) (init-declr-list (init-declr (array-of (ident "Array") (p-expr (fixed "10"))) (initzer (initzer-list (initzer (p-expr (fixed "12"))) (initzer (p-expr (fixed "34"))) (initzer (p-expr (fixed "56"))) (initzer (p-expr (fixed "78"))) (initzer (p-expr (fixed "90"))) (initzer (p-expr (fixed "123"))) (initzer (p-expr (fixed "456"))) (initzer (p-expr (fixed "789"))) (initzer (p-expr (fixed "8642"))) (initzer (p-expr (fixed "9753"))))))))
|
|
|
|
#37_sprintf ; integer formatting unsupported
|
|
|
|
#38_multiple_array_index ; unspported: (decl (decl-spec-list (type-spec (fixed-type "int"))) (init-declr-list (init-declr (array-of (array-of (ident "a") (p-expr (fixed "4"))) (p-expr (fixed "4"))))))
|
|
|
|
#39_typedef ;unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (typename "MyFunStruct"))) (init-declr-list (init-declr (ptr-declr (pointer) (ident "MoreFunThanEver")))))
|
|
|
|
|
|
|
|
#40_stdio ; f* functions
|
|
|
|
#42_function_pointer ; f* functions
|
|
|
|
#46_grep ; f* functions
|
|
|
|
#49_bracket_evaluation ; float
|
|
|
|
#51_static ; unsupported: (decl (decl-spec-list (stor-spec (static)) (type-spec (fixed-type "int"))) (init-declr-list (init-declr (ident "fred") (initzer (p-expr (fixed "1234"))))))
|
|
|
|
#52_unnamed_enum ; unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (enum-def (enum-def-list (enum-defn (ident "e")) (enum-defn (ident "f")) (enum-defn (ident "g")))))) (init-declr-list (init-declr (ident "h"))))
|
|
|
|
#55_lshift_type ; unsigned
|
|
|
|
|
|
|
|
|
2018-05-01 14:50:29 +00:00
|
|
|
expect=$(echo $broken | wc -w)
|
2018-04-29 16:38:57 +00:00
|
|
|
for t in $tests; do
|
|
|
|
if [ ! -f scaffold/tinycc/"$t.c" ]; then
|
|
|
|
echo ' [SKIP]'
|
|
|
|
continue;
|
|
|
|
fi
|
2018-05-04 08:12:34 +00:00
|
|
|
sh build-aux/test.sh "scaffold/tinycc/$t" &> scaffold/tinycc/"$t".log
|
2018-04-29 16:38:57 +00:00
|
|
|
r=$?
|
|
|
|
total=$((total+1))
|
|
|
|
if [ $r = 0 ]; then
|
|
|
|
echo $t: [OK]
|
2018-05-01 14:50:29 +00:00
|
|
|
pass=$((pass+1))
|
2018-04-29 16:38:57 +00:00
|
|
|
else
|
|
|
|
echo $t: [FAIL]
|
|
|
|
fail=$((fail+1))
|
|
|
|
fi
|
|
|
|
done
|
2018-05-01 14:50:29 +00:00
|
|
|
[ $expect != 0 ] && echo "expect: $expect"
|
|
|
|
[ $fail != 0 ] && echo "failed: $fail"
|
|
|
|
[ $fail -lt $expect ] && echo "solved: $(($expect - $fail))"
|
|
|
|
echo "passed: $pass"
|
|
|
|
echo "total: $total"
|
|
|
|
if [ $fail != 0 -a $fail -gt $expect ]; then
|
2018-04-29 16:38:57 +00:00
|
|
|
echo FAILED: $fail/$total
|
|
|
|
exit 1
|
2018-05-01 14:50:29 +00:00
|
|
|
elif [ $fail != 0 ]; then
|
|
|
|
echo PASS: $pass/$total
|
2018-04-29 16:38:57 +00:00
|
|
|
else
|
|
|
|
echo PASS: $total
|
|
|
|
fi
|