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

Print asm test exit status for failing asm tests #4640

Merged
merged 2 commits into from
Sep 18, 2024
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
10 changes: 7 additions & 3 deletions binrz/rz-test/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ RZ_API RzAsmTestOutput *rz_test_run_asm_test(RzTestRunConfig *config, RzAsmTest
if (!out) {
return NULL;
}
out->as_ret = out->disas_ret = out->il_ret = INT_MAX;

RzPVector args;
rz_pvector_init(&args, NULL);
Expand Down Expand Up @@ -318,7 +319,8 @@ RZ_API RzAsmTestOutput *rz_test_run_asm_test(RzTestRunConfig *config, RzAsmTest
out->as_timeout = true;
goto rip;
}
if (rz_subprocess_ret(proc) != 0) {
out->as_ret = rz_subprocess_ret(proc);
if (out->as_ret != 0) {
goto rip;
}
char *hex = (char *)crlf2lf(rz_subprocess_out(proc, NULL));
Expand Down Expand Up @@ -352,7 +354,8 @@ RZ_API RzAsmTestOutput *rz_test_run_asm_test(RzTestRunConfig *config, RzAsmTest
out->disas_timeout = true;
goto ship;
}
if (rz_subprocess_ret(proc) != 0) {
out->disas_ret = rz_subprocess_ret(proc);
if (out->disas_ret != 0) {
goto ship;
}
char *disasm = (char *)crlf2lf(rz_subprocess_out(proc, NULL));
Expand Down Expand Up @@ -382,7 +385,8 @@ RZ_API RzAsmTestOutput *rz_test_run_asm_test(RzTestRunConfig *config, RzAsmTest
rz_str_trim(il_err);
out->il = il;
out->il_report = il_err;
out->il_failed = rz_subprocess_ret(proc) != 0;
out->il_ret = rz_subprocess_ret(proc);
out->il_failed = out->il_ret != 0;
}
free(hex);
rz_pvector_pop(&args);
Expand Down
21 changes: 21 additions & 0 deletions binrz/rz-test/rz-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,18 @@ static RzSubprocessOutput *print_runner(const char *file, const char *args[], si
return NULL;
}

static void print_asm_exit_status(const char *mode, bool timeout, int ret) {
printf("-- %s exit status: ", mode);
if (timeout) {
printf(Color_CYAN "TIMEOUT" Color_RESET);
} else if (ret != 0) {
printf(Color_RED "%d" Color_RESET, ret);
} else {
printf("0");
}
printf("\n");
}

static void print_result_diff(RzTestRunConfig *config, RzTestResultInfo *result) {
if (result->run_failed) {
printf(Color_RED "RUN FAILED (e.g. wrong rizin path)" Color_RESET "\n");
Expand Down Expand Up @@ -856,6 +868,15 @@ static void print_result_diff(RzTestRunConfig *config, RzTestResultInfo *result)
printf(Color_RED "%s" Color_RESET "\n", report);
}
}
if (test->mode & RZ_ASM_TEST_MODE_DISASSEMBLE) {
print_asm_exit_status("disasm", out->disas_timeout, out->disas_ret);
}
if (test->mode & RZ_ASM_TEST_MODE_ASSEMBLE) {
print_asm_exit_status("asm", out->as_timeout, out->as_ret);
}
if (test->il) {
print_asm_exit_status("IL", out->il_timeout, out->il_ret);
}
free(expect_hex);
break;
}
Expand Down
3 changes: 3 additions & 0 deletions binrz/rz-test/rz_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ typedef struct rz_test_asm_test_output_t {
bool as_timeout;
bool disas_timeout;
bool il_timeout;
int as_ret;
int disas_ret;
int il_ret;
} RzAsmTestOutput;

typedef enum rz_test_test_result_t {
Expand Down
Loading