test.h
Go to the documentation of this file.
1 //
2 // Bareflank Hypervisor
3 //
4 // Copyright (C) 2015 Assured Information Security, Inc.
5 // Author: Rian Quinn <quinnr@ainfosec.com>
6 // Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 #ifndef TEST_H
23 #define TEST_H
24 
25 #include <unittest.h>
26 
27 class bfm_ut : public unittest
28 {
29 public:
30 
31  bfm_ut();
32  ~bfm_ut() override = default;
33 
34 protected:
35 
36  bool init() override;
37  bool fini() override;
38  bool list() override;
39 
40 private:
41 
42  void test_command_line_parser_with_no_args();
43  void test_command_line_parser_with_empty_args();
44  void test_command_line_parser_with_unknown_command();
45  void test_command_line_parser_with_unknown_command_resets_state();
46  void test_command_line_parser_with_unknown_option_single_bar();
47  void test_command_line_parser_with_unknown_option_dual_bar();
48  void test_command_line_parser_with_single_bar_help();
49  void test_command_line_parser_with_dual_bar_help();
50  void test_command_line_parser_with_single_bar_help_unknown_option();
51  void test_command_line_parser_with_dual_bar_help_unknown_option();
52  void test_command_line_parser_with_load_no_modules();
53  void test_command_line_parser_with_load_no_modules_empty_arg();
54  void test_command_line_parser_with_valid_load();
55  void test_command_line_parser_with_valid_load_unknown_option();
56  void test_command_line_parser_with_unknown_command_before_valid_load();
57  void test_command_line_parser_with_unknown_command_after_valid_load();
58  void test_command_line_parser_with_help_and_valid_load();
59  void test_command_line_parser_with_valid_unload();
60  void test_command_line_parser_with_valid_start();
61  void test_command_line_parser_with_valid_stop();
62  void test_command_line_parser_with_valid_dump();
63  void test_command_line_parser_with_valid_status();
64  void test_command_line_parser_no_vcpuid();
65  void test_command_line_parser_invalid_vcpuid();
66  void test_command_line_parser_valid_vcpuid();
67  void test_command_line_parser_missing_vmcall_opcode();
68  void test_command_line_parser_unknown_vmcall_opcode();
69  void test_command_line_parser_vmcall_versions_missing_index();
70  void test_command_line_parser_vmcall_versions_invalid_index();
71  void test_command_line_parser_vmcall_versions_success();
72  void test_command_line_parser_vmcall_versions_success_with_missing_cpuid();
73  void test_command_line_parser_vmcall_versions_success_with_invalid_cpuid();
74  void test_command_line_parser_vmcall_versions_success_with_cpuid();
75  void test_command_line_parser_vmcall_registers_missing_registers();
76  void test_command_line_parser_vmcall_registers_one_register_invalid_register();
77  void test_command_line_parser_vmcall_registers_one_register();
78  void test_command_line_parser_vmcall_registers_all_registers();
79  void test_command_line_parser_vmcall_string_missing_type();
80  void test_command_line_parser_vmcall_string_unknown_type();
81  void test_command_line_parser_vmcall_string_missing_string();
82  void test_command_line_parser_vmcall_string_unformatted();
83  void test_command_line_parser_vmcall_string_json_missing_json();
84  void test_command_line_parser_vmcall_string_json_invalid_json();
85  void test_command_line_parser_vmcall_string_json();
86  void test_command_line_parser_vmcall_data_missing_type();
87  void test_command_line_parser_vmcall_data_unknown_type();
88  void test_command_line_parser_vmcall_data_missing_ifile();
89  void test_command_line_parser_vmcall_data_missing_ofile();
90  void test_command_line_parser_vmcall_data();
91  void test_command_line_parser_vmcall_unittest_missing_index();
92  void test_command_line_parser_vmcall_unittest_invalid_index();
93  void test_command_line_parser_vmcall_unittest_success();
94  void test_command_line_parser_vmcall_event_missing_index();
95  void test_command_line_parser_vmcall_event_invalid_index();
96  void test_command_line_parser_vmcall_event_success();
97 
98  void test_file_read_with_bad_filename();
99  void test_file_write_with_bad_filename();
100  void test_file_read_write_success();
101 
102  void test_ioctl_driver_inaccessible();
103  void test_ioctl_add_module_with_invalid_length();
104  void test_ioctl_add_module_failed();
105  void test_ioctl_load_vmm_failed();
106  void test_ioctl_unload_vmm_failed();
107  void test_ioctl_start_vmm_failed();
108  void test_ioctl_stop_vmm_failed();
109  void test_ioctl_dump_vmm_with_invalid_drr();
110  void test_ioctl_dump_vmm_failed();
111  void test_ioctl_vmm_status_with_invalid_status();
112  void test_ioctl_vmm_status_failed();
113  void test_ioctl_vmm_vmcall_with_invalid_registers();
114  void test_ioctl_vmm_vmcall_failed();
115 
116  void test_ioctl_driver_process_invalid_file();
117  void test_ioctl_driver_process_invalid_ioctl();
118  void test_ioctl_driver_process_invalid_command_line_parser();
119  void test_ioctl_driver_process_help();
120  void test_ioctl_driver_process_load_vmm_running();
121  void test_ioctl_driver_process_load_vmm_loaded();
122  void test_ioctl_driver_process_load_vmm_corrupt();
123  void test_ioctl_driver_process_load_vmm_unknown_status();
124  void test_ioctl_driver_process_load_bad_modules_filename();
125  void test_ioctl_driver_process_load_bad_module_filename();
126  void test_ioctl_driver_process_load_add_module_failed();
127  void test_ioctl_driver_process_load_load_failed();
128  void test_ioctl_driver_process_load_success();
129  void test_ioctl_driver_process_unload_vmm_running();
130  void test_ioctl_driver_process_unload_vmm_loaded();
131  void test_ioctl_driver_process_unload_vmm_unloaded();
132  void test_ioctl_driver_process_unload_vmm_corrupt();
133  void test_ioctl_driver_process_unload_vmm_unknown_status();
134  void test_ioctl_driver_process_unload_unload_failed();
135  void test_ioctl_driver_process_unload_success();
136  void test_ioctl_driver_process_start_vmm_running();
137  void test_ioctl_driver_process_start_vmm_loaded();
138  void test_ioctl_driver_process_start_vmm_unloaded();
139  void test_ioctl_driver_process_start_vmm_corrupt();
140  void test_ioctl_driver_process_start_vmm_unknown_status();
141  void test_ioctl_driver_process_start_start_failed();
142  void test_ioctl_driver_process_start_success();
143  void test_ioctl_driver_process_stop_vmm_loaded();
144  void test_ioctl_driver_process_stop_vmm_unloaded();
145  void test_ioctl_driver_process_stop_vmm_corrupt();
146  void test_ioctl_driver_process_stop_vmm_unknown_status();
147  void test_ioctl_driver_process_stop_stop_failed();
148  void test_ioctl_driver_process_stop_success();
149  void test_ioctl_driver_process_dump_vmm_unloaded();
150  void test_ioctl_driver_process_dump_vmm_corrupted();
151  void test_ioctl_driver_process_dump_vmm_unknown_status();
152  void test_ioctl_driver_process_dump_dump_failed();
153  void test_ioctl_driver_process_dump_success_running();
154  void test_ioctl_driver_process_dump_success_loaded();
155  void test_ioctl_driver_process_vmm_status_running();
156  void test_ioctl_driver_process_vmm_status_loaded();
157  void test_ioctl_driver_process_vmm_status_unloaded();
158  void test_ioctl_driver_process_vmm_status_corrupt();
159  void test_ioctl_driver_process_vmm_status_unknown_status();
160  void test_ioctl_driver_process_vmcall_vmm_unloaded();
161  void test_ioctl_driver_process_vmcall_vmm_loaded();
162  void test_ioctl_driver_process_vmcall_vmm_corrupt();
163  void test_ioctl_driver_process_vmcall_vmm_unknown();
164  void test_ioctl_driver_process_vmcall_unknown_vmcall();
165  void test_ioctl_driver_process_vmcall_versions_ioctl_failed();
166  void test_ioctl_driver_process_vmcall_versions_ioctl_return_failed();
167  void test_ioctl_driver_process_vmcall_versions_protocol_version();
168  void test_ioctl_driver_process_vmcall_versions_bareflank_version();
169  void test_ioctl_driver_process_vmcall_versions_user_version();
170  void test_ioctl_driver_process_vmcall_versions_unknown();
171  void test_ioctl_driver_process_vmcall_registers_ioctl_failed();
172  void test_ioctl_driver_process_vmcall_registers_ioctl_return_failed();
173  void test_ioctl_driver_process_vmcall_registers_success();
174  void test_ioctl_driver_process_vmcall_unittest_ioctl_failed();
175  void test_ioctl_driver_process_vmcall_unittest_ioctl_return_failed();
176  void test_ioctl_driver_process_vmcall_unittest_success();
177  void test_ioctl_driver_process_vmcall_event_ioctl_failed();
178  void test_ioctl_driver_process_vmcall_event_ioctl_return_failed();
179  void test_ioctl_driver_process_vmcall_event_success();
180  void test_ioctl_driver_process_vmcall_data_string_unformatted_unknown_data_type();
181  void test_ioctl_driver_process_vmcall_data_string_unformatted_ioctl_failed();
182  void test_ioctl_driver_process_vmcall_data_string_unformatted_ioctl_return_failed();
183  void test_ioctl_driver_process_vmcall_data_string_unformatted_out_of_range();
184  void test_ioctl_driver_process_vmcall_data_string_unformatted_success_no_return();
185  void test_ioctl_driver_process_vmcall_data_string_unformatted_success_unformatted();
186  void test_ioctl_driver_process_vmcall_data_string_json_ioctl_failed();
187  void test_ioctl_driver_process_vmcall_data_string_json_ioctl_return_failed();
188  void test_ioctl_driver_process_vmcall_data_string_json_out_of_range();
189  void test_ioctl_driver_process_vmcall_data_string_json_success_no_return();
190  void test_ioctl_driver_process_vmcall_data_string_json_parse_failure();
191  void test_ioctl_driver_process_vmcall_data_string_json_success_json();
192  void test_ioctl_driver_process_vmcall_data_binary_unformatted_ifile_failed();
193  void test_ioctl_driver_process_vmcall_data_binary_unformatted_ioctl_failed();
194  void test_ioctl_driver_process_vmcall_data_binary_unformatted_ioctl_return_failed();
195  void test_ioctl_driver_process_vmcall_data_binary_unformatted_out_of_range();
196  void test_ioctl_driver_process_vmcall_data_binary_unformatted_success_no_return();
197  void test_ioctl_driver_process_vmcall_data_binary_unformatted_success_unformatted();
198 };
199 
200 #endif
Definition: test.h:27
bool list() override
Definition: test.cpp:41
~bfm_ut() override=default
bool init() override
Definition: test.cpp:29
bfm_ut()
Definition: test.cpp:24
bool fini() override
Definition: test.cpp:35