From ffe18834dd9cf13539e8ef39ae10ef62a20f64a0 Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Fri, 8 May 2026 01:45:24 -0700 Subject: [PATCH] run tests on Linux --- run_tests.sh | 12 ++++++++++++ src/torture/torture.c | 14 +++++++++----- src/torture/torture_d2r.c | 14 +++++++++++++- src/torture/torture_dbg.c | 6 +++++- 4 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 run_tests.sh diff --git a/run_tests.sh b/run_tests.sh new file mode 100644 index 00000000..6713d22f --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eu +cd "$(dirname "$0")" + +# compile our targets +./build.sh raddbg raddbg_non_graphical radlink radbin torture + +# run torture +cd build +./torture +cd .. + diff --git a/src/torture/torture.c b/src/torture/torture.c index 9bc1a1d0..6ffa0086 100644 --- a/src/torture/torture.c +++ b/src/torture/torture.c @@ -167,12 +167,10 @@ t_run_caller(void *raw_ctx) fprintf(stderr, "%.*s", str8_varg(n->string)); } if (g_errors.size) { - fprintf(stderr, "--- STDERR ---------------------------------------------------------------------\n"); - fprintf(stderr, "%.*s\n", str8_varg(g_errors)); + fprintf(stderr, "stderr: \"%.*s\"\n", str8_varg(g_errors)); } if (g_output.size) { - fprintf(stderr, "--- STDOUT ---------------------------------------------------------------------\n"); - fprintf(stderr, "%.*s\n", str8_varg(g_output)); + fprintf(stderr, "stdout: \"%.*s\"\n", str8_varg(g_output)); } } scratch_end(scratch); @@ -355,6 +353,7 @@ t_cwd_path(void) } else { cwd = str8_chop_last_slash(cwd); } + MemoryCopyStr8(path, cwd); path[cwd.size] = 0; scratch_end(scratch); @@ -1325,7 +1324,12 @@ t_entry_point(CmdLine *cmdline) (int)(label_max - strlen(g_torture_tests[s.target_idx].label)) + 4, dots, str8_varg(elapsed_time)); } - + + if (pass_count == target_indices.count) { + fprintf(stdout, "\n \x1b[32m" "%s" "\x1b[0m\n\n", "All Tests Passed!"); + fprintf(stderr, "--------------------------------------------------------------------------------\n"); + } + fprintf(stderr, "\n"); } diff --git a/src/torture/torture_d2r.c b/src/torture/torture_d2r.c index af7e5a74..1382ed41 100644 --- a/src/torture/torture_d2r.c +++ b/src/torture/torture_d2r.c @@ -279,7 +279,19 @@ TEST(d2r_line_table) for EachIndex(k, test_table[i].line_size) { t_invoke_radbin("-voff2line -voff:0x%llx a.rdi", test_table[i].voff + k); T_Ok(g_last_exit_code == 0); - T_MatchLinef(&g_output, "%S:%llu", test_table[i].file->path, test_table[i].ln); + + if ( ! t_match_linef(&g_output, "%S:%llu", test_table[i].file->path, test_table[i].ln)) { + + fprintf(stderr, + "ERROR: conversion produced unexpected lines for voff 0x%llx\n" \ + "\tExpected: %.*s:%llu\n" \ + "\tGot: %.*s\n", + (unsigned long long)test_table[i].voff, + str8_varg(test_table[i].file->path), (unsigned long long)test_table[i].ln, + str8_varg(g_output)); + + T_Ok(0); + } } } diff --git a/src/torture/torture_dbg.c b/src/torture/torture_dbg.c index d6f6aaa4..184dc363 100644 --- a/src/torture/torture_dbg.c +++ b/src/torture/torture_dbg.c @@ -742,7 +742,11 @@ internal void t_dbg_register_script_tests(Arena *arena, String8 folder_path) { Temp scratch = scratch_begin(&arena, 1); - AssertAlways(os_folder_path_exists(folder_path)); + + if ( ! os_folder_path_exists(folder_path)) { + fprintf(stderr, "ERROR: this folder does not exists: %.*s\n", str8_varg(folder_path)); + return; + } // gather file paths in a folder String8List paths = t_file_paths_from_dir(arena, folder_path);