1
2
3
4
5
6
7
8#ifndef _EFI_SELFTEST_H
9#define _EFI_SELFTEST_H
10
11#include <common.h>
12#include <efi.h>
13#include <efi_api.h>
14#include <efi_loader.h>
15#include <linker_lists.h>
16
17#define EFI_ST_SUCCESS 0
18#define EFI_ST_FAILURE 1
19#define EFI_ST_SUCCESS_STR L"SUCCESS"
20
21
22
23#define efi_st_printf(...) \
24 (efi_st_printc(-1, __VA_ARGS__))
25
26
27
28
29
30
31#define efi_st_error(...) \
32 (efi_st_printc(EFI_LIGHTRED, "%s(%u):\nERROR: ", __FILE__, __LINE__), \
33 efi_st_printc(EFI_LIGHTRED, __VA_ARGS__))
34
35
36
37
38
39
40#define efi_st_todo(...) \
41 (efi_st_printc(EFI_YELLOW, "%s(%u):\nTODO: ", __FILE__, __LINE__), \
42 efi_st_printc(EFI_YELLOW, __VA_ARGS__)) \
43
44
45
46
47
48
49enum efi_test_phase {
50 EFI_EXECUTE_BEFORE_BOOTTIME_EXIT = 1,
51 EFI_SETUP_BEFORE_BOOTTIME_EXIT,
52 EFI_SETUP_AFTER_BOOTTIME_EXIT,
53};
54
55extern struct efi_simple_text_output_protocol *con_out;
56extern struct efi_simple_text_input_protocol *con_in;
57
58
59
60
61
62
63
64
65
66void efi_st_exit_boot_services(void);
67
68
69
70
71
72
73
74
75
76void efi_st_printc(int color, const char *fmt, ...)
77 __attribute__ ((format (__printf__, 2, 3)));
78
79
80
81
82
83
84
85u16 *efi_st_translate_char(u16 code);
86
87
88
89
90
91
92
93u16 *efi_st_translate_code(u16 code);
94
95
96
97
98
99
100
101
102int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2);
103
104
105
106
107
108
109u16 efi_st_get_key(void);
110
111
112
113
114
115
116
117
118
119
120
121
122
123struct efi_unit_test {
124 const char *name;
125 const enum efi_test_phase phase;
126 int (*setup)(const efi_handle_t handle,
127 const struct efi_system_table *systable);
128 int (*execute)(void);
129 int (*teardown)(void);
130 bool on_request;
131};
132
133
134#define EFI_UNIT_TEST(__name) \
135 ll_entry_declare(struct efi_unit_test, __name, efi_unit_test)
136
137#endif
138