2018-06-24 17:10:39 +03:00
|
|
|
# Mains testing
|
2018-04-24 20:12:49 +03:00
|
|
|
|
2019-02-27 09:48:21 +02:00
|
|
|
Test methods by their output and exit codes (return, since it is the main).
|
2018-04-24 20:12:49 +03:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
Every test here is tested first as an Interpreter test, and then as binary (arm).
|
2018-06-24 17:10:39 +03:00
|
|
|
|
2019-02-27 09:48:21 +02:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
## Setup and assert
|
2019-09-24 22:05:38 +03:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
The setup require the @input variable to hold the code. This is usually renerated with
|
|
|
|
as_main or similar helper.
|
2018-06-24 17:10:39 +03:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
The @preload may be set to load any of the Macros, so one can actually use methods.
|
|
|
|
Otherwise the only methods are the ones you code
|
2019-02-27 09:48:21 +02:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
The assert_result takes the exit code and std out. It runs both interpreter and arm,
|
|
|
|
in that order.
|
2018-06-24 17:10:39 +03:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
### Interpreter
|
2019-02-27 09:48:21 +02:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
The interpreter is for the most part like another platform. Everything up to the
|
|
|
|
creation of binaries is the same. The Linker object get's passed to the
|
|
|
|
Interpreter which runs the code to the end, and returns return code and stdout.
|
2019-02-27 09:48:21 +02:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
If this passes, arm is run.
|
2019-02-27 09:48:21 +02:00
|
|
|
|
2020-03-28 19:46:07 +02:00
|
|
|
### Arm
|
|
|
|
|
|
|
|
Arm is actually only run if:
|
|
|
|
- you set TEST_ALL (as is done in test/test_all)
|
|
|
|
- you set TEST_ARM
|
|
|
|
|
|
|
|
AND it requires that you have qemu set up correctly. But given all that, it:
|
|
|
|
- creates a binary from the code (mains.o), which is linked to a.out
|
|
|
|
- runs the binary
|
|
|
|
- captures return code and stdout and returns
|
|
|
|
|
|
|
|
Obviously Interpreter AND Arm need to return same codes, the one the assert specifies.
|
|
|
|
|
|
|
|
## Status
|
|
|
|
|
|
|
|
I have moved most of the risc/interpreter code here, which means we now have over 50
|
|
|
|
binary tests.
|
|
|
|
|
|
|
|
Next i will recreate the file based tests in a better way to integrate with the
|
|
|
|
current style.
|