mescc: Mes C Library: Populate with function tests from scaffold.

* .gitignore: Update.
* build-aux/bootstrap.sh.in: Update.
* build-aux/build-mes.sh: Update.
* build-aux/check-mescc.sh: Update.
* lib/tests/assert/50-assert.c: Move from scaffold/tests/50-assert.c.
* lib/tests/dirent/90-readdir.c: Move from scaffold/tests/99-readdir.c.
* lib/tests/dirent/readdir.dir: Move from scaffold/tests/readdir.dir.
* lib/tests/io/90-stat.c: Move from scaffold/tests/92-stat.c.
* lib/tests/mes/30-oputs.c: Move from scaffold/tests/31-oputs.c.
* lib/tests/mes/50-itoa.c: Move from scaffold/tests/51-itoa.c.
* lib/tests/posix/90-unsetenv.c: Move from scaffold/tests/94-unsetenv.c.
* lib/tests/setjmp/80-setjmp.c: Move from scaffold/tests/80-setjmp.c.
* lib/tests/signal/90-signal.c: Move from scaffold/tests/95-signal.c.
* lib/tests/stdio/70-printf-hello.c: Move from scaffold/tests/70-printf-hello.c.
* lib/tests/stdio/70-printf-simple.c: Move from scaffold/tests/70-printf-simple.c.
* lib/tests/stdio/70-printf.c: Move from scaffold/tests/70-printf.c.
* lib/tests/stdio/80-sscanf.c: Move from scaffold/tests/87-sscanf.c.
* lib/tests/stdio/90-fopen-append.c: Move from scaffold/tests/98-fopen.c.
* lib/tests/stdio/90-fopen.c: Move from scaffold/tests/97-fopen.c.
* lib/tests/stdio/90-fread-fwrite.c: Move from scaffold/tests/93-fread-fwrite.c.
* lib/tests/stdio/90-fseek.c: Move from scaffold/tests/91-fseek.c.
* lib/tests/stdlib/50-getenv.c: Move from lib/tests/stdlib/getenv.c.
* lib/tests/stdlib/50-malloc.c: Move from lib/tests/stdlib/malloc.c.
* lib/tests/stdlib/70-strtoull.c: Move from scaffold/tests/7j-strtoull.c.
* lib/tests/stdlib/80-qsort-dupes.c: Move from scaffold/tests/81-qsort-dupes.c.
* lib/tests/stdlib/80-qsort.c: Move from scaffold/tests/81-qsort.c.
* lib/tests/stdlib/90-strtol.c: Move from scaffold/tests/96-strto.c.
* lib/tests/string/30-strlen.c: Move from scaffold/tests/30-strlen.c.
* lib/tests/string/50-strcmp.c: Move from scaffold/tests/51-strcmp.c.
* lib/tests/string/50-strcpy.c: Move from scaffold/tests/53-strcpy.c.
* lib/tests/string/50-strncmp.c: Move from scaffold/tests/51-strncmp.c.
* lib/tests/string/70-strchr.c: Move from scaffold/tests/70-strchr.c.
* lib/tests/string/80-strncpy.c: Move from scaffold/tests/86-strncpy.c.
* lib/tests/string/80-strrchr.c: Move from scaffold/tests/88-strrchr.c.
* lib/tests/string/90-snprintf.c: Move from scaffold/tests/9a-snprintf.c.
* lib/tests/string/90-strpbrk.c: Move from scaffold/tests/90-strpbrk.c.
* lib/tests/string/90-strspn.c: Move from scaffold/tests/90-strspn.c.
This commit is contained in:
Jan Nieuwenhuizen 2018-12-30 17:51:53 +01:00
parent d3c9fcf57a
commit 8b21ff5925
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
43 changed files with 228 additions and 224 deletions

12
.gitignore vendored
View File

