62 lines
2.3 KiB
C
62 lines
2.3 KiB
C
|
|
#include <stdio.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <string.h>
|
||
|
|
#include <signal.h>
|
||
|
|
#include <execinfo.h>
|
||
|
|
#include <unistd.h>
|
||
|
|
#include "scheduler.h"
|
||
|
|
#include "doubly_linked_list_test.h"
|
||
|
|
#include "scheduler_round_robin_test.h"
|
||
|
|
|
||
|
|
// Replicates the crash handler from tests.c:211
|
||
|
|
void segv_handler(int sig) {
|
||
|
|
void *array[10];
|
||
|
|
size_t size;
|
||
|
|
fprintf(stderr, "\n=== Caught signal %d (Segmentation fault) ===\n", sig);
|
||
|
|
size = backtrace(array, 10);
|
||
|
|
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||
|
|
fprintf(stderr, "exit()/exec() detected (test did not return to harness)\n");
|
||
|
|
exit(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Replicates the test routing from tests.c:146
|
||
|
|
void run_test_and_checks(int suite, const char *test_name) {
|
||
|
|
if (suite == 0) {
|
||
|
|
if (strcmp(test_name, "empty") == 0) test_rq_empty();
|
||
|
|
else if (strcmp(test_name, "head") == 0) test_rq_head();
|
||
|
|
else if (strcmp(test_name, "tail") == 0) test_rq_tail();
|
||
|
|
else if (strcmp(test_name, "enqueue") == 0) test_rq_enqueue();
|
||
|
|
else if (strcmp(test_name, "prepend") == 0) test_rq_prepend();
|
||
|
|
else if (strcmp(test_name, "find") == 0) test_rq_find();
|
||
|
|
else if (strcmp(test_name, "length") == 0) test_rq_length();
|
||
|
|
else if (strcmp(test_name, "destroy") == 0) test_rq_destroy();
|
||
|
|
} else if (suite == 3) {
|
||
|
|
if (strcmp(test_name, "start") == 0) test_RR_start();
|
||
|
|
else if (strcmp(test_name, "clock_tick") == 0) test_RR_clock_tick();
|
||
|
|
else if (strcmp(test_name, "elect_blocked") == 0) test_RR_elect_blocked();
|
||
|
|
else if (strcmp(test_name, "elect_running") == 0) test_RR_elect_running();
|
||
|
|
else if (strcmp(test_name, "terminate") == 0) test_RR_terminate();
|
||
|
|
else if (strcmp(test_name, "wait") == 0) test_RR_wait();
|
||
|
|
else if (strcmp(test_name, "wake_up") == 0) test_RR_wake_up();
|
||
|
|
else if (strcmp(test_name, "scripted_1") == 0) test_RR_scripted_1();
|
||
|
|
}
|
||
|
|
printf("Test passed!\n");
|
||
|
|
}
|
||
|
|
|
||
|
|
// Replicates tests.c:409
|
||
|
|
int main(int argc, char **argv) {
|
||
|
|
signal(SIGSEGV, segv_handler);
|
||
|
|
signal(SIGABRT, segv_handler);
|
||
|
|
|
||
|
|
if (argc < 3) {
|
||
|
|
fprintf(stderr, "Usage: ./vpl_execution <suite_id> <test_name>\n");
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
int suite = atoi(argv[1]);
|
||
|
|
const char *test_name = argv[2];
|
||
|
|
|
||
|
|
run_test_and_checks(suite, test_name);
|
||
|
|
return 0;
|
||
|
|
}
|