summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDan Ehrenberg <dehrenberg@chromium.org>2015-01-02 14:39:38 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-05 20:35:56 +0000
commitf3f7fca07fbcb6bb9655a71257f09c71b0a1458d (patch)
treef11e478590427dcc3d0214c7cbe819d565d53294 /tests
parent5d652cdffa70dc772e80548a760e1f0d67de273f (diff)
downloadvboot-f3f7fca07fbcb6bb9655a71257f09c71b0a1458d.tar.gz
nand: vboot support for small GPTs
This patch makes some small modifications to cgpt and vboot to root out the last vestigates of a fixed 128-entry GPT: - Get rid of the TOTAL_ENTRIES_SIZE constant and all users. - Reduce MAX_NUMBER_OF_ENTRIES to 128 (which is what the GPT spec specifies) so that this can be used for things like memory allocations without additional overhead. - Base the amount of GPT read/written on the number of entries specified in the GPT header on disk/flash. BUG=chromium:433433 TEST=make runalltests TEST=Modified fmap to make an 8k RW_GPT, wrote a GPT with cgpt, then rebooted and found that the GPT was correctly read after restarting and the appropriate mtd partitions were present. BRANCH=none Change-Id: I45317377da20259caf04a7a4fa077a892b03c45f Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238245 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/cgptlib_test.c3
-rw-r--r--tests/vboot_kernel_tests.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/tests/cgptlib_test.c b/tests/cgptlib_test.c
index 759fa500..13244a56 100644
--- a/tests/cgptlib_test.c
+++ b/tests/cgptlib_test.c
@@ -42,6 +42,7 @@
#define DEFAULT_SECTOR_SIZE 512
#define MAX_SECTOR_SIZE 4096
#define DEFAULT_DRIVE_SECTORS 467
+#define TOTAL_ENTRIES_SIZE (MAX_NUMBER_OF_ENTRIES * sizeof(GptEntry)) /* 16384 */
#define PARTITION_ENTRIES_SIZE TOTAL_ENTRIES_SIZE /* 16384 */
static const Guid guid_zero = {{{0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}}}};
@@ -245,7 +246,7 @@ static int ParameterTests(void)
{512, DEFAULT_DRIVE_SECTORS, GPT_SUCCESS},
{520, DEFAULT_DRIVE_SECTORS, GPT_ERROR_INVALID_SECTOR_SIZE},
{512, 0, GPT_ERROR_INVALID_SECTOR_NUMBER},
- {512, 66, GPT_ERROR_INVALID_SECTOR_NUMBER},
+ {512, 10, GPT_ERROR_INVALID_SECTOR_NUMBER},
{512, GPT_PMBR_SECTORS + GPT_HEADER_SECTORS * 2 +
TOTAL_ENTRIES_SIZE / DEFAULT_SECTOR_SIZE * 2, GPT_SUCCESS},
{4096, DEFAULT_DRIVE_SECTORS, GPT_ERROR_INVALID_SECTOR_SIZE},
diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c
index e19ac114..03e77f98 100644
--- a/tests/vboot_kernel_tests.c
+++ b/tests/vboot_kernel_tests.c
@@ -83,7 +83,7 @@ static void SetupGptHeader(GptHeader *h, int is_secondary)
/* 16KB: 128 entries of 128 bytes */
h->size_of_entry = sizeof(GptEntry);
- h->number_of_entries = TOTAL_ENTRIES_SIZE / h->size_of_entry;
+ h->number_of_entries = MAX_NUMBER_OF_ENTRIES;
/* Set LBA pointers for primary or secondary header */
if (is_secondary) {
@@ -429,6 +429,8 @@ static void ReadWriteGptTest(void)
Memset(g.primary_header, '\0', g.sector_bytes);
h = (GptHeader*)g.primary_header;
h->entries_lba = 2;
+ h->number_of_entries = MAX_NUMBER_OF_ENTRIES;
+ h->size_of_entry = sizeof(GptEntry);
TEST_EQ(WriteAndFreeGptData(handle, &g), 0, "WriteAndFree mod 1");
TEST_CALLS("VbExDiskWrite(h, 1, 1)\n"
"VbExDiskWrite(h, 2, 32)\n");
@@ -441,6 +443,8 @@ static void ReadWriteGptTest(void)
Memset(g.primary_header, '\0', g.sector_bytes);
h = (GptHeader*)g.primary_header;
h->entries_lba = 2;
+ h->number_of_entries = MAX_NUMBER_OF_ENTRIES;
+ h->size_of_entry = sizeof(GptEntry);
h = (GptHeader*)g.secondary_header;
h->entries_lba = 991;
TEST_EQ(WriteAndFreeGptData(handle, &g), 0, "WriteAndFree mod all");