re-enable p2r determinism tests

This commit is contained in:
Ryan Fleury
2026-06-02 12:11:06 -07:00
parent d909f187d5
commit 4dd22c9e51
3 changed files with 51 additions and 43 deletions
+1 -1
View File
@@ -41,6 +41,6 @@ target:
{ {
executable: "build/torture.exe" executable: "build/torture.exe"
working_directory: build working_directory: build
arguments: "raddbg/* --gui" arguments: "rdi_from_pdb/* --gui"
enabled: 1 enabled: 1
} }
+50 -30
View File
@@ -1,18 +1,39 @@
// Copyright (c) Epic Games Tools // Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
SkippedTest(p2r_determ) internal String8
p2r_test__test_path(Arena *arena, TestCtx *ctx, String8 id, String8 name)
{ {
U64 num_repeats_per_pdb = 32; String8 path = str8f(arena, "%S/%S/%S", ctx->input_data_path, id, name);
return path;
}
Test(p2r_determinism)
{
U64 num_repeats_per_pdb = 16;
String8 pdb_paths[] = String8 pdb_paths[] =
{ {
push_str8f(arena, "%S/mule_main.pdb", g_test_data), p2r_test__test_path(arena, ctx, s("mule_main_9ff1e58f"), s("mule_main.pdb")),
push_str8f(arena, "%S/mule_module.pdb", g_test_data), p2r_test__test_path(arena, ctx, s("mule_main_9ff1e58f"), s("mule_module.pdb")),
}; };
B32 all_pdbs_exist_locally = 1;
for EachElement(pdb_idx, pdb_paths) for EachElement(pdb_idx, pdb_paths)
{
String8 pdb_path = pdb_paths[pdb_idx];
if(properties_from_file_path(pdb_path).modified == 0)
{
all_pdbs_exist_locally = 0;
break;
}
}
if(!all_pdbs_exist_locally)
{
TestSkip();
}
else for EachElement(pdb_idx, pdb_paths)
{ {
// rjf: unpack paths, make output directory // rjf: unpack paths, make output directory
String8 pdb_path = path_normalized_from_string(arena, pdb_paths[pdb_idx]); String8 pdb_path = pdb_paths[pdb_idx];
// rjf: generate all RDIs // rjf: generate all RDIs
String8List rdi_paths = {0}; String8List rdi_paths = {0};
@@ -21,12 +42,12 @@ SkippedTest(p2r_determ)
ProcessList processes = {0}; ProcessList processes = {0};
for EachIndex(repeat_idx, num_repeats_per_pdb) for EachIndex(repeat_idx, num_repeats_per_pdb)
{ {
String8 rdi_name = push_str8f(arena, "repeat_%I64u.rdi", repeat_idx); String8 rdi_name = str8f(arena, "repeat_%I64u.rdi", repeat_idx);
String8 rdi_path = t_make_file_path(arena, rdi_name); String8 rdi_path = str8f(arena, "%S/%S", ctx->artifacts_path, rdi_name);
str8_list_push(arena, &rdi_paths, rdi_path); str8_list_push(arena, &rdi_paths, rdi_path);
String8 cmdl = str8f(arena, "radbin -rdi -deterministic %S -out:%S", pdb_path, rdi_path); String8 cmdl = str8f(arena, "radbin --rdi --deterministic %S --out:%S", pdb_path, rdi_path);
Process process = launch_cmd_line(cmdl); Process process = launch_cmd_line(cmdl);
T_Ok(!process_match(process_zero(), process)); TestCheck(!process_match(process_zero(), process));
process_list_push(arena, &processes, process); process_list_push(arena, &processes, process);
} }
for EachNode(n, ProcessNode, processes.first) for EachNode(n, ProcessNode, processes.first)
@@ -43,8 +64,8 @@ SkippedTest(p2r_determ)
String8 rdi_path = n->string; String8 rdi_path = n->string;
String8 dump_path = str8f(arena, "%S.dump", rdi_path); String8 dump_path = str8f(arena, "%S.dump", rdi_path);
str8_list_push(arena, &dump_paths, dump_path); str8_list_push(arena, &dump_paths, dump_path);
Process process_handle = launch_cmd_linef("radbin -dump -deterministic %S -out:%S", rdi_path, dump_path); Process process_handle = launch_cmd_linef("radbin --dump --deterministic %S --out:%S", rdi_path, dump_path);
T_Ok(!process_match(process_zero(), process_handle)); TestCheck(!process_match(process_zero(), process_handle));
process_list_push(arena, &processes, process_handle); process_list_push(arena, &processes, process_handle);
} }
for EachNode(n, ProcessNode, processes.first) for EachNode(n, ProcessNode, processes.first)
@@ -54,12 +75,12 @@ SkippedTest(p2r_determ)
} }
// rjf: gather all hashes/paths // rjf: gather all hashes/paths
U64 rdi_hashes_count = rdi_paths.node_count; U64 rdi_hashes_count = rdi_paths.node_count;
U128 *rdi_hashes = push_array(arena, U128, rdi_hashes_count); U128 *rdi_hashes = push_array(arena, U128, rdi_hashes_count);
String8 *rdi_paths_array = push_array(arena, String8, rdi_hashes_count); String8 *rdi_paths_array = push_array(arena, String8, rdi_hashes_count);
U64 dump_hashes_count = dump_paths.node_count; U64 dump_hashes_count = dump_paths.node_count;
U128 *dump_hashes = push_array(arena, U128, dump_hashes_count); U128 *dump_hashes = push_array(arena, U128, dump_hashes_count);
String8 *dump_paths_array = push_array(arena, String8, dump_hashes_count); String8 *dump_paths_array = push_array(arena, String8, dump_hashes_count);
{ {
U64 idx = 0; U64 idx = 0;
for EachNode(n, String8Node, rdi_paths.first) for EachNode(n, String8Node, rdi_paths.first)
@@ -67,9 +88,8 @@ SkippedTest(p2r_determ)
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
String8 rdi_path = n->string; String8 rdi_path = n->string;
String8 path = rdi_path; String8 path = rdi_path;
T_Ok(path.size);
String8 data = data_from_file_path(scratch.arena, path); String8 data = data_from_file_path(scratch.arena, path);
T_Ok(data.size); TestCheck(data.size != 0);
rdi_hashes[idx] = u128_hash_from_str8(data); rdi_hashes[idx] = u128_hash_from_str8(data);
rdi_paths_array[idx] = path; rdi_paths_array[idx] = path;
scratch_end(scratch); scratch_end(scratch);
@@ -82,9 +102,8 @@ SkippedTest(p2r_determ)
{ {
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
String8 path = n->string; String8 path = n->string;
T_Ok(path.size);
String8 data = data_from_file_path(scratch.arena, path); String8 data = data_from_file_path(scratch.arena, path);
T_Ok(data.size); TestCheck(data.size != 0);
dump_hashes[idx] = u128_hash_from_str8(data); dump_hashes[idx] = u128_hash_from_str8(data);
dump_paths_array[idx] = path; dump_paths_array[idx] = path;
scratch_end(scratch); scratch_end(scratch);
@@ -93,12 +112,12 @@ SkippedTest(p2r_determ)
} }
// rjf: determine if all hashes match // rjf: determine if all hashes match
U64 mismatch_idx = max_U64; U64 mismatch_num = 0;
for EachIndex(idx, rdi_hashes_count) for EachIndex(idx, rdi_hashes_count)
{ {
if(!u128_match(rdi_hashes[idx], rdi_hashes[0])) if(!u128_match(rdi_hashes[idx], rdi_hashes[0]))
{ {
mismatch_idx = idx; mismatch_num = idx+1;
break; break;
} }
} }
@@ -106,18 +125,19 @@ SkippedTest(p2r_determ)
{ {
if(!u128_match(dump_hashes[idx], dump_hashes[0])) if(!u128_match(dump_hashes[idx], dump_hashes[0]))
{ {
mismatch_idx = idx; mismatch_num = idx+1;
break; break;
} }
} }
// rjf: output bad case info // rjf: output bad case info
if (mismatch_idx != max_U64) { if(mismatch_num != 0)
U64 idx = mismatch_idx; {
t_outf(" pdb[%I64u] \"%S\"\n", idx, pdb_path); U64 idx = mismatch_num-1;
t_outf(" rdi[%I64u] 0x%I64x:%I64x \"%S\"\n", idx, rdi_hashes[idx].u64[0], rdi_hashes[idx].u64[1], rdi_paths_array[idx]); test_outf(" pdb[%I64u] \"%S\"\n", idx, pdb_path);
t_outf(" dump[%I64u] 0x%I64x:%I64x \"%S\"\n", idx, dump_hashes[idx].u64[0], dump_hashes[idx].u64[1], dump_paths_array[idx]); test_outf(" rdi[%I64u] 0x%I64x:%I64x \"%S\"\n", idx, rdi_hashes[idx].u64[0], rdi_hashes[idx].u64[1], rdi_paths_array[idx]);
T_Ok(0); test_outf(" dump[%I64u] 0x%I64x:%I64x \"%S\"\n", idx, dump_hashes[idx].u64[0], dump_hashes[idx].u64[1], dump_paths_array[idx]);
} }
TestCheck(mismatch_num == 0);
} }
} }
-12
View File
@@ -11,7 +11,6 @@ global B32 g_verbose;
global B32 g_redirect_stdout = 1; global B32 g_redirect_stdout = 1;
global B32 g_stop_on_first_fail_or_crash = 1; global B32 g_stop_on_first_fail_or_crash = 1;
global B32 g_build_only = 0; global B32 g_build_only = 0;
global String8 g_test_data;
// tests // tests
global TestInfo *g_sorted_test_infos[ArrayCount(test_infos)] = {0}; global TestInfo *g_sorted_test_infos[ArrayCount(test_infos)] = {0};
@@ -1108,17 +1107,6 @@ t_entry_point(CmdLine *cmdline)
g_gcc_path = cmd_line_string(cmdline, str8_lit("gcc")); g_gcc_path = cmd_line_string(cmdline, str8_lit("gcc"));
g_linker_path = cmd_line_string(cmdline, str8_lit("linker")); g_linker_path = cmd_line_string(cmdline, str8_lit("linker"));
//
// Handle -test_data
//
{
g_test_data = cmd_line_string(cmdline, str8_lit("test_data"));
if (g_test_data.size == 0) {
g_test_data = str8f(scratch.arena, "%S/build", t_cwd_path());
//fprintf(stderr, "WARNING: The test data folder path was not specified. Specify the path when running the program, assuming: %.*s --test_data:%.*s\n", str8_varg(cmdline->exe_name), str8_varg(g_test_data));
}
}
// //
// Handle optional -target // Handle optional -target
// //