diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-10-14 15:11:15 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-14 09:11:15 +0200 |
| commit | 3d0423acf703be7e0e7b004ee85630f6684bf72e (patch) | |
| tree | ffd0958823f0cd8a4a2ac2cccfea53ed6ff2350d /src/core.c | |
| parent | 3ad0ddfe880ee2edbc6cd05ce9cb8acb82b34331 (diff) | |
| download | box64-3d0423acf703be7e0e7b004ee85630f6684bf72e.tar.gz box64-3d0423acf703be7e0e7b004ee85630f6684bf72e.zip | |
Added preliminary unit test runner (#3045)
* Added preliminary unit test runner * Set .text section address * Added support for added custom memory regions * Move json.h to include * Display banner * Added support for custom memory data * Added the ability to include path in nasm * Print env variables
Diffstat (limited to 'src/core.c')
| -rw-r--r-- | src/core.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core.c b/src/core.c index b7636207..20a6df56 100644 --- a/src/core.c +++ b/src/core.c @@ -74,6 +74,7 @@ uintptr_t fmod_smc_end = 0; uint32_t default_gs = 0x53; uint32_t default_fs = 0; int box64_isglibc234 = 0; +int box64_unittest_mode = 0; #ifdef DYNAREC cpu_ext_t cpuext = {0}; @@ -328,6 +329,7 @@ void PrintHelp() { PrintfFtrace(0, " '-v'|'--version' to print box64 version and quit\n"); PrintfFtrace(0, " '-h'|'--help' to print this and quit\n"); PrintfFtrace(0, " '-k'|'--kill-all' to kill all box64 instances\n"); + PrintfFtrace(0, " '-t'|'--test' to run a unit test\n"); PrintfFtrace(0, " '--dynacache-list' to list of DynaCache file and their validity\n"); PrintfFtrace(0, " '--dynacache-clean' to remove invalide DynaCache files\n"); } @@ -428,7 +430,7 @@ static void addLibPaths(box64context_t* context) AppendList(&context->box64_path, getenv("PATH"), 1); // in case some of the path are for x86 world } -void setupZydis(box64context_t* context) +static void setupZydis(box64context_t* context) { #ifdef HAVE_TRACE if ((BOX64ENV(trace_init) && strcmp(BOX64ENV(trace_init), "0")) || (BOX64ENV(trace) && strcmp(BOX64ENV(trace), "0"))) { @@ -728,12 +730,16 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf if(argc>1 && !strcmp(argv[1], "/usr/bin/gdb") && BOX64ENV(trace_file)) exit(0); // uname -m is redirected to box64 -m - if(argc==2 && (!strcmp(argv[1], "-m") || !strcmp(argv[1], "-p") || !strcmp(argv[1], "-i"))) - { + if (argc == 2 && (!strcmp(argv[1], "-m") || !strcmp(argv[1], "-p") || !strcmp(argv[1], "-i"))) { printf("x86_64\n"); exit(0); } + if (argc >= 3 && (!strcmp(argv[1], "--test") || !strcmp(argv[1], "-t"))) { + box64_unittest_mode = 1; + exit(unittest(argc, argv)); + } + ftrace = stdout; // grab pagesize |