Skip to content

Commit 97abec1

Browse files
committed
begin setting up tester for automated tests
1 parent b223a61 commit 97abec1

File tree

5 files changed

+165
-1
lines changed

5 files changed

+165
-1
lines changed

build.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ if "%rdi_from_pdb%"=="1" set didbuild=1 && %compile% ..\src\rdi_fr
104104
if "%rdi_from_dwarf%"=="1" set didbuild=1 && %compile% ..\src\rdi_from_dwarf\rdi_from_dwarf.c %compile_link% %out%rdi_from_dwarf.exe || exit /b 1
105105
if "%rdi_dump%"=="1" set didbuild=1 && %compile% ..\src\rdi_dump\rdi_dump_main.c %compile_link% %out%rdi_dump.exe || exit /b 1
106106
if "%rdi_breakpad_from_pdb%"=="1" set didbuild=1 && %compile% ..\src\rdi_breakpad_from_pdb\rdi_breakpad_from_pdb_main.c %compile_link% %out%rdi_breakpad_from_pdb.exe || exit /b 1
107+
if "%tester%"=="1" set didbuild=1 && %compile% ..\src\tester\tester_main.c %compile_link% %out%tester.exe || exit /b 1
107108
if "%ryan_scratch%"=="1" set didbuild=1 && %compile% ..\src\scratch\ryan_scratch.c %compile_link% %out%ryan_scratch.exe || exit /b 1
108109
if "%mule_main%"=="1" set didbuild=1 && del vc*.pdb mule*.pdb && %compile_release% %only_compile% ..\src\mule\mule_inline.cpp && %compile_release% %only_compile% ..\src\mule\mule_o2.cpp && %compile_debug% %EHsc% ..\src\mule\mule_main.cpp ..\src\mule\mule_c.c mule_inline.obj mule_o2.obj %compile_link% %no_aslr% %out%mule_main.exe || exit /b 1
109110
if "%mule_module%"=="1" set didbuild=1 && %compile% ..\src\mule\mule_module.cpp %compile_link% %link_dll% %out%mule_module.dll || exit /b 1

