Skip to content

Simulator & regression test framework for the Leros ISA

Notifications You must be signed in to change notification settings

leros-dev/leros-sim

Repository files navigation

leros-sim

Simulator and verification suite for the Leros ISA

Verification suite

The simdriver.py python script is used for implementing a compiler- and simulator verification suite. The purpose of the verification suite is to have a set of C language tests which are executed on both the host system and the Leros simulator. Using the syntax described below, a single C source file can be specified, which will be compiled and run on both systems.

Currently, simdrivertests.txt contains the current test suite, containing test cases for the tests in tests/c/.

Usage

Initially, the leros-sim must be built. The simulator is capable of running either leros executable files (Linked files containing an entry point (_start)), or flat binary files.
Execute build.sh in the leros-sim repository to build the simulator.
Next, the Leros compiler must be available - check out https://github.com/leros-dev/leros-llvm and build it using the build.sh script in the root folder of the repository.

To run all of the tests specified in the simdrivertests.txt file, execute the simdriver.py. The script expects three arguments:

  • --llp: LLVM Path, path to the bin/ folder of the Leros compiler tools, ie. --llp ~/leros-clang/bin
  • --sim: Path to executable of the Leros simulator (leros-sim), ie. --sim ~/leros-sim/leros-sim
  • --test: Path to the test suite specification file, ie. --test ~/leros-sim/simdrivertests.txt

Given these input arguments, the script will begin execution of all tests located in the test suite specification file:
python simdriver.py --llp="..." --sim="..." --test="..."

Under the assumption that you have installed the leros tools in ~/leros-dev and used the default configuration for building the tools, the command line is:

python simdriver.py --llp="~/leros-dev/build-leros-llvm/bin/" --sim="~/leros-dev/leros-sim/build-leros-sim/leros-sim" --test="~/leros-dev/leros-sim/simdrivertests.txt"

Adding tests

An example of a simple test could be:

#include "testmacro.h"

int main(int argc, char** argv){
    int a0 = ARG(0);
    int a1 = ARG(1);
    
    int res = a0 + a1;

    TEST_RETURN(res);
}

In defining a test, we utilize the following macros:

  • ARG(N): Fetches the input argument specified by N. On host, this is fetched from argv using atoi. On Leros tests, we parse an argument string to the simulator, which the simulator translates to integers and inserts into its memory. argv is then reinterpreted as (int*)argv and we load the arguments through this pointer.
  • TEST_RETURN(res): on Leros, emits return res. On host, a printf("%d",res) is emitted before the return (used by the simdriver.py script for fetching the return value), and returns 0. For more information on the macros, refer to testmacro.h.

Todo

  • Do multithreaded testing

About

Simulator & regression test framework for the Leros ISA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published