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 vcpu_ut : public unittest
28 {
29 public:
30 
31  vcpu_ut();
32  ~vcpu_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_vcpu_invalid_id();
43  void test_vcpu_null_debug_ring();
44  void test_vcpu_valid();
45  void test_vcpu_write_empty_string();
46  void test_vcpu_write_hello_world();
47  void test_vcpu_init_null_attr();
48  void test_vcpu_init_valid_attr();
49  void test_vcpu_fini_null_attr();
50  void test_vcpu_fini_valid_attr();
51  void test_vcpu_fini_without_init_without_run();
52  void test_vcpu_fini_with_init_without_run();
53  void test_vcpu_fini_without_init_with_run();
54  void test_vcpu_fini_with_init_with_run();
55  void test_vcpu_run_null_attr();
56  void test_vcpu_run_valid_attr();
57  void test_vcpu_run_without_init();
58  void test_vcpu_run_with_init();
59  void test_vcpu_hlt_null_attr();
60  void test_vcpu_hlt_valid_attr();
61  void test_vcpu_hlt_without_run();
62  void test_vcpu_hlt_with_run();
63  void test_vcpu_id();
64  void test_vcpu_is_bootstrap_vcpu();
65  void test_vcpu_is_not_bootstrap_vcpu();
66  void test_vcpu_is_host_vm_vcpu();
67  void test_vcpu_is_not_host_vm_vcpu();
68  void test_vcpu_is_guest_vm_vcpu();
69  void test_vcpu_is_not_guest_vm_vcpu();
70  void test_vcpu_is_running_vm_vcpu();
71  void test_vcpu_is_not_running_vm_vcpu();
72  void test_vcpu_is_initialized_vm_vcpu();
73  void test_vcpu_is_not_initialized_vm_vcpu();
74 
75  void test_vcpu_intel_x64_invalid_id();
76  void test_vcpu_intel_x64_valid();
77  void test_vcpu_intel_x64_init_null_params();
78  void test_vcpu_intel_x64_init_valid_params();
79  void test_vcpu_intel_x64_init_valid();
80  void test_vcpu_intel_x64_init_vmcs_throws();
81  void test_vcpu_intel_x64_fini_null_params();
82  void test_vcpu_intel_x64_fini_valid_params();
83  void test_vcpu_intel_x64_fini_valid();
84  void test_vcpu_intel_x64_fini_no_init();
85  void test_vcpu_intel_x64_run_launch();
86  void test_vcpu_intel_x64_run_launch_is_host_vcpu();
87  void test_vcpu_intel_x64_run_resume();
88  void test_vcpu_intel_x64_run_no_init();
89  void test_vcpu_intel_x64_run_vmxon_throws();
90  void test_vcpu_intel_x64_run_vmcs_throws();
91  void test_vcpu_intel_x64_hlt_no_init();
92  void test_vcpu_intel_x64_hlt_no_run();
93  void test_vcpu_intel_x64_hlt_valid();
94  void test_vcpu_intel_x64_hlt_valid_is_host_vcpu();
95  void test_vcpu_intel_x64_hlt_vmxon_throws();
96 
97  void test_vcpu_manager_create_valid();
98  void test_vcpu_manager_create_valid_twice_overwrites();
99  void test_vcpu_manager_create_make_vcpu_returns_null();
100  void test_vcpu_manager_create_make_vcpu_throws();
101  void test_vcpu_manager_create_init_throws();
102  void test_vcpu_manager_delete_valid();
103  void test_vcpu_manager_delete_valid_twice();
104  void test_vcpu_manager_delete_no_create();
105  void test_vcpu_manager_delete_fini_throws();
106  void test_vcpu_manager_run_valid();
107  void test_vcpu_manager_run_valid_twice();
108  void test_vcpu_manager_run_run_throws();
109  void test_vcpu_manager_run_hlt_throws();
110  void test_vcpu_manager_run_no_create();
111  void test_vcpu_manager_hlt_valid();
112  void test_vcpu_manager_hlt_valid_twice();
113  void test_vcpu_manager_hlt_hlt_throws();
114  void test_vcpu_manager_hlt_no_create();
115  void test_vcpu_manager_write_null();
116  void test_vcpu_manager_write_hello();
117  void test_vcpu_manager_write_no_create();
118 };
119 
120 #endif
bool init() override
Definition: test.cpp:56
bool fini() override
Definition: test.cpp:67
Definition: test.h:27
bool list() override
Definition: test.cpp:73
vcpu_ut()
Definition: test.cpp:51
~vcpu_ut() override=default