project.4coder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ load_paths =
4646
commands =
4747
{
4848
//- rjf: fkey command slots (change locally but do not commit)
49-
.f1 = { .win = "build raddbg telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
49+
.f1 = { .win = "build rdi_from_pdb rdi_dump tester telemetry && pushd build && tester && popd", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
5050
.f2 = { .win = "build rdi_from_pdb", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
5151
.f3 = { .win = "pushd build && raddbg.exe --user:local_dev.raddbg_user --project:local_dev.raddbg_project --xuto_run && popd",.linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
5252

src/os/core/os_core.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,47 @@ os_string_from_file_range(Arena *arena, OS_Handle file, Rng1U64 range)
151151
return result;
152152
}
153153

154+
////////////////////////////////
155+
//~ rjf: Process Launcher Helpers
156+
157+
internal OS_Handle
158+
os_cmd_line_launch(String8 string)
159+
{
160+
Temp scratch = scratch_begin(0, 0);
161+
U8 split_chars[] = {' '};
162+
String8List parts = str8_split(scratch.arena, string, split_chars, ArrayCount(split_chars), 0);
163+
OS_Handle handle = {0};
164+
if(parts.node_count != 0)
165+
{
166+
String8 exe = parts.first->string;
167+
String8 exe_folder = str8_chop_last_slash(exe);
168+
if(exe_folder.size == 0)
169+
{
170+
exe_folder = os_get_current_path(scratch.arena);
171+
}
172+
OS_ProcessLaunchParams params = {0};
173+
params.cmd_line = parts;
174+
params.path = exe_folder;
175+
params.inherit_env = 1;
176+
handle = os_process_launch(&params);
177+
}
178+
scratch_end(scratch);
179+
return handle;
180+
}
181+
182+
internal OS_Handle
183+
os_cmd_line_launchf(char *fmt, ...)
184+
{
185+
Temp scratch = scratch_begin(0, 0);
186+
va_list args;
187+
va_start(args, fmt);
188+
String8 string = push_str8fv(scratch.arena, fmt, args);
189+
OS_Handle result = os_cmd_line_launch(string);
190+
va_end(args);
191+
scratch_end(scratch);
192+
return result;
193+
}
194+
154195
////////////////////////////////
155196
//~ rjf: GUID Helpers (Helpers, Implemented Once)
156197

src/os/core/os_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ internal OS_FileID os_id_from_file_path(String8 path);
165165
internal S64 os_file_id_compare(OS_FileID a, OS_FileID b);
166166
internal String8 os_string_from_file_range(Arena *arena, OS_Handle file, Rng1U64 range);
167167

168+
////////////////////////////////
169+
//~ rjf: Process Launcher Helpers
170+
171+
internal OS_Handle os_cmd_line_launch(String8 string);
172+
internal OS_Handle os_cmd_line_launchf(char *fmt, ...);
173+
168174
////////////////////////////////
169175
//~ rjf: GUID Helpers (Helpers, Implemented Once)
170176

src/tester/tester_main.c

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Copyright (c) 2024 Epic Games Tools
2+
// Licensed under the MIT license (https://opensource.org/license/mit/)
3+
4+
////////////////////////////////
5+
//~ rjf: Build Options
6+
7+
#define BUILD_VERSION_MAJOR 0
8+
#define BUILD_VERSION_MINOR 9
9+
#define BUILD_VERSION_PATCH 12
10+
#define BUILD_RELEASE_PHASE_STRING_LITERAL "ALPHA"
11+
#define BUILD_TITLE "tester"
12+
#define BUILD_CONSOLE_INTERFACE 1
13+
#define OS_FEATURE_GRAPHICAL 1
14+
15+
////////////////////////////////
16+
//~ rjf: Includes
17+
18+
//- rjf: [h]
19+
#include "base/base_inc.h"
20+
#include "os/os_inc.h"
21+
#include "path/path.h"
22+
#include "hash_store/hash_store.h"
23+
24+
//- rjf: [c]
25+
#include "base/base_inc.c"
26+
#include "os/os_inc.c"
27+
#include "path/path.c"
28+
#include "hash_store/hash_store.c"
29+
30+
////////////////////////////////
31+
//~ rjf: Entry Points
32+
33+
internal B32 frame(void) { return 0; }
34+
35+
internal void
36+
entry_point(CmdLine *cmdline)
37+
{
38+
Arena *arena = arena_alloc();
39+
40+
//////////////////////////////
41+
//- rjf: PDB -> RDI determinism
42+
//
43+
String8 name = {0};
44+
B32 good = 1;
45+
String8List out = {0};
46+
{
47+
name = str8_lit("PDB -> RDI determinism");
48+
OS_HandleList processes = {0};
49+
String8List rdi_paths = {0};
50+
U64 num_repeats_per_pdb = 4;
51+
String8 pdb_paths[] =
52+
{
53+
str8_lit_comp("odintest/test.pdb"),
54+
};
55+
for EachElement(pdb_idx, pdb_paths)
56+
{
57+
String8 pdb_path = path_normalized_from_string(arena, pdb_paths[pdb_idx]);
58+
String8 pdb_folder = str8_chop_last_slash(pdb_path);
59+
String8 repeat_folder = push_str8f(arena, "%S/pdb2rdi_determinism", pdb_folder);
60+
os_make_directory(repeat_folder);
61+
for EachIndex(repeat_idx, num_repeats_per_pdb)
62+
{
63+
String8 rdi_path = push_str8f(arena, "%S/repeat_%I64u.rdi", repeat_folder, repeat_idx);
64+
str8_list_push(arena, &rdi_paths, rdi_path);
65+
os_handle_list_push(arena, &processes, os_cmd_line_launchf("rdi_from_pdb --pdb:%S --out:%S", pdb_path, rdi_path));
66+
}
67+
};
68+
for(OS_HandleNode *n = processes.first; n != 0; n = n->next)
69+
{
70+
os_process_join(n->v, max_U64);
71+
}
72+
U64 hashes_count = rdi_paths.node_count;
73+
U128 *hashes = push_array(arena, U128, hashes_count);
74+
String8 *paths = push_array(arena, String8, hashes_count);
75+
{
76+
U64 idx = 0;
77+
for(String8Node *n = rdi_paths.first; n != 0; n = n->next, idx += 1)
78+
{
79+
String8 path = n->string;
80+
String8 data = os_data_from_file_path(arena, path);
81+
hashes[idx] = hs_hash_from_data(data);
82+
paths[idx] = path;
83+
}
84+
}
85+
B32 matches = 1;
86+
for EachIndex(idx, hashes_count)
87+
{
88+
if(!u128_match(hashes[idx], hashes[0]))
89+
{
90+
matches = 0;
91+
break;
92+
}
93+
}
94+
if(!matches)
95+
{
96+
good = 0;
97+
for EachIndex(idx, hashes_count)
98+
{
99+
str8_list_pushf(arena, &out, " [%I64u] (%S): 0x%I64x:%I64x\n", idx, paths[idx], hashes[idx].u64[0], hashes[idx].u64[1]);
100+
}
101+
}
102+
}
103+
104+
//////////////////////////////
105+
//- rjf: dump results
106+
//
107+
fprintf(stderr, "[%s] %.*s\n", good ? "." : "X", str8_varg(name));
108+
if(!good)
109+
{
110+
for(String8Node *n = out.first; n != 0; n = n->next)
111+
{
112+
fprintf(stderr, "%.*s", str8_varg(n->string));
113+
}
114+
}
115+
116+
}

0 commit comments

Comments
 (0)