Skip to content

Commit

Permalink
Add tests for load option helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Inokinoki committed Apr 6, 2022
1 parent d5992a5 commit 19d391e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ add_executable(test_parse_boot_name test_parse_boot_name.cc)
add_executable(test_parse_boot_guid test_parse_boot_guid.cc)
add_executable(test_parse_boot_path test_parse_boot_path.cc)
add_executable(test_load_option_parsing test_load_option_parsing.cc)
add_executable(test_load_option_helpers test_load_option_helpers.cc)
add_executable(test_parse_boot_optional_data test_parse_boot_optional_data.cc)

add_test("Parse Boot Order Test" test_parse_boot_order)
add_test("Parse Boot Name Test" test_parse_boot_name)
add_test("Parse Boot GUID Test" test_parse_boot_guid)
add_test("Parse Boot Path Test" test_parse_boot_path)
add_test("Load Option parsing Test" test_load_option_parsing)
add_test("Load Option helpers Test" test_load_option_helpers)
add_test("Parse Boot Optional Data Test" test_parse_boot_optional_data)

target_link_libraries(test_parse_boot_order ${test_libraries})
target_link_libraries(test_parse_boot_name ${test_libraries})
target_link_libraries(test_parse_boot_guid ${test_libraries})
target_link_libraries(test_parse_boot_path ${test_libraries})
target_link_libraries(test_load_option_parsing ${test_libraries})
target_link_libraries(test_load_option_helpers ${test_libraries})
target_link_libraries(test_parse_boot_optional_data ${test_libraries})
45 changes: 45 additions & 0 deletions tests/test_load_option_helpers.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <QtTest/QtTest>

#include "test_data.h"
#include "../qefi.h"

class TestLoadOptionHelpers: public QObject
{
Q_OBJECT
private slots:
void testParseTestBootData();
void testParseTestBootData2();
void testParseEmptyData();
};

void TestLoadOptionHelpers::testParseTestBootData()
{
QByteArray data((const char *)test_boot_data, TEST_BOOT_DATA_LENGTH);

QVERIFY(qefi_loadopt_description_length(data) ==
2 * strlen(test_boot_name));
QVERIFY(qefi_loadopt_dp_list_length(data) == 0x0068);
QVERIFY(qefi_loadopt_optional_data_length(data) == 0);
}

void TestLoadOptionHelpers::testParseTestBootData2()
{
QByteArray data((const char *)test_boot_data2, TEST_BOOT_DATA2_LENGTH);

QVERIFY(qefi_loadopt_description_length(data) ==
2 * strlen(test_boot_name2));
QVERIFY(qefi_loadopt_dp_list_length(data) == 0x0074);
QVERIFY(qefi_loadopt_optional_data_length(data) == 136);
}

void TestLoadOptionHelpers::testParseEmptyData()
{
QByteArray data;
QVERIFY(qefi_loadopt_description_length(data) <= 0);
QVERIFY(qefi_loadopt_dp_list_length(data) <= 0);
QVERIFY(qefi_loadopt_optional_data_length(data) <= 0);
}

QTEST_MAIN(TestLoadOptionHelpers)

#include "test_load_option_helpers.moc"

0 comments on commit 19d391e

Please sign in to comment.