Skip to content

Commit 19d391e

Browse files
committed
Add tests for load option helpers
1 parent d5992a5 commit 19d391e

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ add_executable(test_parse_boot_name test_parse_boot_name.cc)
88
add_executable(test_parse_boot_guid test_parse_boot_guid.cc)
99
add_executable(test_parse_boot_path test_parse_boot_path.cc)
1010
add_executable(test_load_option_parsing test_load_option_parsing.cc)
11+
add_executable(test_load_option_helpers test_load_option_helpers.cc)
1112
add_executable(test_parse_boot_optional_data test_parse_boot_optional_data.cc)
1213

1314
add_test("Parse Boot Order Test" test_parse_boot_order)
1415
add_test("Parse Boot Name Test" test_parse_boot_name)
1516
add_test("Parse Boot GUID Test" test_parse_boot_guid)
1617
add_test("Parse Boot Path Test" test_parse_boot_path)
1718
add_test("Load Option parsing Test" test_load_option_parsing)
19+
add_test("Load Option helpers Test" test_load_option_helpers)
1820
add_test("Parse Boot Optional Data Test" test_parse_boot_optional_data)
1921

2022
target_link_libraries(test_parse_boot_order ${test_libraries})
2123
target_link_libraries(test_parse_boot_name ${test_libraries})
2224
target_link_libraries(test_parse_boot_guid ${test_libraries})
2325
target_link_libraries(test_parse_boot_path ${test_libraries})
2426
target_link_libraries(test_load_option_parsing ${test_libraries})
27+
target_link_libraries(test_load_option_helpers ${test_libraries})
2528
target_link_libraries(test_parse_boot_optional_data ${test_libraries})

tests/test_load_option_helpers.cc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <QtTest/QtTest>
2+
3+
#include "test_data.h"
4+
#include "../qefi.h"
5+
6+
class TestLoadOptionHelpers: public QObject
7+
{
8+
Q_OBJECT
9+
private slots:
10+
void testParseTestBootData();
11+
void testParseTestBootData2();
12+
void testParseEmptyData();
13+
};
14+
15+
void TestLoadOptionHelpers::testParseTestBootData()
16+
{
17+
QByteArray data((const char *)test_boot_data, TEST_BOOT_DATA_LENGTH);
18+
19+
QVERIFY(qefi_loadopt_description_length(data) ==
20+
2 * strlen(test_boot_name));
21+
QVERIFY(qefi_loadopt_dp_list_length(data) == 0x0068);
22+
QVERIFY(qefi_loadopt_optional_data_length(data) == 0);
23+
}
24+
25+
void TestLoadOptionHelpers::testParseTestBootData2()
26+
{
27+
QByteArray data((const char *)test_boot_data2, TEST_BOOT_DATA2_LENGTH);
28+
29+
QVERIFY(qefi_loadopt_description_length(data) ==
30+
2 * strlen(test_boot_name2));
31+
QVERIFY(qefi_loadopt_dp_list_length(data) == 0x0074);
32+
QVERIFY(qefi_loadopt_optional_data_length(data) == 136);
33+
}
34+
35+
void TestLoadOptionHelpers::testParseEmptyData()
36+
{
37+
QByteArray data;
38+
QVERIFY(qefi_loadopt_description_length(data) <= 0);
39+
QVERIFY(qefi_loadopt_dp_list_length(data) <= 0);
40+
QVERIFY(qefi_loadopt_optional_data_length(data) <= 0);
41+
}
42+
43+
QTEST_MAIN(TestLoadOptionHelpers)
44+
45+
#include "test_load_option_helpers.moc"

0 commit comments

Comments
 (0)