Skip to content

Commit

Permalink
add tests-exclude option
Browse files Browse the repository at this point in the history
  • Loading branch information
RadWolfie committed Feb 14, 2024
1 parent 8e05e50 commit e465b41
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/include/func_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,5 @@ void (*kernel_thunk_table[])(void) =
test_MmDbgReleaseAddress, // 0x017A (377) DEVKIT
test_MmDbgWriteCheck, // 0x017A (378) DEVKIT
};

static const int kernel_thunk_table_size = ARRAY_SIZE(kernel_thunk_table);
59 changes: 52 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static void init_default_values()
static char *submitter = NULL;

static vector tests_to_run;
static vector tests_exclude;

int load_conf_file(char *file_path)
{
Expand Down Expand Up @@ -90,6 +91,13 @@ int load_conf_file(char *file_path)
vector_append(&tests_to_run, strtol(current_test, NULL, 16));
}
}
if (strcmp("tests-exclude", current_key) == 0) {
char *current_test;
char *tests = strtok(NULL, NEWLINE_DELIMITER);
while ((current_test = strtok_r(tests, ",", &tests))) {
vector_append(&tests_exclude, strtol(current_test, NULL, 16));
}
}
if (strcmp("disable-video", current_key) == 0) {
output_video = !strtoul(strtok(NULL, NEWLINE_DELIMITER), NULL, 16);
}
Expand All @@ -105,30 +113,66 @@ int load_conf_file(char *file_path)
return 0;
}

static void run_test(int test_n) {
for (int i = 0; i < tests_exclude.size; i++) {
// If a match is found in the exclusion list, then we skip the test.
if (test_n == vector_get(&tests_exclude, i)) {
test_n = -1;
break;
}
}
// Skip the test if test_n is a negative number.
if (test_n >= 0) {
kernel_thunk_table[test_n]();
}
}

static void run_tests()
{
print("Random seed used is %u", seed);
if (tests_to_run.size == 0) {
print("No Specific tests specified. Running all tests (Single Pass).");
print("No specific tests were requested. Running all tests (Single Pass).");
if (tests_exclude.size) {
int remainder_size = 0;
for (int i = 0; i < tests_exclude.size; i++) {
if (kernel_thunk_table_size > vector_get(&tests_exclude, i)) {
remainder_size++;
}
}
print("%d test(s) will be exclude.", remainder_size);
}
print("-------------------------------------------------------------");
int table_size = ARRAY_SIZE(kernel_thunk_table);
for (int k = 0; k < table_size; k++) {
kernel_thunk_table[k]();
for (int k = 0; k < kernel_thunk_table_size; k++) {
run_test(k);
}
}
else {
print("Config File Was Loaded. Only running requested tests.");
print("A config file was loaded. Only running requested tests.");
if (tests_exclude.size) {
int remainder_size = 0;
for (int k = 0; k < tests_to_run.size; k++) {
int test_n = vector_get(&tests_to_run, k);
for (int i = 0; i < tests_exclude.size; i++) {
if (test_n == vector_get(&tests_exclude, i)) {
remainder_size++;
break;
}
}
}
print("%d test(s) will be exclude.", remainder_size);
}
print("-----------------------------------------------------");
for (int k = 0; k < tests_to_run.size; k++) {
kernel_thunk_table[vector_get(&tests_to_run, k)]();
run_test(vector_get(&tests_to_run, k));
}
}
print("------------------------ End of Tests -----------------------");
}

void main(void)
{
vector_init(&tests_to_run);
vector_init(&tests_to_run, kernel_thunk_table_size);
vector_init(&tests_exclude, 20);
if (!open_output_file("D:\\kernel_tests.log")) {
return;
}
Expand Down Expand Up @@ -169,6 +213,7 @@ void main(void)
run_tests();

vector_free(&tests_to_run);
vector_free(&tests_exclude);
close_output_file();

if (output_video) {
Expand Down
4 changes: 2 additions & 2 deletions src/util/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// This vector implementation is greatly inspired from a tutorial by hbs
// Ref: https://www.happybearsoftware.com/implementing-a-dynamic-array

void vector_init(vector *vec)
void vector_init(vector *vec, int capacity)
{
vec->size = 0;
vec->capacity = 379;
vec->capacity = capacity;
vec->data = malloc(sizeof(int) * vec->capacity);
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef struct {
int *data;
} vector;

void vector_init(vector *vec);
void vector_init(vector *vec, int capacity);
void vector_append(vector *vec, int value);
int vector_get(vector *vec, int index);
void vector_set(vector *vec, int index, int value);
Expand Down

0 comments on commit e465b41

Please sign in to comment.