bfvmm
src
exit_handler
test
test_exit_handler_intel_x64_entry.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 <
exit_handler/exit_handler_intel_x64.h
>
24
#include <
exit_handler/exit_handler_intel_x64_entry.h
>
25
#include <
exit_handler/exit_handler_intel_x64_support.h
>
26
27
void
28
exit_handler_intel_x64_ut::test_entry_valid()
29
{
30
MockRepository mocks;
31
auto
&&eh = mocks.Mock<
exit_handler_intel_x64
>();
32
33
mocks.OnCall(eh,
exit_handler_intel_x64::halt
);
34
mocks.OnCall(eh,
exit_handler_intel_x64::dispatch
);
35
36
RUN_UNITTEST_WITH_MOCKS
(mocks, [&]
37
{
38
this->
expect_no_exception
([&]{
exit_handler
(eh); });
39
});
40
}
41
42
void
43
exit_handler_intel_x64_ut::test_entry_throws_general_exception()
44
{
45
MockRepository mocks;
46
auto
&&eh = mocks.Mock<
exit_handler_intel_x64
>();
47
48
mocks.ExpectCall(eh,
exit_handler_intel_x64::halt
);
49
mocks.OnCall(eh,
exit_handler_intel_x64::dispatch
).Throw(
bfn::general_exception
());
50
51
RUN_UNITTEST_WITH_MOCKS
(mocks, [&]
52
{
53
this->
expect_no_exception
([&]{
exit_handler
(eh); });
54
});
55
}
56
57
void
58
exit_handler_intel_x64_ut::test_entry_throws_standard_exception()
59
{
60
MockRepository mocks;
61
auto
&&eh = mocks.Mock<
exit_handler_intel_x64
>();
62
63
mocks.ExpectCall(eh,
exit_handler_intel_x64::halt
);
64
mocks.OnCall(eh,
exit_handler_intel_x64::dispatch
).Throw(std::exception());
65
66
RUN_UNITTEST_WITH_MOCKS
(mocks, [&]
67
{
68
this->
expect_no_exception
([&]{
exit_handler
(eh); });
69
});
70
}
71
72
void
73
exit_handler_intel_x64_ut::test_entry_throws_any_exception()
74
{
75
MockRepository mocks;
76
auto
&&eh = mocks.Mock<
exit_handler_intel_x64
>();
77
78
mocks.ExpectCall(eh,
exit_handler_intel_x64::halt
);
79
mocks.OnCall(eh,
exit_handler_intel_x64::dispatch
).Throw(10);
80
81
RUN_UNITTEST_WITH_MOCKS
(mocks, [&]
82
{
83
this->
expect_no_exception
([&]{
exit_handler
(eh); });
84
});
85
}
RUN_UNITTEST_WITH_MOCKS
#define RUN_UNITTEST_WITH_MOCKS(a, b)
Definition:
unittest.h:229
exit_handler_intel_x64_support.h
expect_no_exception
#define expect_no_exception(f)
Definition:
unittest.h:198
exit_handler
void exit_handler(exit_handler_intel_x64 *exit_handler) noexcept
Definition:
exit_handler_intel_x64_entry.cpp:31
exit_handler_intel_x64
Definition:
exit_handler_intel_x64.h:52
exit_handler_intel_x64_entry.h
exit_handler_intel_x64.h
bfn::general_exception
Definition:
exception.h:57
test.h
exit_handler_intel_x64::halt
virtual void halt() noexcept
Definition:
exit_handler_intel_x64.cpp:62
exit_handler_intel_x64::dispatch
virtual void dispatch()
Definition:
exit_handler_intel_x64.cpp:58
Generated on Fri Apr 28 2017 22:11:40 by
1.8.14