Skip to content

Commit a025221

Browse files
authored
Merge pull request #1262 from Shaikh-Ubaid/ci_x86
CI: Support integration_tests for X86 and WASM_X86 backends
2 parents ecd57c3 + 0415481 commit a025221

File tree

6 files changed

+72
-6
lines changed

6 files changed

+72
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ integration_tests/b1/*
6868
integration_tests/b2/*
6969
integration_tests/b3/*
7070
integration_tests/b4/*
71+
integration_tests/b5/*
72+
integration_tests/b6/*
7173
integration_tests/_lpython-tmp-test-*
7274
inst/bin/*
7375
*.tlog

ci/test.xsh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ if $WIN != "1":
1919
python run_tests.py
2020
cd integration_tests
2121
python run_tests_new.py -j16 -b llvm cpython c wasm
22+
23+
if $(uname).strip() == "Linux":
24+
python run_tests_new.py -j16 -b x86 wasm_x86

integration_tests/CMakeLists.txt

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ macro(RUN)
7070
set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}")
7171
endif()
7272
if (${RUN_FAIL})
73-
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
73+
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
7474
endif()
7575
elseif(KIND STREQUAL "c")
7676
add_custom_command(
@@ -86,7 +86,7 @@ macro(RUN)
8686
set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}")
8787
endif()
8888
if (${RUN_FAIL})
89-
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
89+
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
9090
endif()
9191
elseif(KIND STREQUAL "cpython")
9292
# CPython test
@@ -105,7 +105,41 @@ macro(RUN)
105105
set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}")
106106
endif()
107107
if (${RUN_FAIL})
108-
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
108+
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
109+
endif()
110+
elseif(KIND STREQUAL "x86")
111+
# x86 test
112+
add_custom_command(
113+
OUTPUT ${name}.x86
114+
COMMAND lpython --backend x86 ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}.x86
115+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py
116+
VERBATIM
117+
)
118+
add_custom_target(${name} ALL
119+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86)
120+
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86)
121+
if (RUN_LABELS)
122+
set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}")
123+
endif()
124+
if (${RUN_FAIL})
125+
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
126+
endif()
127+
elseif(KIND STREQUAL "wasm_x86")
128+
# wasm_to_x86 test
129+
add_custom_command(
130+
OUTPUT ${name}.x86
131+
COMMAND lpython --backend wasm_x86 ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}.x86
132+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py
133+
VERBATIM
134+
)
135+
add_custom_target(${name} ALL
136+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86)
137+
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86)
138+
if (RUN_LABELS)
139+
set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}")
140+
endif()
141+
if (${RUN_FAIL})
142+
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
109143
endif()
110144
elseif(KIND STREQUAL "wasm")
111145
# wasm test
@@ -128,7 +162,7 @@ macro(RUN)
128162
set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}")
129163
endif()
130164
if (${RUN_FAIL})
131-
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
165+
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
132166
endif()
133167
endif()
134168
endif()
@@ -152,6 +186,7 @@ RUN(NAME exit_02c FAIL LABELS cpython llvm c)
152186

153187
# Test all four backends
154188
RUN(NAME print_01 LABELS cpython llvm c wasm) # wasm not yet supports sep and end keywords
189+
RUN(NAME print_03 LABELS x86 wasm_x86) # simple test case specifically for x86 and wasm_x86
155190

156191
# CPython and LLVM
157192
RUN(NAME const_01 LABELS cpython llvm c)

integration_tests/print_03.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def Main0():
2+
x: i32
3+
x = (2+3)*5
4+
print(x)
5+
print("Hi")
6+
print("Hello")
7+
print((5-2) * 7)
8+
print("Bye")
9+
10+
Main0()

integration_tests/run_tests.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ex
44

5-
rm -rf b1 b2 b3 b4
5+
rm -rf b1 b2 b3 b4 b5 b6
66

77
# Append "-j4" or "-j" to run in parallel
88
jn=$1
@@ -38,3 +38,19 @@ node -v
3838
cmake -DKIND=wasm ..
3939
make $jn
4040
ctest $jn --output-on-failure
41+
cd ..
42+
43+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
44+
mkdir b5
45+
cd b5
46+
cmake -DKIND=x86 ..
47+
make $jn
48+
ctest $jn --output-on-failure
49+
cd ..
50+
51+
mkdir b6
52+
cd b6
53+
cmake -DKIND=wasm_x86 ..
54+
make $jn
55+
ctest $jn --output-on-failure
56+
fi

integration_tests/run_tests_new.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Initialization
88
DEFAULT_THREADS_TO_USE = 8 # default no of threads is 8
9-
SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython']
9+
SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython', 'x86', 'wasm_x86']
1010
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
1111
LPYTHON_PATH = f"{BASE_DIR}/../src/bin"
1212

0 commit comments

Comments
 (0)