Something weird happens if one tries to clean and test at the same time
with a command like:
make clean test -j2
See https://lists.gnu.org/archive/html/help-make/2021-01/msg00000.html
To be safe until further investigation, we breakup the makefile into 2
files and serialize the first where M2-Planet is built.
For any test there's a directory with a script for each architecture.
These scripts generate intermediate files in the dir during compilation,
with the same names no matter the arch. So if one tries to execute the
scripts in parallel they all fight for the files.
To allow for parallel testing, now we create a temporal dir named after
the arch to isolate the intermediate files. Scripts are patched
accordingly.
This also allows easier clean-up: now, removing the temporal dirs is
almost all that we need (and the per-test .gitignore files are replaced
with a couple of lines in test/.gitignore). A common script replaces
the per-test cleanup.sh. It gets the number of the test as an argument
and takes care of some minor special cases. The makefile is adapted to
use this new test/cleanup_test.sh script.
Those special files are created during the last stage of each test, but
only if the host arch matches the test. They're _not_ isolated here
because it's harder (due to how we do the checksum) and they cannot
collide unless emulation is used and several calls to make are made at
the same time.
- disables --bootstrap-mode where it was enabled, except for test1000
which needs to build in bootstrap-mode to check that M2-Planet can be
compiled by cc_*
- the only hold-out is test0021 which needs getcwd which is missing in
M2libc
- note that test0106 needs a fix to fgetc or it will never notice it has
reached the end of stdin
- no longer generate CONSTANT lines for #defined constants
- "#define FOO 1" turns "return FOO;" into "return 1;"
- Macros expanding into a macro is not supported:
#define FOO 1
#define BAR FOO
will expand BAR to FOO, not to 1
- Expansion inside #if conditions is not supported.
- Function-like macros are not supported.
- // and # lines always appear in the result of read_all_tokens
- in bootstrap mode, // tokens (but not the subsequent lines) and #
lines are stripped. no preprocessing happens.
- in non-bootstrap mode, // lines are stripped and # lines stay for the
preprocessing phase
- updates tests to pass --bootstrap-mode when necessary
- support for #if, #elif, #else, #endif, but no macro expansion just
yet. Any macro is treated as undefined and expands to 0.
for example:
./bin/M2-Planet -E test.c
#if 1 == FOO
foo
#else
bar
#endif
results in
bar
- change the lexer to not remove preprocessor directives
- preprocess() removes any lines starting with a macro directive that it
doesn't understand (which is currently all of them)
- needed to determine start and end of macro directives
- the main parser doesn't need them, so strip out the newline tokens
before parsing to avoid changing it
Note that this is a backwards incompatible change: Unlike POSIX, exit()
will not flush all open streams, so you are responsible for flushing or
closing all your streams before successful exit.
Also, file.c will now also require calloc.c (and malloc.c).
Updated the test cases accordingly.
Only implemented and tested for x86.
The close syscall was missing an indirection and therefore closed random
file descriptors (very visible in strace output).
Test 0104 did not properly null terminate the envp, resulting in -EFAULT
on execve syscall in case the next value in memory does not happen to be
0 (which it seems to be right now).