Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Save .wasm/.aot file to report dir if test failed #1937

Merged
merged 2 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions tests/wamr-test-suites/spec-test-script/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def test_case(
verbose_flag=True,
qemu_flag=False,
qemu_firmware='',
log='',
):
case_path = pathlib.Path(case_path).resolve()
case_name = case_path.stem
Expand Down Expand Up @@ -170,6 +171,10 @@ def test_case(
if not clean_up_flag:
CMD.append("--no_cleanup")

if log != '':
CMD.append("--log-dir")
CMD.append(log)

CMD.append(case_path)
print(f"============> run {case_name} ", end="")
with subprocess.Popen(
Expand Down Expand Up @@ -228,7 +233,8 @@ def test_suite(
verbose_flag=True,
parl_flag=False,
qemu_flag=False,
qemu_firmware=''
qemu_firmware='',
log='',
):
suite_path = pathlib.Path(SPEC_TEST_DIR).resolve()
if not suite_path.exists():
Expand Down Expand Up @@ -264,6 +270,7 @@ def test_suite(
verbose_flag,
qemu_flag,
qemu_firmware,
log,
],
)

Expand Down Expand Up @@ -299,6 +306,7 @@ def test_suite(
verbose_flag,
qemu_flag,
qemu_firmware,
log,
)
successful_case += 1
except Exception as e:
Expand Down Expand Up @@ -393,6 +401,12 @@ def main():
dest="qemu_firmware",
help="Firmware required by qemu",
)
parser.add_argument(
"--log",
default='',
dest="log",
help="Log directory",
)
parser.add_argument(
"--quiet",
action="store_false",
Expand Down Expand Up @@ -435,6 +449,7 @@ def main():
options.parl_flag,
options.qemu_flag,
options.qemu_firmware,
options.log,
)
end = time.time_ns()
print(
Expand All @@ -455,7 +470,8 @@ def main():
options.clean_up_flag,
options.verbose_flag,
options.qemu_flag,
options.qemu_firmware
options.qemu_firmware,
options.log
)
else:
ret = True
Expand Down
9 changes: 8 additions & 1 deletion tests/wamr-test-suites/spec-test-script/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def assert_prompt(runner, prompts, timeout, is_need_execute_result):
help="Use direct pipes instead of pseudo-tty")
parser.add_argument('--log-file', type=str,
help="Write messages to the named file in addition the screen")
parser.add_argument('--log-dir', type=str,
help="The log directory to save the case file if test failed")
parser.add_argument('--debug-file', type=str,
help="Write all test interaction the named file")

Expand Down Expand Up @@ -1092,6 +1094,7 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile,

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

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

shutil.copyfile(wasm_tempfile, os.path.join(opts.log_dir, os.path.basename(wasm_tempfile)))

if opts.aot or opts.xip:
shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)))
if "indirect-mode" in str(e):
compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "object")
shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+'.o'))
subprocess.check_call(["llvm-objdump", "-r", aot_tempfile])
compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "ir")
subprocess.check_call(["cat", aot_tempfile])
shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+".ir"))

else:
ret_code = 0
Expand Down
5 changes: 4 additions & 1 deletion tests/wamr-test-suites/test_wamr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,12 @@ function spec_test()

if [[ ${ENABLE_QEMU} == 1 ]]; then
ARGS_FOR_SPEC_TEST+="--qemu "
ARGS_FOR_SPEC_TEST+="--qemu-firmware ${QEMU_FIRMWARE}"
ARGS_FOR_SPEC_TEST+="--qemu-firmware ${QEMU_FIRMWARE} "
fi

# set log directory
ARGS_FOR_SPEC_TEST+="--log ${REPORT_DIR}"

cd ${WORK_DIR}
echo "python3 ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt"
python3 ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt
Expand Down