test_error_codes.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 #include <error_codes.h>
24 
25 void
26 misc_ut::test_error_codes_valid()
27 {
28  this->expect_true(ec_to_str(SUCCESS) == "SUCCESS"_s);
29  this->expect_true(ec_to_str(ENTRY_ERROR_STACK_OVERFLOW) == "ENTRY_ERROR_STACK_OVERFLOW"_s);
30  this->expect_true(ec_to_str(ENTRY_ERROR_VMM_INIT_FAILED) == "ENTRY_ERROR_VMM_INIT_FAILED"_s);
31  this->expect_true(ec_to_str(ENTRY_ERROR_VMM_START_FAILED) == "ENTRY_ERROR_VMM_START_FAILED"_s);
32  this->expect_true(ec_to_str(ENTRY_ERROR_VMM_STOP_FAILED) == "ENTRY_ERROR_VMM_STOP_FAILED"_s);
33  this->expect_true(ec_to_str(ENTRY_ERROR_UNKNOWN) == "ENTRY_ERROR_UNKNOWN"_s);
34  this->expect_true(ec_to_str(CRT_FAILURE) == "CRT_FAILURE"_s);
35  this->expect_true(ec_to_str(REGISTER_EH_FRAME_FAILURE) == "REGISTER_EH_FRAME_FAILURE"_s);
36  this->expect_true(ec_to_str(GET_DRR_FAILURE) == "GET_DRR_FAILURE"_s);
37  this->expect_true(ec_to_str(MEMORY_MANAGER_FAILURE) == "MEMORY_MANAGER_FAILURE"_s);
38  this->expect_true(ec_to_str(BFELF_ERROR_INVALID_ARG) == "BFELF_ERROR_INVALID_ARG"_s);
39  this->expect_true(ec_to_str(BFELF_ERROR_INVALID_FILE) == "BFELF_ERROR_INVALID_FILE"_s);
40  this->expect_true(ec_to_str(BFELF_ERROR_INVALID_INDEX) == "BFELF_ERROR_INVALID_INDEX"_s);
41  this->expect_true(ec_to_str(BFELF_ERROR_INVALID_SIGNATURE) == "BFELF_ERROR_INVALID_SIGNATURE"_s);
42  this->expect_true(ec_to_str(BFELF_ERROR_UNSUPPORTED_FILE) == "BFELF_ERROR_UNSUPPORTED_FILE"_s);
43  this->expect_true(ec_to_str(BFELF_ERROR_INVALID_SEGMENT) == "BFELF_ERROR_INVALID_SEGMENT"_s);
44  this->expect_true(ec_to_str(BFELF_ERROR_INVALID_SECTION) == "BFELF_ERROR_INVALID_SECTION"_s);
45  this->expect_true(ec_to_str(BFELF_ERROR_LOADER_FULL) == "BFELF_ERROR_LOADER_FULL"_s);
46  this->expect_true(ec_to_str(BFELF_ERROR_NO_SUCH_SYMBOL) == "BFELF_ERROR_NO_SUCH_SYMBOL"_s);
47  this->expect_true(ec_to_str(BFELF_ERROR_MISMATCH) == "BFELF_ERROR_MISMATCH"_s);
48  this->expect_true(ec_to_str(BFELF_ERROR_UNSUPPORTED_RELA) == "BFELF_ERROR_UNSUPPORTED_RELA"_s);
49  this->expect_true(ec_to_str(BFELF_ERROR_OUT_OF_ORDER) == "BFELF_ERROR_OUT_OF_ORDER"_s);
50  this->expect_true(ec_to_str(BF_ERROR_INVALID_ARG) == "BF_ERROR_INVALID_ARG"_s);
51  this->expect_true(ec_to_str(BF_ERROR_INVALID_INDEX) == "BF_ERROR_INVALID_INDEX"_s);
52  this->expect_true(ec_to_str(BF_ERROR_NO_MODULES_ADDED) == "BF_ERROR_NO_MODULES_ADDED"_s);
53  this->expect_true(ec_to_str(BF_ERROR_MAX_MODULES_REACHED) == "BF_ERROR_MAX_MODULES_REACHED"_s);
54  this->expect_true(ec_to_str(BF_ERROR_VMM_INVALID_STATE) == "BF_ERROR_VMM_INVALID_STATE"_s);
55  this->expect_true(ec_to_str(BF_ERROR_FAILED_TO_ADD_FILE) == "BF_ERROR_FAILED_TO_ADD_FILE"_s);
56  this->expect_true(ec_to_str(BF_ERROR_FAILED_TO_DUMP_DR) == "BF_ERROR_FAILED_TO_DUMP_DR"_s);
57  this->expect_true(ec_to_str(BF_ERROR_OUT_OF_MEMORY) == "BF_ERROR_OUT_OF_MEMORY"_s);
58  this->expect_true(ec_to_str(BF_ERROR_VMM_CORRUPTED) == "BF_ERROR_VMM_CORRUPTED"_s);
59  this->expect_true(ec_to_str(BF_ERROR_UNKNOWN) == "BF_ERROR_UNKNOWN"_s);
60  this->expect_true(ec_to_str(BF_BAD_ALLOC) == "BF_BAD_ALLOC"_s);
61  this->expect_true(ec_to_str(BF_IOCTL_FAILURE) == "BF_IOCTL_FAILURE"_s);
62 }
63 
64 void
65 misc_ut::test_error_codes_unknown()
66 {
67  this->expect_true(ec_to_str(0x123456789) == std::string("UNDEFINED_ERROR_CODE"));
68 }
#define BFELF_ERROR_UNSUPPORTED_RELA
Definition: error_codes.h:91
#define ENTRY_ERROR_VMM_START_FAILED
Definition: error_codes.h:51
#define BFELF_ERROR_INVALID_ARG
Definition: error_codes.h:81
#define BFELF_ERROR_NO_SUCH_SYMBOL
Definition: error_codes.h:89
#define BFELF_ERROR_INVALID_SECTION
Definition: error_codes.h:87
#define BF_ERROR_FAILED_TO_DUMP_DR
Definition: error_codes.h:112
#define BF_ERROR_VMM_INVALID_STATE
Definition: error_codes.h:110
#define BF_ERROR_MAX_MODULES_REACHED
Definition: error_codes.h:109
#define REGISTER_EH_FRAME_FAILURE
Definition: error_codes.h:67
#define MEMORY_MANAGER_FAILURE
Definition: error_codes.h:99
#define BFELF_ERROR_MISMATCH
Definition: error_codes.h:90
#define GET_DRR_FAILURE
Definition: error_codes.h:74
#define BFELF_ERROR_INVALID_INDEX
Definition: error_codes.h:83
#define BFELF_ERROR_UNSUPPORTED_FILE
Definition: error_codes.h:85
#define BFELF_ERROR_OUT_OF_ORDER
Definition: error_codes.h:92
#define BF_IOCTL_FAILURE
Definition: error_codes.h:122
#define BF_BAD_ALLOC
Definition: error_codes.h:128
#define ENTRY_ERROR_UNKNOWN
Definition: error_codes.h:53
#define CRT_FAILURE
Definition: error_codes.h:60
#define BFELF_ERROR_INVALID_FILE
Definition: error_codes.h:82
#define BF_ERROR_INVALID_INDEX
Definition: error_codes.h:107
#define BFELF_ERROR_INVALID_SEGMENT
Definition: error_codes.h:86
#define BFELF_ERROR_LOADER_FULL
Definition: error_codes.h:88
#define BFELF_ERROR_INVALID_SIGNATURE
Definition: error_codes.h:84
#define BF_ERROR_OUT_OF_MEMORY
Definition: error_codes.h:113
#define ENTRY_ERROR_STACK_OVERFLOW
Definition: error_codes.h:49
#define BF_ERROR_NO_MODULES_ADDED
Definition: error_codes.h:108
#define ENTRY_ERROR_VMM_STOP_FAILED
Definition: error_codes.h:52
#define BF_ERROR_INVALID_ARG
Definition: error_codes.h:106
#define BF_ERROR_FAILED_TO_ADD_FILE
Definition: error_codes.h:111
#define BF_ERROR_VMM_CORRUPTED
Definition: error_codes.h:114
#define expect_true(a)
#define ENTRY_ERROR_VMM_INIT_FAILED
Definition: error_codes.h:50
#define SUCCESS
Definition: error_codes.h:42
#define BF_ERROR_UNKNOWN
Definition: error_codes.h:115