Skip to content

Commit 2c8375e

Browse files
authored
wamr-test-suites: Save .wasm/.aot file to the report dir if test failed (#1937)
1 parent 42ced88 commit 2c8375e

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

tests/wamr-test-suites/spec-test-script/all.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def test_case(
111111
verbose_flag=True,
112112
qemu_flag=False,
113113
qemu_firmware='',
114+
log='',
114115
):
115116
case_path = pathlib.Path(case_path).resolve()
116117
case_name = case_path.stem
@@ -170,6 +171,10 @@ def test_case(
170171
if not clean_up_flag:
171172
CMD.append("--no_cleanup")
172173

174+
if log != '':
175+
CMD.append("--log-dir")
176+
CMD.append(log)
177+
173178
CMD.append(case_path)
174179
print(f"============> run {case_name} ", end="")
175180
with subprocess.Popen(
@@ -228,7 +233,8 @@ def test_suite(
228233
verbose_flag=True,
229234
parl_flag=False,
230235
qemu_flag=False,
231-
qemu_firmware=''
236+
qemu_firmware='',
237+
log='',
232238
):
233239
suite_path = pathlib.Path(SPEC_TEST_DIR).resolve()
234240
if not suite_path.exists():
@@ -264,6 +270,7 @@ def test_suite(
264270
verbose_flag,
265271
qemu_flag,
266272
qemu_firmware,
273+
log,
267274
],
268275
)
269276

@@ -299,6 +306,7 @@ def test_suite(
299306
verbose_flag,
300307
qemu_flag,
301308
qemu_firmware,
309+
log,
302310
)
303311
successful_case += 1
304312
except Exception as e:
@@ -393,6 +401,12 @@ def main():
393401
dest="qemu_firmware",
394402
help="Firmware required by qemu",
395403
)
404+
parser.add_argument(
405+
"--log",
406+
default='',
407+
dest="log",
408+
help="Log directory",
409+
)
396410
parser.add_argument(
397411
"--quiet",
398412
action="store_false",
@@ -435,6 +449,7 @@ def main():
435449
options.parl_flag,
436450
options.qemu_flag,
437451
options.qemu_firmware,
452+
options.log,
438453
)
439454
end = time.time_ns()
440455
print(
@@ -455,7 +470,8 @@ def main():
455470
options.clean_up_flag,
456471
options.verbose_flag,
457472
options.qemu_flag,
458-
options.qemu_firmware
473+
options.qemu_firmware,
474+
options.log
459475
)
460476
else:
461477
ret = True

tests/wamr-test-suites/spec-test-script/runtest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ def assert_prompt(runner, prompts, timeout, is_need_execute_result):
200200
help="Use direct pipes instead of pseudo-tty")
201201
parser.add_argument('--log-file', type=str,
202202
help="Write messages to the named file in addition the screen")
203+
parser.add_argument('--log-dir', type=str,
204+
help="The log directory to save the case file if test failed")
203205
parser.add_argument('--debug-file', type=str,
204206
help="Write all test interaction the named file")
205207

@@ -1092,6 +1094,7 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile,
10921094

10931095
if __name__ == "__main__":
10941096
opts = parser.parse_args(sys.argv[1:])
1097+
print('Input param :',opts)
10951098

10961099
if opts.aot: test_aot = True
10971100
# default x86_64
@@ -1271,12 +1274,16 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile,
12711274
print("THE FINAL EXCEPTION IS {}".format(e))
12721275
ret_code = 101
12731276

1277+
shutil.copyfile(wasm_tempfile, os.path.join(opts.log_dir, os.path.basename(wasm_tempfile)))
1278+
12741279
if opts.aot or opts.xip:
1280+
shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)))
12751281
if "indirect-mode" in str(e):
12761282
compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "object")
1283+
shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+'.o'))
12771284
subprocess.check_call(["llvm-objdump", "-r", aot_tempfile])
12781285
compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "ir")
1279-
subprocess.check_call(["cat", aot_tempfile])
1286+
shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+".ir"))
12801287

12811288
else:
12821289
ret_code = 0

tests/wamr-test-suites/test_wamr.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,12 @@ function spec_test()
442442

443443
if [[ ${ENABLE_QEMU} == 1 ]]; then
444444
ARGS_FOR_SPEC_TEST+="--qemu "
445-
ARGS_FOR_SPEC_TEST+="--qemu-firmware ${QEMU_FIRMWARE}"
445+
ARGS_FOR_SPEC_TEST+="--qemu-firmware ${QEMU_FIRMWARE} "
446446
fi
447447

448+
# set log directory
449+
ARGS_FOR_SPEC_TEST+="--log ${REPORT_DIR}"
450+
448451
cd ${WORK_DIR}
449452
echo "python3 ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt"
450453
python3 ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt

0 commit comments

Comments
 (0)