@ -62,6 +62,12 @@
/lib/x86-mes/0exit-42
/lib/x86-mes/exit-42
/lib/tests/*/[0-9a][0-9a-z]-*
/lib/tests/*/x86-mes-*
!/lib/tests/*/*.c
!/lib/tests/*/*.exit
!/lib/tests/*/*.stdout
/scaffold/argv
/scaffold/hello
/scaffold/main
@ -73,7 +79,11 @@
/scaffold/x86_64-mes-*
/scaffold/tests/x86-mes-*
/scaffold/tests/[0-9a][0-9a-z]-[^.]*
/scaffold/tests/[0-9a][0-9a-z]-*
/scaffold/tests/t.*
!/scaffold/tests/*.c
!/scaffold/tests/*.exit
!/scaffold/tests/*.stdout
/src/mes.mes.symbols.h
/src/gc.mes.h

View File

@ -51,9 +51,9 @@ mv lib/libc+gnu.x86-mes-o lib/x86-mes/libc+gnu.o
@GUILE@ -e main -L module scripts/mescc.scm -v -g -L lib/linux/x86-mes -L lib/linux -L lib/x86-mes -L lib -L @MES_SEED@ -o scaffold/x86-mes-argv scaffold/argv.x86-mes-o -l c-mini
@GUILE@ -e main -L module scripts/mescc.scm -c -D 'VERSION="@VERSION@"' -D 'MODULEDIR="@moduledir@"' -D 'PREFIX="@prefix@"' -I . -I lib -I include -v -g -L lib/linux/x86-mes -L lib/linux -L lib/x86-mes -L lib -L @MES_SEED@ -o lib/tests/stdlib/malloc.x86-mes-o lib/tests/stdlib/malloc.c
@GUILE@ -e main -L module scripts/mescc.scm -c -D 'VERSION="@VERSION@"' -D 'MODULEDIR="@moduledir@"' -D 'PREFIX="@prefix@"' -I . -I lib -I include -v -g -L lib/linux/x86-mes -L lib/linux -L lib/x86-mes -L lib -L @MES_SEED@ -o lib/tests/stdlib/50-malloc.x86-mes-o lib/tests/stdlib/50-malloc.c
@GUILE@ -e main -L module scripts/mescc.scm -c -D 'VERSION="@VERSION@"' -D 'MODULEDIR="@moduledir@"' -D 'PREFIX="@prefix@"' -I . -I lib -I include -v -g -L lib/linux/x86-mes -L lib/linux -L lib/x86-mes -L lib -L @MES_SEED@ -o lib/tests/stdlib/getenv.x86-mes-o lib/tests/stdlib/getenv.c
@GUILE@ -e main -L module scripts/mescc.scm -c -D 'VERSION="@VERSION@"' -D 'MODULEDIR="@moduledir@"' -D 'PREFIX="@prefix@"' -I . -I lib -I include -v -g -L lib/linux/x86-mes -L lib/linux -L lib/x86-mes -L lib -L @MES_SEED@ -o lib/tests/posix/50-getenv.x86-mes-o lib/tests/posix/50-getenv.c
@GUILE@ -e main -L module scripts/mescc.scm -c -D 'VERSION="@VERSION@"' -D 'MODULEDIR="@moduledir@"' -D 'PREFIX="@prefix@"' -I . -I lib -I include -v -g -L lib/linux/x86-mes -L lib/linux -L lib/x86-mes -L lib -L @MES_SEED@ -o scaffold/micro-mes.x86-mes-o scaffold/micro-mes.c

View File

@ -69,11 +69,11 @@ compile scaffold/hello
compile scaffold/argv
(libc="-l c-mini" link scaffold/argv)
[ "$mes_p" ] && compile lib/tests/stdlib/malloc
[ "$mes_p" ] && link lib/tests/stdlib/malloc
[ "$mes_p" ] && compile lib/tests/stdlib/50-malloc
[ "$mes_p" ] && link lib/tests/stdlib/50-malloc
[ "$mes_p" ] && compile lib/tests/stdlib/getenv
[ "$mes_p" ] && link lib/tests/stdlib/getenv
[ "$mes_p" ] && compile lib/tests/posix/50-getenv
[ "$mes_p" ] && link lib/tests/posix/50-getenv
[ "$mes_p" ] && compile scaffold/micro-mes

View File

@ -26,206 +26,207 @@ set -e
test_sh=${test_sh-${srcdest}build-aux/test.sh}
tests="
t
00-exit-0
01-return-0
02-return-1
03-call
04-call-0
05-call-1
06-call-!1
06-!call-1
06-call-2
06-call-string
06-call-variable
06-return-void
07-include
08-assign
08-assign-negative
08-assign-global
10-if-0
11-if-1
12-if-==
13-if-!=
14-if-goto
15-if-!f
16-if-t
17-compare-char
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
17-compare-unsigned-char-le
17-compare-unsigned-short-le
17-compare-unsigned-long-le
17-compare-and
17-compare-or
17-compare-and-or
17-compare-assign
17-compare-call
18-assign-shadow
20-while
21-char[]-simple
21-char[]
22-while-char[]
23-global-pointer-init-null
23-global-pointer-init
23-global-pointer-ref
23-global-pointer-pointer-ref
23-pointer-sub
23-pointer
30-strlen
31-oputs
32-call-wrap
32-compare
33-and-or
34-pre-post
35-compare-char
36-compare-arithmetic
37-compare-assign
38-compare-call-2
38-compare-call-3
38-compare-call
40-if-else
41-?
42-goto-label
43-for-do-while
44-switch
44-switch-fallthrough
44-switch-body-fallthrough
45-void-call
46-function-static
47-function-expression
48-global-static
50-assert
51-pointer-sub
51-itoa
51-strcmp
51-strncmp
53-strcpy
54-argc
54-argv
55-char-array
60-math
61-array
62-array
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
63-struct-cell
64-make-cell
65-read
66-local-char-array
70-strchr
70-stdarg
70-printf-hello
70-printf-simple
70-printf
71-struct-array
72-typedef-struct-def
73-union-hello
73-union
74-multi-line-string
75-struct-union
76-pointer-arithmetic-pp
76-pointer-arithmetic
77-pointer-assign
78-union-struct
79-int-array-simple
79-int-array
7a-struct-char-array
7b-struct-int-array-hello
7b-struct-int-array-pointer
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-simple
7i-struct-struct
7j-strtoull
7k-empty-for
7k-for-each-elem-simple
7k-for-each-elem
7l-struct-any-size-array-simple
7l-struct-any-size-array
7m-struct-char-array-assign
7n-struct-struct-array
7o-struct-pre-post-simple
7o-struct-pre-post
7p-struct-cast
7q-bit-field-simple
7q-bit-field
7r-sign-extend
7s-struct-short
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
80-setjmp
81-qsort
81-qsort-dupes
82-define
83-heterogenoous-init
84-struct-field-list
85-sizeof
86-strncpy
87-sscanf
88-strrchr
90-strspn
90-strpbrk
91-fseek
92-stat
93-fread-fwrite
94-unsetenv
95-signal
96-strto
97-fopen
98-fopen
99-readdir
9a-snprintf
a0-call-trunc-char
a0-call-trunc-short
a0-call-trunc-int
a0-math-divide-signed-negative
a1-global-no-align
a1-global-no-clobber
scaffold/tests/t
scaffold/tests/00-exit-0
scaffold/tests/01-return-0
scaffold/tests/02-return-1
scaffold/tests/03-call
scaffold/tests/04-call-0
scaffold/tests/05-call-1
scaffold/tests/06-call-!1
scaffold/tests/06-!call-1
scaffold/tests/06-call-2
scaffold/tests/06-call-string
scaffold/tests/06-call-variable
scaffold/tests/06-return-void
scaffold/tests/07-include
scaffold/tests/08-assign
scaffold/tests/08-assign-negative
scaffold/tests/08-assign-global
scaffold/tests/10-if-0
scaffold/tests/11-if-1
scaffold/tests/12-if-==
scaffold/tests/13-if-!=
scaffold/tests/14-if-goto
scaffold/tests/15-if-!f
scaffold/tests/16-if-t
scaffold/tests/17-compare-char
scaffold/tests/17-compare-ge
scaffold/tests/17-compare-gt
scaffold/tests/17-compare-le
scaffold/tests/17-compare-lt
scaffold/tests/17-compare-unsigned-ge
scaffold/tests/17-compare-unsigned-gt
scaffold/tests/17-compare-unsigned-le
scaffold/tests/17-compare-unsigned-lt
scaffold/tests/17-compare-unsigned-char-le
scaffold/tests/17-compare-unsigned-short-le
scaffold/tests/17-compare-unsigned-long-le
scaffold/tests/17-compare-and
scaffold/tests/17-compare-or
scaffold/tests/17-compare-and-or
scaffold/tests/17-compare-assign
scaffold/tests/17-compare-call
scaffold/tests/18-assign-shadow
scaffold/tests/20-while
scaffold/tests/21-char[]-simple
scaffold/tests/21-char[]
scaffold/tests/22-while-char[]
scaffold/tests/23-global-pointer-init-null
scaffold/tests/23-global-pointer-init
scaffold/tests/23-global-pointer-ref
scaffold/tests/23-global-pointer-pointer-ref
scaffold/tests/23-pointer-sub
scaffold/tests/23-pointer
lib/tests/mes/30-oputs
lib/tests/string/30-strlen
scaffold/tests/32-call-wrap
scaffold/tests/32-compare
scaffold/tests/33-and-or
scaffold/tests/34-pre-post
scaffold/tests/35-compare-char
scaffold/tests/36-compare-arithmetic
scaffold/tests/37-compare-assign
scaffold/tests/38-compare-call-2
scaffold/tests/38-compare-call-3
scaffold/tests/38-compare-call
scaffold/tests/40-if-else
scaffold/tests/41-?
scaffold/tests/42-goto-label
scaffold/tests/43-for-do-while
scaffold/tests/44-switch
scaffold/tests/44-switch-fallthrough
scaffold/tests/44-switch-body-fallthrough
scaffold/tests/45-void-call
scaffold/tests/46-function-static
scaffold/tests/47-function-expression
scaffold/tests/48-global-static
lib/tests/assert/50-assert
lib/tests/mes/50-itoa
lib/tests/posix/50-getenv
lib/tests/string/50-strcmp
lib/tests/string/50-strcpy
lib/tests/string/50-strncmp
scaffold/tests/51-pointer-sub
scaffold/tests/54-argc
scaffold/tests/54-argv
scaffold/tests/55-char-array
scaffold/tests/60-math
scaffold/tests/61-array
scaffold/tests/62-array
scaffold/tests/63-struct
scaffold/tests/63-struct-pointer
scaffold/tests/63-struct-local
scaffold/tests/63-struct-function
scaffold/tests/63-struct-assign
scaffold/tests/63-struct-array
scaffold/tests/63-struct-array-assign
scaffold/tests/63-struct-array-compare
scaffold/tests/63-struct-cell
scaffold/tests/64-make-cell
scaffold/tests/65-read
scaffold/tests/66-local-char-array
scaffold/tests/70-stdarg
lib/tests/stdio/70-printf-hello
lib/tests/stdio/70-printf-simple
lib/tests/stdio/70-printf
lib/tests/stdlib/70-strtoull
lib/tests/string/70-strchr
scaffold/tests/71-struct-array
scaffold/tests/72-typedef-struct-def
scaffold/tests/73-union-hello
scaffold/tests/73-union
scaffold/tests/74-multi-line-string
scaffold/tests/75-struct-union
scaffold/tests/76-pointer-arithmetic-pp
scaffold/tests/76-pointer-arithmetic
scaffold/tests/77-pointer-assign
scaffold/tests/78-union-struct
scaffold/tests/79-int-array-simple
scaffold/tests/79-int-array
scaffold/tests/7a-struct-char-array
scaffold/tests/7b-struct-int-array-hello
scaffold/tests/7b-struct-int-array-pointer
scaffold/tests/7b-struct-int-array
scaffold/tests/7c-dynarray
scaffold/tests/7d-cast-char
scaffold/tests/7e-struct-array-access
scaffold/tests/7f-struct-pointer-arithmetic
scaffold/tests/7g-struct-byte-word-field
scaffold/tests/7h-struct-assign
scaffold/tests/7i-struct-struct-simple
scaffold/tests/7i-struct-struct
scaffold/tests/7k-empty-for
scaffold/tests/7k-for-each-elem-simple
scaffold/tests/7k-for-each-elem
scaffold/tests/7l-struct-any-size-array-simple
scaffold/tests/7l-struct-any-size-array
scaffold/tests/7m-struct-char-array-assign
scaffold/tests/7n-struct-struct-array
scaffold/tests/7o-struct-pre-post-simple
scaffold/tests/7o-struct-pre-post
scaffold/tests/7p-struct-cast
scaffold/tests/7q-bit-field-simple
scaffold/tests/7q-bit-field
scaffold/tests/7r-sign-extend
scaffold/tests/7s-struct-short
scaffold/tests/7s-unsigned-compare
scaffold/tests/7t-function-destruct
scaffold/tests/7u-double
scaffold/tests/7u-long-long
scaffold/tests/7u-?-expression
scaffold/tests/7u-call-?
scaffold/tests/7u-inc-byte-word
scaffold/tests/7u-struct-func
scaffold/tests/7u-struct-size10
scaffold/tests/7u-vstack
lib/tests/setjmp/80-setjmp
lib/tests/stdio/80-sscanf
lib/tests/stdlib/80-qsort
lib/tests/stdlib/80-qsort-dupes
lib/tests/string/80-strncpy
lib/tests/string/80-strrchr
scaffold/tests/82-define
scaffold/tests/83-heterogenoous-init
scaffold/tests/84-struct-field-list
scaffold/tests/85-sizeof
lib/tests/dirent/90-readdir
lib/tests/io/90-stat
lib/tests/posix/90-unsetenv
lib/tests/signal/90-signal
lib/tests/stdio/90-fopen
lib/tests/stdio/90-fopen-append
lib/tests/stdio/90-fread-fwrite
lib/tests/stdio/90-fseek
lib/tests/stdlib/90-strtol
lib/tests/string/90-snprintf
lib/tests/string/90-strpbrk
lib/tests/string/90-strspn
scaffold/tests/a0-call-trunc-char
scaffold/tests/a0-call-trunc-short
scaffold/tests/a0-call-trunc-int
scaffold/tests/a0-math-divide-signed-negative
scaffold/tests/a1-global-no-align
scaffold/tests/a1-global-no-clobber
"
broken="$broken
17-compare-unsigned-char-le
17-compare-unsigned-short-le
66-local-char-array
a0-call-trunc-int
a0-math-divide-signed-negative
scaffold/tests/17-compare-unsigned-char-le
scaffold/tests/17-compare-unsigned-short-le
scaffold/tests/66-local-char-array
scaffold/tests/a0-call-trunc-int
scaffold/tests/a0-math-divide-signed-negative
"
if [ "$mes_arch" = "x86_64-gcc" ]; then
broken="$broken
21-char[]
41-?
70-printf-stdarg
70-printf-simple
70-printf
80-setjmp
a1-global-no-align
scaffold/tests/21-char[]
scaffold/tests/41-?
scaffold/tests/stdio/70-printf-stdarg
scaffold/tests/stdio/70-printf-simple
scaffold/tests/stdio/70-printf
lib/tests/setjmp/80-setjmp
scaffold/tests/a1-global-no-align
"
fi
@ -234,20 +235,20 @@ expect=$(echo $broken | wc -w)
pass=0
fail=0
total=0
mkdir -p scaffold/tests
for t in $tests; do
if [ -z "${t/[012][0-9]-*/}" ]; then
b=$(basename "$t")
if [ -z "${b/[012][0-9]-*/}" ]; then
libc=
elif [ -z "${t/[34][0-9]-*/}" ]; then
elif [ -z "${b/[34][0-9]-*/}" ]; then
libc='-l c-mini'
elif [ -z "${t/[78][0-9a-z]-*/}" ]; then
elif [ -z "${b/[78][0-9a-z]-*/}" ]; then
libc='-l c+tcc'
elif [ -z "${t/9[0-9a-z]-*/}" ]; then
elif [ -z "${b/9[0-9a-z]-*/}" ]; then
libc='-l c+gnu'
else
libc='-l c'
fi
sh $test_sh "scaffold/tests/$t" &> scaffold/tests/"$t".log
sh $test_sh "$t" &> "$t".log
r=$?
total=$((total+1))
if [ $r = 0 ]; then

