DSC Engine
Loading...
Searching...
No Matches
testmod.hpp
1#pragma once
2
3namespace DSC
4{
5 extern bool const IS_TESTMOD;
6
7 void testmod_fatal_raise();
8 bool testmod_fatal_raised();
9 void testmod_reset();
10
11 extern volatile int __testmod_r13;
12 extern volatile int __testmod_r14;
13 extern volatile int __testmod_r15;
14
15 __attribute__((always_inline))
16 inline void testmod_capture()
17 {
18 asm volatile ("mov %0, r13" : "=r"(__testmod_r13));
19 asm volatile ("mov %0, r14" : "=r"(__testmod_r14));
20 asm volatile ("mov %0, r15" : "=r"(__testmod_r15));
21 asm volatile ("nop");
22
23 }
24
25 inline void testmod_return()
26 {
27 asm volatile ("mov r13, %0" :: "r"(__testmod_r13));
28 asm volatile ("mov r14, %0" :: "r"(__testmod_r14));
29 asm volatile ("mov r15, %0" :: "r"(__testmod_r15));
30 }
31
32 typedef void (*TestHandler)();
33
34 void testmod_load_next();
35 void __testmod_register__(TestHandler test_handler, const char* name, bool expect_fatal = false);
36
37
38 #define _testmod_register_1(handler) DSC::__testmod_register__((handler), (#handler))
39 #define _testmod_register_2(handler, expect_fatal) DSC::__testmod_register__((handler), (#handler), (expect_fatal))
40
41 #define _ARG2(_0, _1, _2, ...) _2
42 #define NARG2(...) _ARG2(__VA_ARGS__, 2, 1, 0)
43
44 #define __testmod_register_N(N, ...) _testmod_register_ ## N (__VA_ARGS__)
45 #define _testmod_register_N(N, ...) __testmod_register_N(N, __VA_ARGS__)
46 #define testmod_register(...) _testmod_register_N(NARG2(__VA_ARGS__), __VA_ARGS__)
47
48
49 bool testmod_ready();
50 void testmod_run();
51 bool testmod_expected_fatal();
52
53 void testmod_report_success();
54 void testmod_report_fail();
55
56 void testmod_terminate();
57
58 extern void testmod_init();
59}