Skip to content

Commit

Permalink
add api name support for tests/tests-exclude options
Browse files Browse the repository at this point in the history
  • Loading branch information
RadWolfie committed May 7, 2024
1 parent 91f23de commit fb011d2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Here is a setup guide: https://github.com/XboxDev/nxdk/wiki/Getting-Started
The following list of options can be used inside the config.txt file:
- `seed` = `<hexadecimal (support up to FFFFFFFF)>`
- `tests` = `<hexadecimal (support up to 17A)>[,...]`
- `tests-exclude` = `<hexadecimal (support up to 17A)>[,...]`
- `tests` = `<hexadecimal (support up to 17A) or case insensitive API name>[,...]`
- `tests-exclude` = `<hexadecimal (support up to 17A) or case insensitive API name>[,...]`
- `disable-video` = `<boolean>`[^1]

[^1]: boolean value can be 1 or 0
Expand All @@ -28,7 +28,7 @@ The following list of options can be used inside the config.txt file:
> ```
> seed=5
>
> tests=1,25,3,F
> tests=1,25,3,F,NtReadFile
> ```
## NAME FILE:
Expand Down
24 changes: 22 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ void load_name_file(const char* file_path)
static std::bitset<kernel_api_tests_size> tests_to_run;
static std::bitset<kernel_api_tests_size> tests_to_exclude;

constexpr size_t XBOXKRNL_API_NAME_STR_MIN_LENGTH = 6; // XcHMAC and RtlRip APIs are the shortest kernel names.
unsigned long convert_test_api_input(char* test_str) {
// Trim space(s) before attempting to compare strings.
while(test_str[0] == ' ') {
test_str++;
}
if (strlen(test_str) >= XBOXKRNL_API_NAME_STR_MIN_LENGTH) {
for (unsigned long i = 0; i < kernel_api_tests_size; i++) {
// If the API name is a match, then return the index value.
if (_stricmp(test_str, kernel_api_tests[i].name) == 0) {
return i;
}
}
// If no match is found, then return a max value to skip add to the list.
return ULONG_MAX;
}
// Otherwise, we assumed the input is a hexadecimal string.
return strtoul(test_str, NULL, 16);
}

int load_conf_file(const char *file_path)
{
print("Trying to open config file: %s", file_path);
Expand Down Expand Up @@ -142,7 +162,7 @@ int load_conf_file(const char *file_path)
char *current_test;
char *tests = strtok(NULL, NEWLINE_DELIMITER);
while ((current_test = strtok_r(tests, ",", &tests))) {
unsigned long value = strtoul(current_test, NULL, 16);
unsigned long value = convert_test_api_input(current_test);
if (value < kernel_api_tests_size) {
tests_to_run.set(value);
}
Expand All @@ -152,7 +172,7 @@ int load_conf_file(const char *file_path)
char *current_test;
char *tests = strtok(NULL, NEWLINE_DELIMITER);
while ((current_test = strtok_r(tests, ",", &tests))) {
unsigned long value = strtoul(current_test, NULL, 16);
unsigned long value = convert_test_api_input(current_test);
if (value < kernel_api_tests_size) {
tests_to_exclude.set(value);
}
Expand Down

0 comments on commit fb011d2

Please sign in to comment.