View File

@ -38,12 +38,12 @@ link "$t"
r=0
[ -f "$t".exit ] && r=$(cat "$t".exit)
set +e
$(dirname "$o")/${program_prefix}$(basename "$o") $ARGS > "$o".${program_prefix}stdout
$(dirname "$o")/${program_prefix}$(basename "$o") $ARGS > "$o".${program_prefix}1 2> "$o".${program_prefix}2
m=$?
cat "$o".${program_prefix}stdout
cat "$o".${program_prefix}1
set -e
[ $m = $r ]
if [ -f "$t".expect ]; then
$DIFF -ub "$t".expect "$o".${program_prefix}stdout
if [ -f "$t".stdout ]; then
$DIFF -ub "$t".stdout "$o".${program_prefix}1
fi

View File

@ -60,9 +60,9 @@ __mes_debug ()
#if !___GNU__
#include <string/memcpy.c>
#include <stdlib/malloc.c>
#include <assert/assert.c>
#include <stdlib/malloc.c>
#include <string/memcpy.c>
#endif
#include <stdio/getchar.c>
@ -82,9 +82,9 @@ __mes_debug ()
#include <stdlib/free.c>
#include <stdlib/realloc.c>
#include <stdlib/getenv.c>
#include <stdlib/setenv.c>
#include <posix/getenv.c>
#include <posix/isatty.c>
#include <posix/setenv.c>
#include <posix/wait.c>
#include <posix/execv.c>

View File

@ -34,20 +34,20 @@ qsort_strcmp (void const* a, void const* b)
int
main ()
{
DIR *d = opendir ("scaffold/tests/readdir-fu");
DIR *d = opendir ("lib/tests/dirent/readdir-fu");
if (d)
return 1;
if (errno != ENOENT)
return 2;
d = opendir ("scaffold/tests/99-readdir.c");
d = opendir ("lib/tests/dirent/90-readdir.c");
if (d)
return 3;
if (errno != ENOTDIR)
return 4;
errno = 0;
d = opendir ("scaffold/tests/readdir.dir");
d = opendir ("lib/tests/dirent/readdir.dir");
if (!d)
return 5;

View File

@ -19,14 +19,7 @@
*/
#include "libmes.h"
#include "string.h"
#include "stdlib.h"
#define strlen xstrlen
#define strncmp xstrncmp
#define getenv xgetenv
#include "lib/string/strlen.c"
#include "lib/string/strncmp.c"
#include "lib/stdlib/getenv.c"
int
main (int argc, char const *argv[])