From 189dc63cebaf1f20a213d5a4a42789eda7572d90 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Mon, 1 May 2023 17:31:37 +0100 Subject: [PATCH] add lit filecheck --- .github/workflows/ci-pytest.yml | 3 +++ requirements-dev.txt | 2 ++ test/filecheck/.lit_test_times.txt | 1 + test/filecheck/hello-world.asm | 15 +++++++++++++++ test/filecheck/lit.cfg | 10 ++++++++++ 5 files changed, 31 insertions(+) create mode 100644 test/filecheck/.lit_test_times.txt create mode 100644 test/filecheck/hello-world.asm create mode 100644 test/filecheck/lit.cfg diff --git a/.github/workflows/ci-pytest.yml b/.github/workflows/ci-pytest.yml index a310feb..9c772a4 100644 --- a/.github/workflows/ci-pytest.yml +++ b/.github/workflows/ci-pytest.yml @@ -39,6 +39,9 @@ jobs: - name: Test with pytest run: | pytest -W error + - name: Test with lit + run: | + lit -v test/filecheck #- name: Execute lit tests # run: | diff --git a/requirements-dev.txt b/requirements-dev.txt index eddc4cb..a3041eb 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,5 @@ black==23.3.0 pre-commit==3.2.2 pytest==7.3.1 +filecheck==0.0.23 +lit==16.0.2 diff --git a/test/filecheck/.lit_test_times.txt b/test/filecheck/.lit_test_times.txt new file mode 100644 index 0000000..05e0b49 --- /dev/null +++ b/test/filecheck/.lit_test_times.txt @@ -0,0 +1 @@ +8.836818e-02 hello-world.asm diff --git a/test/filecheck/hello-world.asm b/test/filecheck/hello-world.asm new file mode 100644 index 0000000..5122bc1 --- /dev/null +++ b/test/filecheck/hello-world.asm @@ -0,0 +1,15 @@ +// RUN: python3 -m riscemu -v %s | filecheck %s + .data +msg: .ascii "Hello world\n" + .text + addi a0, zero, 1 // print to stdout + addi a1, zero, msg // load msg address + addi a2, zero, 12 // write 12 bytes + addi a7, zero, SCALL_WRITE // write syscall code + scall + addi a0, zero, 0 // set exit code to 0 + addi a7, zero, SCALL_EXIT // exit syscall code + scall + +// CHECK: Hello world +// CHECK: [CPU] Program exited with code 0 \ No newline at end of file diff --git a/test/filecheck/lit.cfg b/test/filecheck/lit.cfg new file mode 100644 index 0000000..7879d03 --- /dev/null +++ b/test/filecheck/lit.cfg @@ -0,0 +1,10 @@ +import lit.formats +import os + +config.test_source_root = os.path.dirname(__file__) +xdsl_src = os.path.dirname(os.path.dirname(config.test_source_root)) + +config.name = "riscemu" +config.test_format = lit.formats.ShTest(preamble_commands=[f"cd {xdsl_src}"]) +config.suffixes = ['.asm'] +