-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathunit_tests.c
62 lines (51 loc) · 1.91 KB
/
unit_tests.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <criterion/criterion.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdio.h>
#include <common.h>
// Include src
#include "process_scheduling.h"
#include "student_code.h"
#include "tests.h"
// Define any important factors for tests
#define FLOAT_EPSILON 0.1
// Include our unit tests
#include "tests/unittests_helpers.c"
#include "tests/unittests_fifo.c"
#include "tests/unittests_priority.c"
#include "tests/unittests_lifo.c"
#include "tests/unittests_sjf.c"
#include "tests/unittests_stcf.c"
#include "tests/unittests_rr.c"
#include "tests/unittests_end2end.c"
TestSuite(HelperFunctions, .disabled=false, .timeout=60.0);
TestSuite(PRIORITY, .disabled=false, .timeout=60.0);
TestSuite(STCF, .disabled=false, .timeout=60.0);
TestSuite(SJF, .disabled=false, .timeout=60.0);
TestSuite(LIFO, .disabled=false, .timeout=60.0);
TestSuite(FIFO, .disabled=false, .timeout=60.0);
TestSuite(RR, .disabled=false, .timeout=60.0);
// From: https://github.com/codewars/criterion-hooks/blob/main/criterion-hooks.c
// PRE_TEST: occurs after the test initialization, but before the test is run.
ReportHook(PRE_TEST)(struct criterion_test *test) {
log_info("Starting test: %s\n", test->name)
}
// From: https://github.com/codewars/criterion-hooks/blob/main/criterion-hooks.c
// TEST_CRASH: occurs when a test crashes unexpectedly.
ReportHook(TEST_CRASH)(struct criterion_test_stats *stats) {
log_error("Test Crashed. Caught unexpected signal: ");
switch (stats->signal) {
case SIGILL:
log_error("SIGILL (%d). %s\n", stats->signal, "Invalid instruction.");
break;
case SIGFPE:
log_error("SIGFPE (%d). %s\n", stats->signal, "Erroneous arithmetic operation.");
break;
case SIGSEGV:
log_error("SIGSEGV (%d). %s\n", stats->signal, "Invalid memory access.");
break;
default:
log_error("%d\n", stats->signal);
}
}