summaryrefslogtreecommitdiff
path: root/tests/cgptlib_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cgptlib_test.c')
-rw-r--r--tests/cgptlib_test.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/tests/cgptlib_test.c b/tests/cgptlib_test.c
index 12b366ad..fc166fda 100644
--- a/tests/cgptlib_test.c
+++ b/tests/cgptlib_test.c
@@ -461,15 +461,15 @@ static int SignatureTest(void)
GptHeader *h2 = (GptHeader *)gpt->secondary_header;
int i;
- EXPECT(1 == CheckHeader(NULL, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(NULL, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
for (i = 0; i < 8; ++i) {
BuildTestGptData(gpt);
h1->signature[i] ^= 0xff;
h2->signature[i] ^= 0xff;
RefreshCrc32(gpt);
- EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
}
return TEST_OK;
@@ -503,9 +503,9 @@ static int RevisionTest(void)
h2->revision = cases[i].value_to_test;
RefreshCrc32(gpt);
- EXPECT(CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE) ==
+ EXPECT(CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE) ==
cases[i].expect_rv);
- EXPECT(CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE) ==
+ EXPECT(CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE) ==
cases[i].expect_rv);
}
return TEST_OK;
@@ -536,9 +536,9 @@ static int SizeTest(void)
h2->size = cases[i].value_to_test;
RefreshCrc32(gpt);
- EXPECT(CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE) ==
+ EXPECT(CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE) ==
cases[i].expect_rv);
- EXPECT(CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE) ==
+ EXPECT(CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE) ==
cases[i].expect_rv);
}
return TEST_OK;
@@ -555,12 +555,12 @@ static int CrcFieldTest(void)
/* Modify a field that the header verification doesn't care about */
h1->entries_crc32++;
h2->entries_crc32++;
- EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
/* Refresh the CRC; should pass now */
RefreshCrc32(gpt);
- EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(0 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(0 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
return TEST_OK;
}
@@ -576,8 +576,8 @@ static int ReservedFieldsTest(void)
h1->reserved_zero ^= 0x12345678; /* whatever random */
h2->reserved_zero ^= 0x12345678; /* whatever random */
RefreshCrc32(gpt);
- EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
#ifdef PADDING_CHECKED
/* TODO: padding check is currently disabled */
@@ -585,8 +585,8 @@ static int ReservedFieldsTest(void)
h1->padding[12] ^= 0x34; /* whatever random */
h2->padding[56] ^= 0x78; /* whatever random */
RefreshCrc32(gpt);
- EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
#endif
return TEST_OK;
@@ -624,9 +624,9 @@ static int SizeOfPartitionEntryTest(void) {
cases[i].value_to_test;
RefreshCrc32(gpt);
- EXPECT(CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE) ==
+ EXPECT(CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE) ==
cases[i].expect_rv);
- EXPECT(CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE) ==
+ EXPECT(CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE) ==
cases[i].expect_rv);
}
@@ -647,11 +647,11 @@ static int NumberOfPartitionEntriesTest(void)
h1->number_of_entries--;
h2->number_of_entries /= 2;
RefreshCrc32(gpt);
- EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
/* But it's okay to have less if the GPT structs are stored elsewhere. */
- EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_OFF_DEVICE));
- EXPECT(0 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_OFF_DEVICE));
+ EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_OFF_DEVICE));
+ EXPECT(0 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_OFF_DEVICE));
return TEST_OK;
}
@@ -666,37 +666,37 @@ static int MyLbaTest(void)
/* myLBA depends on primary vs secondary flag */
BuildTestGptData(gpt);
- EXPECT(1 == CheckHeader(h1, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
BuildTestGptData(gpt);
h1->my_lba--;
h2->my_lba--;
RefreshCrc32(gpt);
- EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
BuildTestGptData(gpt);
h1->my_lba = 2;
h2->my_lba--;
RefreshCrc32(gpt);
- EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
/* We should ignore the alternate_lba field entirely */
BuildTestGptData(gpt);
h1->alternate_lba++;
h2->alternate_lba++;
RefreshCrc32(gpt);
- EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(0 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(0 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
BuildTestGptData(gpt);
h1->alternate_lba--;
h2->alternate_lba--;
RefreshCrc32(gpt);
- EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(0 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(0 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
BuildTestGptData(gpt);
h1->entries_lba++;
@@ -706,19 +706,19 @@ static int MyLbaTest(void)
* We support a padding between primary GPT header and its entries. So
* this still passes.
*/
- EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(0 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
/*
* But the secondary table should fail because it would overlap the
* header, which is now lying after its entry array.
*/
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
BuildTestGptData(gpt);
h1->entries_lba--;
h2->entries_lba--;
RefreshCrc32(gpt);
- EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
- EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
+ EXPECT(1 == CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
return TEST_OK;
}
@@ -767,9 +767,9 @@ static int FirstUsableLbaAndLastUsableLbaTest(void)
h2->last_usable_lba = cases[i].secondary_last_usable_lba;
RefreshCrc32(gpt);
- EXPECT(CheckHeader(h1, 0, gpt->drive_sectors, GPT_STORED_ON_DEVICE) ==
+ EXPECT(CheckHeader(h1, 0, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE) ==
cases[i].primary_rv);
- EXPECT(CheckHeader(h2, 1, gpt->drive_sectors, GPT_STORED_ON_DEVICE) ==
+ EXPECT(CheckHeader(h2, 1, gpt->drive_sectors, gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE) ==
cases[i].secondary_rv);
}
@@ -1981,26 +1981,26 @@ static int CheckHeaderOffDevice()
// GPT is stored on the same device so first usable lba should not
// start at 0.
EXPECT(1 == CheckHeader(primary_header, 0, gpt->drive_sectors,
- GPT_STORED_ON_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
// But off device, it is okay to accept this GPT header.
EXPECT(0 == CheckHeader(primary_header, 0, gpt->drive_sectors,
- GPT_STORED_OFF_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_OFF_DEVICE));
BuildTestGptData(gpt);
primary_header->number_of_entries = 100;
RefreshCrc32(gpt);
// Normally, number of entries is 128. So this should fail.
EXPECT(1 == CheckHeader(primary_header, 0, gpt->drive_sectors,
- GPT_STORED_ON_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
// But off device, it is okay.
EXPECT(0 == CheckHeader(primary_header, 0, gpt->drive_sectors,
- GPT_STORED_OFF_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_OFF_DEVICE));
primary_header->number_of_entries = MIN_NUMBER_OF_ENTRIES - 1;
RefreshCrc32(gpt);
// However, too few entries is not good.
EXPECT(1 == CheckHeader(primary_header, 0, gpt->drive_sectors,
- GPT_STORED_OFF_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_OFF_DEVICE));
// Repeat for secondary header.
BuildTestGptData(gpt);
@@ -2008,22 +2008,22 @@ static int CheckHeaderOffDevice()
secondary_header->first_usable_lba = 0;
RefreshCrc32(gpt);
EXPECT(1 == CheckHeader(secondary_header, 1, gpt->drive_sectors,
- GPT_STORED_ON_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
EXPECT(0 == CheckHeader(secondary_header, 1, gpt->drive_sectors,
- GPT_STORED_OFF_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_OFF_DEVICE));
BuildTestGptData(gpt);
secondary_header->number_of_entries = 100;
RefreshCrc32(gpt);
EXPECT(1 == CheckHeader(secondary_header, 1, gpt->drive_sectors,
- GPT_STORED_ON_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_ON_DEVICE));
EXPECT(0 == CheckHeader(secondary_header, 1, gpt->drive_sectors,
- GPT_STORED_OFF_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_OFF_DEVICE));
secondary_header->number_of_entries = MIN_NUMBER_OF_ENTRIES - 1;
RefreshCrc32(gpt);
EXPECT(1 == CheckHeader(secondary_header, 1, gpt->drive_sectors,
- GPT_STORED_OFF_DEVICE));
+ gpt->gpt_drive_sectors, GPT_STORED_OFF_DEVICE));
return TEST_OK;
}