2018-04-29 16:38:57 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
2018-07-22 12:24:36 +00:00
|
|
|
# GNU Mes --- Maxwell Equations of Software
|
2018-04-29 16:38:57 +00:00
|
|
|
# Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
|
|
|
#
|
2018-07-22 12:24:36 +00:00
|
|
|
# This file is part of GNU Mes.
|
2018-04-29 16:38:57 +00:00
|
|
|
#
|
2018-07-22 12:24:36 +00:00
|
|
|
# GNU Mes is free software; you can redistribute it and/or modify it
|
2018-04-29 16:38:57 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2018-07-22 12:24:36 +00:00
|
|
|
# GNU Mes is distributed in the hope that it will be useful, but
|
2018-04-29 16:38:57 +00:00
|
|
|
# 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
|
2018-07-22 12:24:36 +00:00
|
|
|
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
2018-04-29 16:38:57 +00:00
|
|
|
|
2018-07-21 22:43:39 +00:00
|
|
|
set -e
|
2018-07-25 06:14:13 +00:00
|
|
|
. ${srcdest}build-aux/config.sh
|
|
|
|
. ${srcdest}build-aux/trace.sh
|
2018-04-29 16:38:57 +00:00
|
|
|
|
2018-05-03 18:32:06 +00:00
|
|
|
MES=${MES-src/mes}
|
2018-07-25 06:14:13 +00:00
|
|
|
[ -z "$MESCC" ] && MESCC=scripts/mescc
|
2018-05-03 18:32:06 +00:00
|
|
|
GUILE=${GUILE-guile}
|
2018-07-21 05:15:52 +00:00
|
|
|
MES_PREFIX=${MES_PREFIX-mes}
|
2018-05-03 18:32:06 +00:00
|
|
|
|
|
|
|
HEX2=${HEX2-hex2}
|
|
|
|
M1=${M1-M1}
|
|
|
|
BLOOD_ELF=${BLOOD_ELF-blood-elf}
|
|
|
|
MES_SEED=${MES_SEED-../mes-seed}
|
|
|
|
MESCC=${MESCC-$(command -v mescc)}
|
2018-07-25 06:14:13 +00:00
|
|
|
[ -z "$MESCC" ] && MESCC=scripts/mescc
|
2018-05-03 18:32:06 +00:00
|
|
|
MES=${MES-$(command -v mes)}
|
2018-07-25 06:14:13 +00:00
|
|
|
[ -z "$MES" ] && MES=src/mes
|
2018-04-29 16:38:57 +00:00
|
|
|
|
2018-05-25 06:05:02 +00:00
|
|
|
if ! command -v $GUILE > /dev/null; then
|
|
|
|
GUILE=true
|
|
|
|
fi
|
2018-04-29 16:38:57 +00:00
|
|
|
|
2018-08-15 16:26:55 +00:00
|
|
|
test_sh=${test_sh-${srcdest}build-aux/test.sh}
|
|
|
|
if [ "$arch" = "x86_64-mes" ]; then
|
|
|
|
test_sh=${srcdest}build-aux/test64.sh
|
|
|
|
fi
|
|
|
|
|
2018-04-29 16:38:57 +00:00
|
|
|
tests="
|
|
|
|
t
|
|
|
|
00-exit-0
|
|
|
|
01-return-0
|
|
|
|
02-return-1
|
|
|
|
03-call
|
|
|
|
04-call-0
|
|
|
|
05-call-1
|
|
|
|
06-call-!1
|
2018-08-15 16:26:55 +00:00
|
|
|
06-!call-1
|
|
|
|
06-call-2
|
|
|
|
06-call-string
|
|
|
|
06-call-variable
|
|
|
|
06-return-void
|
2018-08-15 17:11:54 +00:00
|
|
|
07-include
|
|
|
|
08-assign
|
2018-08-15 16:26:55 +00:00
|
|
|
08-assign-negative
|
|
|
|
08-assign-global
|
2018-04-29 16:38:57 +00:00
|
|
|
10-if-0
|
|
|
|
11-if-1
|
|
|
|
12-if-==
|
|
|
|
13-if-!=
|
|
|
|
14-if-goto
|
|
|
|
15-if-!f
|
|
|
|
16-if-t
|
2018-12-13 17:19:19 +00:00
|
|
|
17-compare-char
|
2018-08-15 16:26:55 +00:00
|
|
|
17-compare-ge
|
|
|
|
17-compare-gt
|
|
|
|
17-compare-le
|
|
|
|
17-compare-lt
|
|
|
|
17-compare-unsigned-ge
|
|
|
|
17-compare-unsigned-gt
|
|
|
|
17-compare-unsigned-le
|
|
|
|
17-compare-unsigned-lt
|
2018-10-06 12:51:57 +00:00
|
|
|
17-compare-unsigned-char-le
|
|
|
|
17-compare-unsigned-short-le
|
|
|
|
17-compare-unsigned-long-le
|
2018-08-15 16:26:55 +00:00
|
|
|
17-compare-and
|
|
|
|
17-compare-or
|
|
|
|
17-compare-and-or
|
|
|
|
17-compare-assign
|
|
|
|
17-compare-call
|
|
|
|
18-assign-shadow
|
2018-04-29 16:38:57 +00:00
|
|
|
20-while
|
2018-08-15 16:26:55 +00:00
|
|
|
21-char[]-simple
|
2018-04-29 16:38:57 +00:00
|
|
|
21-char[]
|
|
|
|
22-while-char[]
|
2018-08-15 16:26:55 +00:00
|
|
|
23-global-pointer-init-null
|
|
|
|
23-global-pointer-init
|
|
|
|
23-global-pointer-ref
|
|
|
|
23-global-pointer-pointer-ref
|
|
|
|
23-pointer-sub
|
2018-04-29 16:38:57 +00:00
|
|
|
23-pointer
|
|
|
|
30-strlen
|
2018-08-15 16:26:55 +00:00
|
|
|
31-oputs
|
|
|
|
32-call-wrap
|
2018-04-29 16:38:57 +00:00
|
|
|
32-compare
|
|
|
|
33-and-or
|
|
|
|
34-pre-post
|
|
|
|
35-compare-char
|
|
|
|
36-compare-arithmetic
|
|
|
|
37-compare-assign
|
2018-08-15 16:26:55 +00:00
|
|
|
38-compare-call-2
|
|
|
|
38-compare-call-3
|
2018-04-29 16:38:57 +00:00
|
|
|
38-compare-call
|
|
|
|
40-if-else
|
|
|
|
41-?
|
|
|
|
42-goto-label
|
|
|
|
43-for-do-while
|
|
|
|
44-switch
|
2018-08-15 16:26:55 +00:00
|
|
|
44-switch-fallthrough
|
|
|
|
44-switch-body-fallthrough
|
2018-04-29 16:38:57 +00:00
|
|
|
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
|
2018-08-15 16:26:55 +00:00
|
|
|
48-global-static
|
2018-04-29 16:38:57 +00:00
|
|
|
50-assert
|
2018-08-15 16:26:55 +00:00
|
|
|
51-pointer-sub
|
|
|
|
51-itoa
|
2018-04-29 16:38:57 +00:00
|
|
|
51-strcmp
|
2018-08-21 18:33:54 +00:00
|
|
|
51-strncmp
|
2018-04-29 16:38:57 +00:00
|
|
|
53-strcpy
|
2018-08-15 16:26:55 +00:00
|
|
|
54-argc
|
2018-04-29 16:38:57 +00:00
|
|
|
54-argv
|
2018-08-15 16:26:55 +00:00
|
|
|
55-char-array
|
2018-04-29 16:38:57 +00:00
|
|
|
60-math
|
|
|
|
61-array
|
2018-05-05 10:30:06 +00:00
|
|
|
62-array
|
2018-08-15 16:26:55 +00:00
|
|
|
63-struct
|
|
|
|
63-struct-pointer
|
|
|
|
63-struct-local
|
|
|
|
63-struct-function
|
|
|
|
63-struct-assign
|
|
|
|
63-struct-array
|
|
|
|
63-struct-array-assign
|
|
|
|
63-struct-array-compare
|
2018-04-29 16:38:57 +00:00
|
|
|
63-struct-cell
|
|
|
|
64-make-cell
|
|
|
|
65-read
|
2018-08-15 16:26:55 +00:00
|
|
|
66-local-char-array
|
|
|
|
70-strchr
|
|
|
|
70-stdarg
|
|
|
|
70-printf-hello
|
|
|
|
70-printf-simple
|
2018-04-29 16:38:57 +00:00
|
|
|
70-printf
|
|
|
|
71-struct-array
|
|
|
|
72-typedef-struct-def
|
2018-08-15 16:26:55 +00:00
|
|
|
73-union-hello
|
2018-04-29 16:38:57 +00:00
|
|
|
73-union
|
|
|
|
74-multi-line-string
|
|
|
|
75-struct-union
|
2018-08-15 16:26:55 +00:00
|
|
|
76-pointer-arithmetic-pp
|
2018-04-29 16:38:57 +00:00
|
|
|
76-pointer-arithmetic
|
|
|
|
77-pointer-assign
|
|
|
|
78-union-struct
|
2018-08-15 16:26:55 +00:00
|
|
|
79-int-array-simple
|
2018-04-29 16:38:57 +00:00
|
|
|
79-int-array
|
|
|
|
7a-struct-char-array
|
2018-08-15 16:26:55 +00:00
|
|
|
7b-struct-int-array-hello
|
|
|
|
7b-struct-int-array-pointer
|
2018-04-29 16:38:57 +00:00
|
|
|
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
|
2018-08-15 16:26:55 +00:00
|
|
|
7i-struct-struct-simple
|
2018-04-29 16:38:57 +00:00
|
|
|
7i-struct-struct
|
|
|
|
7j-strtoull
|
2018-08-15 16:26:55 +00:00
|
|
|
7k-empty-for
|
|
|
|
7k-for-each-elem-simple
|
2018-04-29 16:38:57 +00:00
|
|
|
7k-for-each-elem
|
2018-08-15 16:26:55 +00:00
|
|
|
7l-struct-any-size-array-simple
|
2018-04-29 16:38:57 +00:00
|
|
|
7l-struct-any-size-array
|
|
|
|
7m-struct-char-array-assign
|
|
|
|
7n-struct-struct-array
|
2018-08-15 16:26:55 +00:00
|
|
|
7o-struct-pre-post-simple
|
2018-05-13 11:50:32 +00:00
|
|
|
7o-struct-pre-post
|
2018-05-11 22:20:51 +00:00
|
|
|
7p-struct-cast
|
2018-08-15 16:26:55 +00:00
|
|
|
7q-bit-field-simple
|
2018-05-13 15:05:28 +00:00
|
|
|
7q-bit-field
|
mescc: Tinycc support: Char and short sign extend.
* module/mes/as-i386.mes (i386:accu*n->local, i386:byte-accu->local+n,
i386:word-accu->local+n): Remove.
(i386:byte-accu, i386:signed-byte-accu, i386:word-accu,
i386:signed-word-accu): New function.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (accu->local+n-text): Simplify.
(mem->accu, convert-accu): New function.
(expr->accu): Use them.
* stage0/x86.M1 (mov____%al,0x32(%ebp), mov____%al,0x8(%ebp),
mov____%ax,0x32(%ebp), mov____%ax,0x8(%ebp), movzbl_0x32(%ebp),%eax,
movzbl_0x8(%ebp),%eax, movzwl_0x32(%ebp),%eax,
movzwl_0x8(%ebp),%eax): Deprecate.
* scaffold/tests/7r-sign-extend.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-05-18 21:58:10 +00:00
|
|
|
7r-sign-extend
|
2018-05-19 12:53:05 +00:00
|
|
|
7s-struct-short
|
2018-08-15 16:26:55 +00:00
|
|
|
7s-unsigned-compare
|
|
|
|
7t-function-destruct
|
|
|
|
7u-double
|
|
|
|
7u-long-long
|
|
|
|
7u-?-expression
|
|
|
|
7u-call-?
|
|
|
|
7u-inc-byte-word
|
|
|
|
7u-struct-func
|
|
|
|
7u-struct-size10
|
|
|
|
7u-vstack
|
2018-04-29 16:38:57 +00:00
|
|
|
80-setjmp
|
|
|
|
81-qsort
|
2018-08-27 20:37:12 +00:00
|
|
|
81-qsort-dupes
|
2018-04-29 16:38:57 +00:00
|
|
|
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-05-19 18:52:24 +00:00
|
|
|
86-strncpy
|
2018-05-30 19:49:40 +00:00
|
|
|
87-sscanf
|
2018-06-24 15:25:46 +00:00
|
|
|
88-strrchr
|
2018-08-15 16:26:55 +00:00
|
|
|
90-strspn
|
2018-05-30 19:55:39 +00:00
|
|
|
90-strpbrk
|
|
|
|
91-fseek
|
2018-06-03 16:54:26 +00:00
|
|
|
92-stat
|
|
|
|
93-fread-fwrite
|
2018-06-06 17:43:32 +00:00
|
|
|
94-unsetenv
|
2018-06-06 20:14:35 +00:00
|
|
|
95-signal
|
2018-06-06 20:39:57 +00:00
|
|
|
96-strto
|
2018-06-16 13:18:27 +00:00
|
|
|
97-fopen
|
2018-06-16 14:12:51 +00:00
|
|
|
98-fopen
|
2018-08-26 16:34:53 +00:00
|
|
|
99-readdir
|
2018-10-06 09:57:04 +00:00
|
|
|
a0-call-trunc-char
|
|
|
|
a0-call-trunc-short
|
2018-10-06 12:51:57 +00:00
|
|
|
a0-call-trunc-int
|
2018-10-06 15:28:08 +00:00
|
|
|
a0-math-divide-signed-negative
|
2018-10-06 13:56:14 +00:00
|
|
|
a1-global-no-align
|
|
|
|
a1-global-no-clobber
|
2018-04-29 16:38:57 +00:00
|
|
|
"
|
|
|
|
|
2018-05-01 14:50:29 +00:00
|
|
|
broken="$broken
|
2018-10-06 12:51:57 +00:00
|
|
|
17-compare-unsigned-char-le
|
|
|
|
17-compare-unsigned-short-le
|
2018-08-15 16:26:55 +00:00
|
|
|
66-local-char-array
|
2018-10-06 13:56:14 +00:00
|
|
|
a0-call-trunc-int
|
2018-10-06 15:28:08 +00:00
|
|
|
a0-math-divide-signed-negative
|
2018-05-01 14:50:29 +00:00
|
|
|
"
|
2018-04-29 16:38:57 +00:00
|
|
|
|
2018-06-02 09:41:06 +00:00
|
|
|
# gcc not supported
|
|
|
|
CC=
|
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-07-25 06:14:13 +00:00
|
|
|
mkdir -p scaffold/tests
|
2018-04-29 16:38:57 +00:00
|
|
|
for t in $tests; do
|
2018-08-16 19:04:36 +00:00
|
|
|
if [ -z "${t/[012][0-9]-*/}" ]; then
|
2018-08-15 15:47:03 +00:00
|
|
|
LIBC=
|
|
|
|
MES_LIBS="-l none"
|
2018-08-16 19:04:36 +00:00
|
|
|
elif [ -z "${t/[34][0-9]-*/}" ]; then
|
2018-05-29 18:07:46 +00:00
|
|
|
LIBC=c-mini
|
2018-07-09 09:49:49 +00:00
|
|
|
MES_LIBS="-l c-mini"
|
2018-05-30 19:55:39 +00:00
|
|
|
elif [ -z "${t/[78][0-9a-z]-*/}" ]; then
|
2018-05-29 18:07:46 +00:00
|
|
|
LIBC=c+tcc
|
2018-07-09 09:49:49 +00:00
|
|
|
MES_LIBS="-l c+tcc"
|
2018-05-30 19:55:39 +00:00
|
|
|
elif [ -z "${t/9[0-9]-*/}" ]; then
|
|
|
|
LIBC=c+gnu
|
2018-07-09 09:49:49 +00:00
|
|
|
MES_LIBS="-l c+gnu"
|
2018-05-01 14:50:29 +00:00
|
|
|
else
|
2018-05-29 18:07:46 +00:00
|
|
|
LIBC=c
|
2018-07-09 09:49:49 +00:00
|
|
|
MES_LIBS=
|
2018-05-01 14:50:29 +00:00
|
|
|
fi
|
2018-08-15 16:26:55 +00:00
|
|
|
sh $test_sh "scaffold/tests/$t" &> scaffold/tests/"$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
|