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 
28 {
29 public:
30 
32  ~memory_manager_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_mem_pool_free_zero();
43  void test_mem_pool_free_heap_twice();
44  void test_mem_pool_invalid_pool();
45  void test_mem_pool_malloc_zero();
46  void test_mem_pool_multiple_malloc_heap_should_be_contiguous();
47  void test_mem_pool_malloc_heap_all_of_memory();
48  void test_mem_pool_malloc_heap_all_of_memory_one_block();
49  void test_mem_pool_malloc_heap_all_memory_fragmented();
50  void test_mem_pool_malloc_heap_too_much_memory_one_block();
51  void test_mem_pool_malloc_heap_too_much_memory_non_block_size();
52  void test_mem_pool_malloc_heap_massive();
53  void test_mem_pool_size_out_of_bounds();
54  void test_mem_pool_size_unallocated();
55  void test_mem_pool_size();
56  void test_mem_pool_contains_out_of_bounds();
57  void test_mem_pool_contains();
58 
59  void test_memory_manager_x64_size_out_of_bounds();
60  void test_memory_manager_x64_malloc_out_of_memory();
61  void test_memory_manager_x64_malloc_heap();
62  void test_memory_manager_x64_malloc_page();
63  void test_memory_manager_x64_malloc_map();
64  void test_memory_manager_x64_add_md();
65  void test_memory_manager_x64_add_md_invalid_type();
66  void test_memory_manager_x64_add_md_unaligned_physical();
67  void test_memory_manager_x64_add_md_unaligned_virtual();
68  void test_memory_manager_x64_remove_md_invalid_virt();
69  void test_memory_manager_x64_virtint_to_physint_failure();
70  void test_memory_manager_x64_physint_to_virtint_failure();
71  void test_memory_manager_x64_virtint_to_attrint_failure();
72  void test_memory_manager_x64_virtint_to_physint_random_address();
73  void test_memory_manager_x64_virtint_to_physint_nullptr();
74  void test_memory_manager_x64_physint_to_virtint_random_address();
75  void test_memory_manager_x64_physint_to_virtint_nullptr();
76  void test_memory_manager_x64_virtint_to_attrint_random_address();
77  void test_memory_manager_x64_virtint_to_attrint_nullptr();
78 
79  void test_page_table_x64_add_remove_page_success_without_setting();
80  void test_page_table_x64_add_remove_page_1g_success();
81  void test_page_table_x64_add_remove_page_2m_success();
82  void test_page_table_x64_add_remove_page_4k_success();
83  void test_page_table_x64_add_remove_page_swap_success();
84  void test_page_table_x64_add_page_twice_success();
85  void test_page_table_x64_remove_page_twice_success();
86  void test_page_table_x64_remove_page_unknown_success();
87  void test_page_table_x64_virt_to_pte_invalid();
88  void test_page_table_x64_virt_to_pte_success();
89  void test_page_table_x64_pt_to_mdl_success();
90 
91  void test_page_table_entry_x64_present();
92  void test_page_table_entry_x64_rw();
93  void test_page_table_entry_x64_us();
94  void test_page_table_entry_x64_pwt();
95  void test_page_table_entry_x64_pcd();
96  void test_page_table_entry_x64_accessed();
97  void test_page_table_entry_x64_dirty();
98  void test_page_table_entry_x64_pat();
99  void test_page_table_entry_x64_ps();
100  void test_page_table_entry_x64_global();
101  void test_page_table_entry_x64_nx();
102  void test_page_table_entry_x64_phys_addr();
103  void test_page_table_entry_x64_pat_index();
104  void test_page_table_entry_x64_clear();
105 
106  void test_unique_map_ptr_x64_default_constructor();
107  void test_unique_map_ptr_x64_phys_constructor_invalid_args();
108  void test_unique_map_ptr_x64_phys_constructor_mm_map_fails();
109  void test_unique_map_ptr_x64_phys_constructor_success();
110  void test_unique_map_ptr_x64_phys_range_constructor_invalid_args();
111  void test_unique_map_ptr_x64_phys_range_constructor_mm_map_fails();
112  void test_unique_map_ptr_x64_phys_range_constructor_success();
113  void test_unique_map_ptr_x64_virt_cr3_constructor_invalid_args();
114  void test_unique_map_ptr_x64_virt_cr3_constructor_mm_map_fails();
115  void test_unique_map_ptr_x64_virt_cr3_constructor_success_1g();
116  void test_unique_map_ptr_x64_virt_cr3_constructor_success_2m();
117  void test_unique_map_ptr_x64_virt_cr3_constructor_success_4k();
118  void test_unique_map_ptr_x64_virt_cr3_constructor_success_4k_aligned_addr();
119  void test_unique_map_ptr_x64_virt_cr3_constructor_success_4k_aligned_size();
120  void test_unique_map_ptr_x64_virt_cr3_constructor_not_present();
121  void test_unique_map_ptr_x64_virt_cr3_constructor_invalid_phys_addr();
122  void test_unique_map_ptr_x64_copy_constructor();
123  void test_unique_map_ptr_x64_move_operator_valid();
124  void test_unique_map_ptr_x64_move_operator_invalid();
125  void test_unique_map_ptr_x64_reference_operators();
126  void test_unique_map_ptr_x64_release();
127  void test_unique_map_ptr_x64_reset();
128  void test_unique_map_ptr_x64_swap();
129  void test_unique_map_ptr_x64_flush();
130  void test_unique_map_ptr_x64_cache_flush();
131  void test_unique_map_ptr_x64_comparison();
132  void test_unique_map_ptr_x64_make_failure();
133  void test_virt_to_phys_with_cr3_invalid();
134  void test_virt_to_phys_with_cr3_1g();
135  void test_virt_to_phys_with_cr3_2m();
136  void test_virt_to_phys_with_cr3_4k();
137 
138  void test_root_page_table_x64_init_failure();
139  void test_root_page_table_x64_init_success();
140  void test_root_page_table_x64_cr3();
141  void test_root_page_table_x64_map_1g();
142  void test_root_page_table_x64_map_2m();
143  void test_root_page_table_x64_map_4k();
144  void test_root_page_table_x64_map_invalid();
145  void test_root_page_table_x64_map_unmap_twice_success();
146  void test_root_page_table_x64_setup_identity_map_1g_invalid();
147  void test_root_page_table_x64_setup_identity_map_1g_valid();
148  void test_root_page_table_x64_setup_identity_map_2m_invalid();
149  void test_root_page_table_x64_setup_identity_map_2m_valid();
150  void test_root_page_table_x64_setup_identity_map_4k_invalid();
151  void test_root_page_table_x64_setup_identity_map_4k_valid();
152  void test_root_page_table_x64_pt_to_mdl();
153 
154  void test_pat_x64_mem_attr_to_pat_index();
155  void test_mem_attr_x64_mem_type_to_attr();
156 };
157 
158 #endif
bool init() override
Definition: test.cpp:32
bool fini() override
Definition: test.cpp:38
bool list() override
Definition: test.cpp:44
~memory_manager_ut() override=default