diff --git a/.github/workflows/lit.yml b/.github/workflows/lit.yml index 254a064b8b..4858e5864b 100644 --- a/.github/workflows/lit.yml +++ b/.github/workflows/lit.yml @@ -10,8 +10,8 @@ on: workflow_dispatch: jobs: - lit-linux: - name: Lit (Linux) + lit-linux-debug: + name: lit tests (Linux, debug build) runs-on: ubuntu-latest container: ghcr.io/plc-lang/rust-llvm:latest steps: @@ -20,4 +20,16 @@ jobs: - name: Run `build.sh --lit` shell: bash run: | - ./scripts/build.sh --lit \ No newline at end of file + ./scripts/build.sh --lit + + lit-linux-release: + name: lit tests (Linux, release build) + runs-on: ubuntu-latest + container: ghcr.io/plc-lang/rust-llvm:latest + steps: + - uses: actions/checkout@v3 + + - name: Run `build.sh --lit --release` + shell: bash + run: | + ./scripts/build.sh --lit --release \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh index c3273ab75d..ab431fc90f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -142,12 +142,16 @@ function run_check_style() { } function run_lit_test() { - # We need a binary to execute the lit tests - cargo build - cargo build --release + # We need a binary as well as the stdlib and its *.so file before running lit tests + run_build + run_std_build + run_package_std - lit -v -DCOMPILER=$project_location/target/debug/plc tests/lit/ - lit -v -DCOMPILER=$project_location/target/release/plc tests/lit/ + if [[ $release -eq 0 ]]; then + lit -v -DLIB=$project_location/output -DCOMPILER=$project_location/target/debug/plc tests/lit/ + else + lit -v -DLIB=$project_location/output -DCOMPILER=$project_location/target/release/plc tests/lit/ + fi } function run_test() { @@ -201,6 +205,8 @@ function set_offline() { function run_package_std() { cc=$(get_compiler) + OUTPUT_DIR=$project_location/output + make_dir "$OUTPUT_DIR" log "Packaging Standard functions" log "Removing previous output folder" rm -rf $OUTPUT_DIR @@ -433,11 +439,6 @@ if [[ $container -ne 0 ]]; then exit 0 fi -if [[ $package -ne 0 ]]; then - OUTPUT_DIR=$project_location/output - make_dir "$OUTPUT_DIR" -fi - if [[ $vendor -ne 0 ]]; then generate_sources exit 0 diff --git a/tests/lit/lit.cfg b/tests/lit/lit.cfg index 5be5d0b6ae..eb46b868c4 100644 --- a/tests/lit/lit.cfg +++ b/tests/lit/lit.cfg @@ -4,16 +4,9 @@ config.test_format = lit.formats.ShTest(True) config.pipefail = False rustyRootDirectory = subprocess.check_output("dirname `cargo locate-project --message-format plain`", shell=True).decode("utf-8").strip() -# TODO: These need to be adjusted to the action runner / build.sh file -# compiler = lit_config.params["COMPILER"] -# lib = lit_config.params["STDLIBPATH"] -# arch = lit_config.params["ARCH"] -# config.substitutions.append(('%COMPILE', f'{compiler} -o /tmp/%basename_t.out -liec61131std -L{lib}{arch}/lib/ -i "{lib}/include/*.st" -i {srcDir}/helpers/printf.pli --linker=cc')) -# config.substitutions.append(('%RUN', f'LD_LIBRARY_PATH="{lib}{arch}/lib" /tmp/%basename_t.out')) -# config.substitutions.append(('%CHECK', f'FileCheck-14 --check-prefixes GREY,CHECK --allow-unused-prefixes --match-full-lines')) - # ~/.local/bin/lit -v -DCOMPILER=/home/vosa@bachmann.at/Development/rusty/target/debug/plc ./tests/lit -compiler = lit_config.params["COMPILER"] -config.substitutions.append(('%COMPILE', f'{compiler} -o /tmp/%basename_t.out {rustyRootDirectory}/tests/lit/util/printf.pli --linker=cc')) -config.substitutions.append(('%RUN', f'/tmp/%basename_t.out')) +stdlibLocation = lit_config.params["LIB"] +compilerLocation = lit_config.params["COMPILER"] +config.substitutions.append(('%COMPILE', f'LD_LIBRARY_PATH="{stdlibLocation}/lib" {compilerLocation} -o /tmp/%basename_t.out -liec61131std -L{stdlibLocation}/lib -i "{stdlibLocation}/include/*.st" -i {rustyRootDirectory}/tests/lit/util/printf.pli --linker=cc')) +config.substitutions.append(('%RUN', f'LD_LIBRARY_PATH="{stdlibLocation}/lib" /tmp/%basename_t.out')) config.substitutions.append(('%CHECK', f'FileCheck-14 --check-prefixes CHECK --allow-unused-prefixes --match-full-lines')) \ No newline at end of file diff --git a/tests/lit/single/arithmetic/addition.st b/tests/lit/single/arithmetic/addition.st index 6ee546ed3e..79d620ec0e 100644 --- a/tests/lit/single/arithmetic/addition.st +++ b/tests/lit/single/arithmetic/addition.st @@ -1,4 +1,5 @@ // RUN: (%COMPILE %s && %RUN) | %CHECK %s +// CHECK: 10 FUNCTION main VAR x : DINT; @@ -8,5 +9,4 @@ FUNCTION main x := 5; y := 5; printf('%d$N', x + y); - // CHECK: 10 END_FUNCTION diff --git a/tests/lit/single/arithmetic/sqrt.st b/tests/lit/single/arithmetic/sqrt.st new file mode 100644 index 0000000000..5bedfc48fd --- /dev/null +++ b/tests/lit/single/arithmetic/sqrt.st @@ -0,0 +1,8 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +// CHECK: 2 +FUNCTION main + VAR + res : LREAL; + END_VAR + printf('%d$N', REAL_TO_DINT(SQRT(4.0))); +END_FUNCTION