growlight: fix build with doctest 2.4.6

This commit is contained in:
Đoàn Trần Công Danh 2021-03-25 21:21:01 +07:00
parent deda791335
commit 93e42c7c1f
2 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,74 @@
Index: growlight-1.2.31/tests/gpt.cpp
===================================================================
--- growlight-1.2.31.orig/tests/gpt.cpp
+++ growlight-1.2.31/tests/gpt.cpp
@@ -6,6 +6,9 @@
#define UUID "\x5E\x86\x90\xEF\xD0\x30\x03\x46\x99\x3D\x54\x6E\xB0\xE7\x1B\x0D"
+template <typename T>
+T xnormalise(T value) { return value; }
+
TEST_CASE("GPT") {
// First eight bytes must be "EFI PART"
@@ -19,14 +22,14 @@ TEST_CASE("GPT") {
SUBCASE("Revision") {
gpt_header head;
CHECK(0 == initialize_gpt(&head, 512, 4194287, 34, nullptr));
- CHECK(0x00010000 == head.revision);
+ CHECK(0x00010000 == xnormalise(head.revision));
}
// Bytes 0xc--0xf must be >= 92, should be the logical block size
SUBCASE("HeaderSize") {
gpt_header head;
CHECK(0 == initialize_gpt(&head, 512, 4194287, 34, nullptr));
- CHECK(92 == head.headsize);
+ CHECK(92 == xnormalise(head.headsize));
}
// Bytes 0x18--0x1f are the sector of the GPT primary, usually 1
@@ -34,8 +37,8 @@ TEST_CASE("GPT") {
SUBCASE("GPTLBAs") {
gpt_header head;
CHECK(0 == initialize_gpt(&head, 512, 100000, 34, nullptr));
- CHECK(1 == head.lba);
- CHECK(100000 == head.backuplba);
+ CHECK(1 == xnormalise(head.lba));
+ CHECK(100000 == xnormalise(head.backuplba));
}
// Verify the 16-byte UUID is as specified
@@ -61,17 +64,17 @@ TEST_CASE("GPT") {
gpt_header head;
CHECK(0 == initialize_gpt(&head, 512, 4194287, 34, UUID));
// partition entry size must be a positive multiple of 128 (usually 128)
- CHECK(0 < head.partsize);
+ CHECK(0 < xnormalise(head.partsize));
CHECK(0 == (head.partsize % 128));
// number of partition entries, usually 128 (MINIMUM_GPT_ENTRIES)
- CHECK(128 <= head.partcount);
+ CHECK(128 <= xnormalise(head.partcount));
auto entries = new gpt_entry[head.partcount];
memset(entries, 0, sizeof(*entries) * head.partcount);
CHECK(0 == update_crc(&head, entries));
// FIXME fix on big-endian!
- WARN(2006165414 == head.crc);
- CHECK(0 == head.reserved);
- CHECK(2874462854 == head.partcrc);
+ WARN(2006165414 == xnormalise(head.crc));
+ CHECK(0 == xnormalise(head.reserved));
+ CHECK(2874462854 == xnormalise(head.partcrc));
delete[] entries;
}
@@ -85,7 +88,7 @@ TEST_CASE("GPT") {
memset(sector, 0xff, sizeof(sector));
gpt_header* head = reinterpret_cast<gpt_header*>(sector);
CHECK(0 == initialize_gpt(head, sizeof(sector), 4194287, 34, nullptr));
- CHECK(92 == head->headsize);
+ CHECK(92 == xnormalise(head->headsize));
for(size_t idx = 92 ; idx < sizeof(sector) ; ++idx){
CHECK(0 == sector[idx]);
}

View file

@ -15,6 +15,7 @@ license="GPL-3.0-or-later"
homepage="https://nick-black.com/dankwiki/index.php/Growlight"
distfiles="https://github.com/dankamongmen/growlight/archive/v${version}.tar.gz"
checksum=25cf643d99be88d299756ccb2933868641abecbc26793f5d87cfae93a461e2d6
patch_args=-Np1
build_options="man zfs"