test.cpp
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 #include <test.h>
23 
25 {
26 }
27 
28 bool
30 {
31  return true;
32 }
33 
34 bool
36 {
37  return true;
38 }
39 
40 bool
42 {
43  this->test_command_line_parser_with_no_args();
44  this->test_command_line_parser_with_empty_args();
45  this->test_command_line_parser_with_unknown_command();
46  this->test_command_line_parser_with_unknown_command_resets_state();
47  this->test_command_line_parser_with_unknown_option_single_bar();
48  this->test_command_line_parser_with_unknown_option_dual_bar();
49  this->test_command_line_parser_with_single_bar_help();
50  this->test_command_line_parser_with_dual_bar_help();
51  this->test_command_line_parser_with_single_bar_help_unknown_option();
52  this->test_command_line_parser_with_dual_bar_help_unknown_option();
53  this->test_command_line_parser_with_load_no_modules();
54  this->test_command_line_parser_with_load_no_modules_empty_arg();
55  this->test_command_line_parser_with_valid_load();
56  this->test_command_line_parser_with_valid_load_unknown_option();
57  this->test_command_line_parser_with_unknown_command_before_valid_load();
58  this->test_command_line_parser_with_unknown_command_after_valid_load();
59  this->test_command_line_parser_with_help_and_valid_load();
60  this->test_command_line_parser_with_valid_unload();
61  this->test_command_line_parser_with_valid_start();
62  this->test_command_line_parser_with_valid_stop();
63  this->test_command_line_parser_with_valid_dump();
64  this->test_command_line_parser_with_valid_status();
65  this->test_command_line_parser_no_vcpuid();
66  this->test_command_line_parser_invalid_vcpuid();
67  this->test_command_line_parser_valid_vcpuid();
68  this->test_command_line_parser_missing_vmcall_opcode();
69  this->test_command_line_parser_unknown_vmcall_opcode();
70  this->test_command_line_parser_vmcall_versions_missing_index();
71  this->test_command_line_parser_vmcall_versions_invalid_index();
72  this->test_command_line_parser_vmcall_versions_success();
73  this->test_command_line_parser_vmcall_versions_success_with_missing_cpuid();
74  this->test_command_line_parser_vmcall_versions_success_with_invalid_cpuid();
75  this->test_command_line_parser_vmcall_versions_success_with_cpuid();
76  this->test_command_line_parser_vmcall_registers_missing_registers();
77  this->test_command_line_parser_vmcall_registers_one_register_invalid_register();
78  this->test_command_line_parser_vmcall_registers_one_register();
79  this->test_command_line_parser_vmcall_registers_all_registers();
80  this->test_command_line_parser_vmcall_string_missing_type();
81  this->test_command_line_parser_vmcall_string_unknown_type();
82  this->test_command_line_parser_vmcall_string_missing_string();
83  this->test_command_line_parser_vmcall_string_unformatted();
84  this->test_command_line_parser_vmcall_string_json_missing_json();
85  this->test_command_line_parser_vmcall_string_json_invalid_json();
86  this->test_command_line_parser_vmcall_string_json();
87  this->test_command_line_parser_vmcall_data_missing_type();
88  this->test_command_line_parser_vmcall_data_unknown_type();
89  this->test_command_line_parser_vmcall_data_missing_ifile();
90  this->test_command_line_parser_vmcall_data_missing_ofile();
91  this->test_command_line_parser_vmcall_data();
92  this->test_command_line_parser_vmcall_unittest_missing_index();
93  this->test_command_line_parser_vmcall_unittest_invalid_index();
94  this->test_command_line_parser_vmcall_unittest_success();
95  this->test_command_line_parser_vmcall_event_missing_index();
96  this->test_command_line_parser_vmcall_event_invalid_index();
97  this->test_command_line_parser_vmcall_event_success();
98 
99  this->test_file_read_with_bad_filename();
100  this->test_file_write_with_bad_filename();
101  this->test_file_read_write_success();
102 
103  this->test_ioctl_driver_inaccessible();
104  this->test_ioctl_add_module_with_invalid_length();
105  this->test_ioctl_add_module_failed();
106  this->test_ioctl_load_vmm_failed();
107  this->test_ioctl_unload_vmm_failed();
108  this->test_ioctl_start_vmm_failed();
109  this->test_ioctl_stop_vmm_failed();
110  this->test_ioctl_dump_vmm_with_invalid_drr();
111  this->test_ioctl_dump_vmm_failed();
112  this->test_ioctl_vmm_status_with_invalid_status();
113  this->test_ioctl_vmm_status_failed();
114  this->test_ioctl_vmm_vmcall_with_invalid_registers();
115  this->test_ioctl_vmm_vmcall_failed();
116 
117  this->test_ioctl_driver_process_invalid_file();
118  this->test_ioctl_driver_process_invalid_ioctl();
119  this->test_ioctl_driver_process_invalid_command_line_parser();
120  this->test_ioctl_driver_process_help();
121  this->test_ioctl_driver_process_load_vmm_running();
122  this->test_ioctl_driver_process_load_vmm_loaded();
123  this->test_ioctl_driver_process_load_vmm_corrupt();
124  this->test_ioctl_driver_process_load_vmm_unknown_status();
125  this->test_ioctl_driver_process_load_bad_modules_filename();
126  this->test_ioctl_driver_process_load_bad_module_filename();
127  this->test_ioctl_driver_process_load_add_module_failed();
128  this->test_ioctl_driver_process_load_load_failed();
129  this->test_ioctl_driver_process_load_success();
130  this->test_ioctl_driver_process_unload_vmm_running();
131  this->test_ioctl_driver_process_unload_vmm_loaded();
132  this->test_ioctl_driver_process_unload_vmm_unloaded();
133  this->test_ioctl_driver_process_unload_vmm_corrupt();
134  this->test_ioctl_driver_process_unload_vmm_unknown_status();
135  this->test_ioctl_driver_process_unload_unload_failed();
136  this->test_ioctl_driver_process_unload_success();
137  this->test_ioctl_driver_process_start_vmm_running();
138  this->test_ioctl_driver_process_start_vmm_loaded();
139  this->test_ioctl_driver_process_start_vmm_unloaded();
140  this->test_ioctl_driver_process_start_vmm_corrupt();
141  this->test_ioctl_driver_process_start_vmm_unknown_status();
142  this->test_ioctl_driver_process_start_start_failed();
143  this->test_ioctl_driver_process_start_success();
144  this->test_ioctl_driver_process_stop_vmm_loaded();
145  this->test_ioctl_driver_process_stop_vmm_unloaded();
146  this->test_ioctl_driver_process_stop_vmm_corrupt();
147  this->test_ioctl_driver_process_stop_vmm_unknown_status();
148  this->test_ioctl_driver_process_stop_stop_failed();
149  this->test_ioctl_driver_process_stop_success();
150  this->test_ioctl_driver_process_dump_vmm_unloaded();
151  this->test_ioctl_driver_process_dump_vmm_corrupted();
152  this->test_ioctl_driver_process_dump_vmm_unknown_status();
153  this->test_ioctl_driver_process_dump_dump_failed();
154  this->test_ioctl_driver_process_dump_success_running();
155  this->test_ioctl_driver_process_dump_success_loaded();
156  this->test_ioctl_driver_process_vmm_status_running();
157  this->test_ioctl_driver_process_vmm_status_loaded();
158  this->test_ioctl_driver_process_vmm_status_unloaded();
159  this->test_ioctl_driver_process_vmm_status_corrupt();
160  this->test_ioctl_driver_process_vmm_status_unknown_status();
161  this->test_ioctl_driver_process_vmcall_vmm_unloaded();
162  this->test_ioctl_driver_process_vmcall_vmm_loaded();
163  this->test_ioctl_driver_process_vmcall_vmm_corrupt();
164  this->test_ioctl_driver_process_vmcall_vmm_unknown();
165  this->test_ioctl_driver_process_vmcall_unknown_vmcall();
166  this->test_ioctl_driver_process_vmcall_versions_ioctl_failed();
167  this->test_ioctl_driver_process_vmcall_versions_ioctl_return_failed();
168  this->test_ioctl_driver_process_vmcall_versions_protocol_version();
169  this->test_ioctl_driver_process_vmcall_versions_bareflank_version();
170  this->test_ioctl_driver_process_vmcall_versions_user_version();
171  this->test_ioctl_driver_process_vmcall_versions_unknown();
172  this->test_ioctl_driver_process_vmcall_registers_ioctl_failed();
173  this->test_ioctl_driver_process_vmcall_registers_ioctl_return_failed();
174  this->test_ioctl_driver_process_vmcall_registers_success();
175  this->test_ioctl_driver_process_vmcall_unittest_ioctl_failed();
176  this->test_ioctl_driver_process_vmcall_unittest_ioctl_return_failed();
177  this->test_ioctl_driver_process_vmcall_unittest_success();
178  this->test_ioctl_driver_process_vmcall_event_ioctl_failed();
179  this->test_ioctl_driver_process_vmcall_event_ioctl_return_failed();
180  this->test_ioctl_driver_process_vmcall_event_success();
181  this->test_ioctl_driver_process_vmcall_data_string_unformatted_unknown_data_type();
182  this->test_ioctl_driver_process_vmcall_data_string_unformatted_ioctl_failed();
183  this->test_ioctl_driver_process_vmcall_data_string_unformatted_ioctl_return_failed();
184  this->test_ioctl_driver_process_vmcall_data_string_unformatted_out_of_range();
185  this->test_ioctl_driver_process_vmcall_data_string_unformatted_success_no_return();
186  this->test_ioctl_driver_process_vmcall_data_string_unformatted_success_unformatted();
187  this->test_ioctl_driver_process_vmcall_data_string_json_ioctl_failed();
188  this->test_ioctl_driver_process_vmcall_data_string_json_ioctl_return_failed();
189  this->test_ioctl_driver_process_vmcall_data_string_json_out_of_range();
190  this->test_ioctl_driver_process_vmcall_data_string_json_success_no_return();
191  this->test_ioctl_driver_process_vmcall_data_string_json_parse_failure();
192  this->test_ioctl_driver_process_vmcall_data_string_json_success_json();
193  this->test_ioctl_driver_process_vmcall_data_binary_unformatted_ifile_failed();
194  this->test_ioctl_driver_process_vmcall_data_binary_unformatted_ioctl_failed();
195  this->test_ioctl_driver_process_vmcall_data_binary_unformatted_ioctl_return_failed();
196  this->test_ioctl_driver_process_vmcall_data_binary_unformatted_out_of_range();
197  this->test_ioctl_driver_process_vmcall_data_binary_unformatted_success_no_return();
198  this->test_ioctl_driver_process_vmcall_data_binary_unformatted_success_unformatted();
199 
200  return true;
201 }
202 
203 int
204 main(int argc, char *argv[])
205 {
206  return RUN_ALL_TESTS(bfm_ut);
207 }
Definition: test.h:27
int main(int argc, char *argv[])
Definition: test.cpp:221
bool list() override
Definition: test.cpp:41
#define RUN_ALL_TESTS(ut)
Definition: unittest.h:246
bool init() override
Definition: test.cpp:29
bfm_ut()
Definition: test.cpp:24
bool fini() override
Definition: test.cpp:35