From 1daa396776cb35786ed695c5b3a1e2ab85d9662b Mon Sep 17 00:00:00 2001 From: Ubaid Date: Thu, 3 Nov 2022 20:12:18 +0530 Subject: [PATCH 1/7] TEST: Support integration_tests for x86 backend --- .gitignore | 1 + integration_tests/CMakeLists.txt | 17 +++++++++++++++++ integration_tests/run_tests.sh | 9 ++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9a8527d336..9d24f38f35 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,7 @@ integration_tests/b1/* integration_tests/b2/* integration_tests/b3/* integration_tests/b4/* +integration_tests/b5/* integration_tests/_lpython-tmp-test-* inst/bin/* *.tlog diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 03acc455c0..0f42f0d116 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -107,6 +107,23 @@ macro(RUN) if (${RUN_FAIL}) set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() + elseif(KIND STREQUAL "x86") + # x86 test + add_custom_command( + OUTPUT ${name}.x86 + COMMAND lpython --backend x86 ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}.x86 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py + VERBATIM + ) + add_custom_target(${name} ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86) + add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86) + if (RUN_LABELS) + set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") + endif() + if (${RUN_FAIL}) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + endif() elseif(KIND STREQUAL "wasm") # wasm test execute_process(COMMAND lpython --backend wasm ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}) diff --git a/integration_tests/run_tests.sh b/integration_tests/run_tests.sh index b7f1e9daf0..1d9ea7e9fb 100755 --- a/integration_tests/run_tests.sh +++ b/integration_tests/run_tests.sh @@ -2,7 +2,7 @@ set -ex -rm -rf b1 b2 b3 b4 +rm -rf b1 b2 b3 b4 b5 # Append "-j4" or "-j" to run in parallel jn=$1 @@ -38,3 +38,10 @@ node -v cmake -DKIND=wasm .. make $jn ctest $jn --output-on-failure +cd .. + +mkdir b5 +cd b5 +cmake -DKIND=x86 .. +make $jn +ctest $jn --output-on-failure From f26d1cbcfdc50eea07855dbffe950de8ad638f47 Mon Sep 17 00:00:00 2001 From: Ubaid Date: Thu, 3 Nov 2022 22:27:55 +0530 Subject: [PATCH 2/7] TEST: Support integration_tests for wasm_x86 backend --- .gitignore | 1 + integration_tests/CMakeLists.txt | 17 +++++++++++++++++ integration_tests/run_tests.sh | 9 ++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9d24f38f35..94846e03a5 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ integration_tests/b2/* integration_tests/b3/* integration_tests/b4/* integration_tests/b5/* +integration_tests/b6/* integration_tests/_lpython-tmp-test-* inst/bin/* *.tlog diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 0f42f0d116..06ffb5fb22 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -124,6 +124,23 @@ macro(RUN) if (${RUN_FAIL}) set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() + elseif(KIND STREQUAL "wasm_x86") + # wasm_to_x86 test + add_custom_command( + OUTPUT ${name}.x86 + COMMAND lpython --backend wasm_x86 ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}.x86 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py + VERBATIM + ) + add_custom_target(${name} ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86) + add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86) + if (RUN_LABELS) + set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") + endif() + if (${RUN_FAIL}) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + endif() elseif(KIND STREQUAL "wasm") # wasm test execute_process(COMMAND lpython --backend wasm ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}) diff --git a/integration_tests/run_tests.sh b/integration_tests/run_tests.sh index 1d9ea7e9fb..f49769552e 100755 --- a/integration_tests/run_tests.sh +++ b/integration_tests/run_tests.sh @@ -2,7 +2,7 @@ set -ex -rm -rf b1 b2 b3 b4 b5 +rm -rf b1 b2 b3 b4 b5 b6 # Append "-j4" or "-j" to run in parallel jn=$1 @@ -45,3 +45,10 @@ cd b5 cmake -DKIND=x86 .. make $jn ctest $jn --output-on-failure +cd .. + +mkdir b6 +cd b6 +cmake -DKIND=wasm_x86 .. +make $jn +ctest $jn --output-on-failure From a0dbd325b594e37e2c6b1543685a78ad45f17ead Mon Sep 17 00:00:00 2001 From: Ubaid Date: Thu, 3 Nov 2022 22:08:19 +0530 Subject: [PATCH 3/7] TEST: X86 and WASM_X86: Add basic print test case --- integration_tests/CMakeLists.txt | 1 + integration_tests/print_03.py | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 integration_tests/print_03.py diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 06ffb5fb22..2eaf26e20e 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -186,6 +186,7 @@ RUN(NAME exit_02c FAIL LABELS cpython llvm c) # Test all four backends RUN(NAME print_01 LABELS cpython llvm c wasm) # wasm not yet supports sep and end keywords +RUN(NAME print_03 LABELS x86 wasm_x86) # simple test case specifically for x86 and wasm_x86 # CPython and LLVM RUN(NAME const_01 LABELS cpython llvm c) diff --git a/integration_tests/print_03.py b/integration_tests/print_03.py new file mode 100644 index 0000000000..a69c02e251 --- /dev/null +++ b/integration_tests/print_03.py @@ -0,0 +1,4 @@ +def Main0(): + print(5) + +Main0() From bb3a1a3473273589375272310aca6b8c589e2b92 Mon Sep 17 00:00:00 2001 From: Ubaid Date: Thu, 3 Nov 2022 22:29:37 +0530 Subject: [PATCH 4/7] Formatting: Fix simple indentation --- integration_tests/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 2eaf26e20e..64048b6c88 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -70,7 +70,7 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() elseif(KIND STREQUAL "c") add_custom_command( @@ -86,7 +86,7 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() elseif(KIND STREQUAL "cpython") # CPython test @@ -105,7 +105,7 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() elseif(KIND STREQUAL "x86") # x86 test @@ -122,7 +122,7 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() elseif(KIND STREQUAL "wasm_x86") # wasm_to_x86 test @@ -162,7 +162,7 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() endif() endif() From ab48dc885cd6be67308639e491073942b088f0e2 Mon Sep 17 00:00:00 2001 From: Ubaid Date: Fri, 4 Nov 2022 19:28:22 +0530 Subject: [PATCH 5/7] TEST: WASM_X86: Improve integration_tests/print_03.py --- integration_tests/print_03.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/integration_tests/print_03.py b/integration_tests/print_03.py index a69c02e251..46f5120a31 100644 --- a/integration_tests/print_03.py +++ b/integration_tests/print_03.py @@ -1,4 +1,10 @@ def Main0(): - print(5) + x: i32 + x = (2+3)*5 + print(x) + print("Hi") + print("Hello") + print((5-2) * 7) + print("Bye") Main0() From 2829ef4ea85674f3a05170885c1d0d4bdf9f8e92 Mon Sep 17 00:00:00 2001 From: Ubaid Date: Fri, 4 Nov 2022 19:41:41 +0530 Subject: [PATCH 6/7] TEST: Execute integration_tests for x86 and wasm_x86 backends only on Linux --- integration_tests/run_tests.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/integration_tests/run_tests.sh b/integration_tests/run_tests.sh index f49769552e..1086f6697a 100755 --- a/integration_tests/run_tests.sh +++ b/integration_tests/run_tests.sh @@ -40,15 +40,17 @@ make $jn ctest $jn --output-on-failure cd .. -mkdir b5 -cd b5 -cmake -DKIND=x86 .. -make $jn -ctest $jn --output-on-failure -cd .. - -mkdir b6 -cd b6 -cmake -DKIND=wasm_x86 .. -make $jn -ctest $jn --output-on-failure +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + mkdir b5 + cd b5 + cmake -DKIND=x86 .. + make $jn + ctest $jn --output-on-failure + cd .. + + mkdir b6 + cd b6 + cmake -DKIND=wasm_x86 .. + make $jn + ctest $jn --output-on-failure +fi From 04154814e98c282d4b89d1fe78b1a0a87287e5e3 Mon Sep 17 00:00:00 2001 From: Ubaid Date: Thu, 10 Nov 2022 23:52:22 +0530 Subject: [PATCH 7/7] Support x86 and wasm_x86 testing in integration_tests/run_tests_new.py --- ci/test.xsh | 3 +++ integration_tests/run_tests_new.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/test.xsh b/ci/test.xsh index 50a0649d19..0c842a923a 100644 --- a/ci/test.xsh +++ b/ci/test.xsh @@ -19,3 +19,6 @@ if $WIN != "1": python run_tests.py cd integration_tests python run_tests_new.py -j16 -b llvm cpython c wasm + + if $(uname).strip() == "Linux": + python run_tests_new.py -j16 -b x86 wasm_x86 diff --git a/integration_tests/run_tests_new.py b/integration_tests/run_tests_new.py index e038e7adf3..12054150f1 100644 --- a/integration_tests/run_tests_new.py +++ b/integration_tests/run_tests_new.py @@ -6,7 +6,7 @@ # Initialization DEFAULT_THREADS_TO_USE = 8 # default no of threads is 8 -SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython'] +SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython', 'x86', 'wasm_x86'] BASE_DIR = os.path.dirname(os.path.realpath(__file__)) LPYTHON_PATH = f"{BASE_DIR}/../src/bin"