Lines Matching refs:gpt

72 static void RefreshCrc32(GptData *gpt)  in RefreshCrc32()  argument
77 header = (GptHeader *)gpt->primary_header; in RefreshCrc32()
78 entries = (GptEntry *)gpt->primary_entries; in RefreshCrc32()
79 header2 = (GptHeader *)gpt->secondary_header; in RefreshCrc32()
80 entries2 = (GptEntry *)gpt->secondary_entries; in RefreshCrc32()
94 static void ZeroHeaders(GptData *gpt) in ZeroHeaders() argument
96 Memset(gpt->primary_header, 0, MAX_SECTOR_SIZE); in ZeroHeaders()
97 Memset(gpt->secondary_header, 0, MAX_SECTOR_SIZE); in ZeroHeaders()
100 static void ZeroEntries(GptData *gpt) in ZeroEntries() argument
102 Memset(gpt->primary_entries, 0, PARTITION_ENTRIES_SIZE); in ZeroEntries()
103 Memset(gpt->secondary_entries, 0, PARTITION_ENTRIES_SIZE); in ZeroEntries()
106 static void ZeroHeadersEntries(GptData *gpt) in ZeroHeadersEntries() argument
108 ZeroHeaders(gpt); in ZeroHeadersEntries()
109 ZeroEntries(gpt); in ZeroHeadersEntries()
119 static GptData gpt; in GetEmptyGptData() local
125 Memset(&gpt, 0, sizeof(gpt)); in GetEmptyGptData()
126 gpt.primary_header = primary_header; in GetEmptyGptData()
127 gpt.primary_entries = primary_entries; in GetEmptyGptData()
128 gpt.secondary_header = secondary_header; in GetEmptyGptData()
129 gpt.secondary_entries = secondary_entries; in GetEmptyGptData()
130 ZeroHeadersEntries(&gpt); in GetEmptyGptData()
133 gpt.current_kernel = CGPT_KERNEL_ENTRY_NOT_FOUND; in GetEmptyGptData()
135 return &gpt; in GetEmptyGptData()
145 static void BuildTestGptData(GptData *gpt) in BuildTestGptData() argument
152 gpt->sector_bytes = DEFAULT_SECTOR_SIZE; in BuildTestGptData()
153 gpt->streaming_drive_sectors = in BuildTestGptData()
154 gpt->gpt_drive_sectors = DEFAULT_DRIVE_SECTORS; in BuildTestGptData()
155 gpt->current_kernel = CGPT_KERNEL_ENTRY_NOT_FOUND; in BuildTestGptData()
156 gpt->valid_headers = MASK_BOTH; in BuildTestGptData()
157 gpt->valid_entries = MASK_BOTH; in BuildTestGptData()
158 gpt->modified = 0; in BuildTestGptData()
161 header = (GptHeader *)gpt->primary_header; in BuildTestGptData()
162 entries = (GptEntry *)gpt->primary_entries; in BuildTestGptData()
194 header2 = (GptHeader *)gpt->secondary_header; in BuildTestGptData()
195 entries2 = (GptEntry *)gpt->secondary_entries; in BuildTestGptData()
202 RefreshCrc32(gpt); in BuildTestGptData()
222 GptData *gpt; in TestBuildTestGptData() local
224 gpt = GetEmptyGptData(); in TestBuildTestGptData()
225 BuildTestGptData(gpt); in TestBuildTestGptData()
226 EXPECT(GPT_SUCCESS == GptInit(gpt)); in TestBuildTestGptData()
227 gpt->sector_bytes = 0; in TestBuildTestGptData()
228 EXPECT(GPT_ERROR_INVALID_SECTOR_SIZE == GptInit(gpt)); in TestBuildTestGptData()
240 GptData *gpt; in ParameterTests() local
256 gpt = GetEmptyGptData(); in ParameterTests()
258 BuildTestGptData(gpt); in ParameterTests()
259 gpt->sector_bytes = cases[i].sector_bytes; in ParameterTests()
260 gpt->streaming_drive_sectors = in ParameterTests()
261 gpt->gpt_drive_sectors = cases[i].drive_sectors; in ParameterTests()
262 EXPECT(cases[i].expected_retval == CheckParameters(gpt)); in ParameterTests()
271 GptData *gpt = GetEmptyGptData(); in HeaderCrcTest() local
272 GptHeader *h1 = (GptHeader *)gpt->primary_header; in HeaderCrcTest()
274 BuildTestGptData(gpt); in HeaderCrcTest()
278 BuildTestGptData(gpt); in HeaderCrcTest()
279 gpt->primary_header[0] ^= 0xa5; in HeaderCrcTest()
283 BuildTestGptData(gpt); in HeaderCrcTest()
284 gpt->primary_header[h1->size - 1] ^= 0x5a; in HeaderCrcTest()
288 BuildTestGptData(gpt); in HeaderCrcTest()
289 gpt->primary_header[h1->size] ^= 0x5a; in HeaderCrcTest()
298 GptData *gpt = GetEmptyGptData(); in HeaderSameTest() local
299 GptHeader *h1 = (GptHeader *)gpt->primary_header; in HeaderSameTest()
300 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in HeaderSameTest()
351 GptData *gpt = GetEmptyGptData(); in SignatureTest() local
352 GptHeader *h1 = (GptHeader *)gpt->primary_header; in SignatureTest()
353 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in SignatureTest()
356 EXPECT(1 == CheckHeader(NULL, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in SignatureTest()
359 BuildTestGptData(gpt); in SignatureTest()
362 RefreshCrc32(gpt); in SignatureTest()
363 EXPECT(1 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in SignatureTest()
364 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in SignatureTest()
376 GptData *gpt = GetEmptyGptData(); in RevisionTest() local
377 GptHeader *h1 = (GptHeader *)gpt->primary_header; in RevisionTest()
378 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in RevisionTest()
393 BuildTestGptData(gpt); in RevisionTest()
396 RefreshCrc32(gpt); in RevisionTest()
398 EXPECT(CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0) == in RevisionTest()
400 EXPECT(CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0) == in RevisionTest()
408 GptData *gpt = GetEmptyGptData(); in SizeTest() local
409 GptHeader *h1 = (GptHeader *)gpt->primary_header; in SizeTest()
410 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in SizeTest()
426 BuildTestGptData(gpt); in SizeTest()
429 RefreshCrc32(gpt); in SizeTest()
431 EXPECT(CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0) == in SizeTest()
433 EXPECT(CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0) == in SizeTest()
442 GptData *gpt = GetEmptyGptData(); in CrcFieldTest() local
443 GptHeader *h1 = (GptHeader *)gpt->primary_header; in CrcFieldTest()
444 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in CrcFieldTest()
446 BuildTestGptData(gpt); in CrcFieldTest()
450 EXPECT(1 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in CrcFieldTest()
451 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in CrcFieldTest()
453 RefreshCrc32(gpt); in CrcFieldTest()
454 EXPECT(0 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in CrcFieldTest()
455 EXPECT(0 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in CrcFieldTest()
463 GptData *gpt = GetEmptyGptData(); in ReservedFieldsTest() local
464 GptHeader *h1 = (GptHeader *)gpt->primary_header; in ReservedFieldsTest()
465 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in ReservedFieldsTest()
467 BuildTestGptData(gpt); in ReservedFieldsTest()
470 RefreshCrc32(gpt); in ReservedFieldsTest()
471 EXPECT(1 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in ReservedFieldsTest()
472 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in ReservedFieldsTest()
476 BuildTestGptData(gpt); in ReservedFieldsTest()
479 RefreshCrc32(gpt); in ReservedFieldsTest()
480 EXPECT(1 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in ReservedFieldsTest()
481 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in ReservedFieldsTest()
492 GptData *gpt = GetEmptyGptData(); in SizeOfPartitionEntryTest() local
493 GptHeader *h1 = (GptHeader *)gpt->primary_header; in SizeOfPartitionEntryTest()
494 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in SizeOfPartitionEntryTest()
510 BuildTestGptData(gpt); in SizeOfPartitionEntryTest()
517 RefreshCrc32(gpt); in SizeOfPartitionEntryTest()
519 EXPECT(CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0) == in SizeOfPartitionEntryTest()
521 EXPECT(CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0) == in SizeOfPartitionEntryTest()
534 GptData *gpt = GetEmptyGptData(); in NumberOfPartitionEntriesTest() local
535 GptHeader *h1 = (GptHeader *)gpt->primary_header; in NumberOfPartitionEntriesTest()
536 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in NumberOfPartitionEntriesTest()
538 BuildTestGptData(gpt); in NumberOfPartitionEntriesTest()
543 RefreshCrc32(gpt); in NumberOfPartitionEntriesTest()
544 EXPECT(1 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in NumberOfPartitionEntriesTest()
545 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in NumberOfPartitionEntriesTest()
547 …EXPECT(0 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, GPT_FLAG_EXTE… in NumberOfPartitionEntriesTest()
548 …EXPECT(0 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, GPT_FLAG_EXTE… in NumberOfPartitionEntriesTest()
557 GptData *gpt = GetEmptyGptData(); in MyLbaTest() local
558 GptHeader *h1 = (GptHeader *)gpt->primary_header; in MyLbaTest()
559 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in MyLbaTest()
562 BuildTestGptData(gpt); in MyLbaTest()
563 EXPECT(1 == CheckHeader(h1, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
564 EXPECT(1 == CheckHeader(h2, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
566 BuildTestGptData(gpt); in MyLbaTest()
569 RefreshCrc32(gpt); in MyLbaTest()
570 EXPECT(1 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
571 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
573 BuildTestGptData(gpt); in MyLbaTest()
576 RefreshCrc32(gpt); in MyLbaTest()
577 EXPECT(1 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
578 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
581 BuildTestGptData(gpt); in MyLbaTest()
584 RefreshCrc32(gpt); in MyLbaTest()
585 EXPECT(0 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
586 EXPECT(0 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
588 BuildTestGptData(gpt); in MyLbaTest()
591 RefreshCrc32(gpt); in MyLbaTest()
592 EXPECT(0 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
593 EXPECT(0 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
595 BuildTestGptData(gpt); in MyLbaTest()
598 RefreshCrc32(gpt); in MyLbaTest()
603 EXPECT(0 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
608 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
610 BuildTestGptData(gpt); in MyLbaTest()
613 RefreshCrc32(gpt); in MyLbaTest()
614 EXPECT(1 == CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
615 EXPECT(1 == CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0)); in MyLbaTest()
627 GptData *gpt = GetEmptyGptData(); in FirstUsableLbaAndLastUsableLbaTest() local
628 GptHeader *h1 = (GptHeader *)gpt->primary_header; in FirstUsableLbaAndLastUsableLbaTest()
629 GptHeader *h2 = (GptHeader *)gpt->secondary_header; in FirstUsableLbaAndLastUsableLbaTest()
655 BuildTestGptData(gpt); in FirstUsableLbaAndLastUsableLbaTest()
662 RefreshCrc32(gpt); in FirstUsableLbaAndLastUsableLbaTest()
664 EXPECT(CheckHeader(h1, 0, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0) == in FirstUsableLbaAndLastUsableLbaTest()
666 EXPECT(CheckHeader(h2, 1, gpt->streaming_drive_sectors, gpt->gpt_drive_sectors, 0) == in FirstUsableLbaAndLastUsableLbaTest()
679 GptData *gpt = GetEmptyGptData(); in EntriesCrcTest() local
680 GptHeader *h1 = (GptHeader *)gpt->primary_header; in EntriesCrcTest()
681 GptEntry *e1 = (GptEntry *)(gpt->primary_entries); in EntriesCrcTest()
682 GptEntry *e2 = (GptEntry *)(gpt->secondary_entries); in EntriesCrcTest()
685 BuildTestGptData(gpt); in EntriesCrcTest()
688 gpt->primary_entries[0] ^= 0xa5; /* just XOR a non-zero value */ in EntriesCrcTest()
689 gpt->secondary_entries[TOTAL_ENTRIES_SIZE-1] ^= 0x5a; in EntriesCrcTest()
705 GptData *gpt = GetEmptyGptData(); in ValidEntryTest() local
706 GptHeader *h1 = (GptHeader *)gpt->primary_header; in ValidEntryTest()
707 GptEntry *e1 = (GptEntry *)(gpt->primary_entries); in ValidEntryTest()
710 BuildTestGptData(gpt); in ValidEntryTest()
712 RefreshCrc32(gpt); in ValidEntryTest()
716 BuildTestGptData(gpt); in ValidEntryTest()
718 RefreshCrc32(gpt); in ValidEntryTest()
722 BuildTestGptData(gpt); in ValidEntryTest()
724 RefreshCrc32(gpt); in ValidEntryTest()
728 BuildTestGptData(gpt); in ValidEntryTest()
731 RefreshCrc32(gpt); in ValidEntryTest()
739 GptData *gpt = GetEmptyGptData(); in OverlappedPartitionTest() local
740 GptHeader *h = (GptHeader *)gpt->primary_header; in OverlappedPartitionTest()
741 GptEntry *e = (GptEntry *)gpt->primary_entries; in OverlappedPartitionTest()
793 BuildTestGptData(gpt); in OverlappedPartitionTest()
794 ZeroEntries(gpt); in OverlappedPartitionTest()
806 RefreshCrc32(gpt); in OverlappedPartitionTest()
816 GptData *gpt = GetEmptyGptData(); in SanityCheckTest() local
817 GptHeader *h1 = (GptHeader *)gpt->primary_header; in SanityCheckTest()
818 GptEntry *e1 = (GptEntry *)gpt->primary_entries; in SanityCheckTest()
822 BuildTestGptData(gpt); in SanityCheckTest()
823 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
824 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
825 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
827 GptRepair(gpt); in SanityCheckTest()
828 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
829 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
830 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
831 EXPECT(0 == gpt->modified); in SanityCheckTest()
834 BuildTestGptData(gpt); in SanityCheckTest()
835 gpt->sector_bytes = 1024; in SanityCheckTest()
836 EXPECT(GPT_ERROR_INVALID_SECTOR_SIZE == GptSanityCheck(gpt)); in SanityCheckTest()
839 BuildTestGptData(gpt); in SanityCheckTest()
840 gpt->primary_header[0]++; in SanityCheckTest()
841 gpt->secondary_header[0]++; in SanityCheckTest()
842 EXPECT(GPT_ERROR_INVALID_HEADERS == GptSanityCheck(gpt)); in SanityCheckTest()
843 EXPECT(0 == gpt->valid_headers); in SanityCheckTest()
844 EXPECT(0 == gpt->valid_entries); in SanityCheckTest()
846 GptRepair(gpt); in SanityCheckTest()
847 EXPECT(GPT_ERROR_INVALID_HEADERS == GptSanityCheck(gpt)); in SanityCheckTest()
848 EXPECT(0 == gpt->valid_headers); in SanityCheckTest()
849 EXPECT(0 == gpt->valid_entries); in SanityCheckTest()
850 EXPECT(0 == gpt->modified); in SanityCheckTest()
852 BuildTestGptData(gpt); in SanityCheckTest()
853 gpt->primary_header[0]++; in SanityCheckTest()
854 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
855 EXPECT(MASK_SECONDARY == gpt->valid_headers); in SanityCheckTest()
856 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
857 GptRepair(gpt); in SanityCheckTest()
858 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
859 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
860 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
861 EXPECT(GPT_MODIFIED_HEADER1 == gpt->modified); in SanityCheckTest()
863 BuildTestGptData(gpt); in SanityCheckTest()
864 gpt->secondary_header[0]++; in SanityCheckTest()
865 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
866 EXPECT(MASK_PRIMARY == gpt->valid_headers); in SanityCheckTest()
867 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
868 GptRepair(gpt); in SanityCheckTest()
869 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
870 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
871 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
872 EXPECT(GPT_MODIFIED_HEADER2 == gpt->modified); in SanityCheckTest()
878 BuildTestGptData(gpt); in SanityCheckTest()
880 RefreshCrc32(gpt); in SanityCheckTest()
881 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
882 EXPECT(MASK_PRIMARY == gpt->valid_headers); in SanityCheckTest()
883 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
884 GptRepair(gpt); in SanityCheckTest()
885 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
886 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
887 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
888 EXPECT(GPT_MODIFIED_HEADER2 == gpt->modified); in SanityCheckTest()
891 BuildTestGptData(gpt); in SanityCheckTest()
892 gpt->primary_entries[0]++; in SanityCheckTest()
893 gpt->secondary_entries[0]++; in SanityCheckTest()
894 EXPECT(GPT_ERROR_INVALID_ENTRIES == GptSanityCheck(gpt)); in SanityCheckTest()
895 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
896 EXPECT(MASK_NONE == gpt->valid_entries); in SanityCheckTest()
898 GptRepair(gpt); in SanityCheckTest()
899 EXPECT(GPT_ERROR_INVALID_ENTRIES == GptSanityCheck(gpt)); in SanityCheckTest()
900 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
901 EXPECT(MASK_NONE == gpt->valid_entries); in SanityCheckTest()
902 EXPECT(0 == gpt->modified); in SanityCheckTest()
904 BuildTestGptData(gpt); in SanityCheckTest()
905 gpt->primary_entries[0]++; in SanityCheckTest()
906 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
907 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
908 EXPECT(MASK_SECONDARY == gpt->valid_entries); in SanityCheckTest()
909 GptRepair(gpt); in SanityCheckTest()
910 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
911 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
912 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
913 EXPECT(GPT_MODIFIED_ENTRIES1 == gpt->modified); in SanityCheckTest()
915 BuildTestGptData(gpt); in SanityCheckTest()
916 gpt->secondary_entries[0]++; in SanityCheckTest()
917 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
918 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
919 EXPECT(MASK_PRIMARY == gpt->valid_entries); in SanityCheckTest()
920 GptRepair(gpt); in SanityCheckTest()
921 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
922 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
923 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
924 EXPECT(GPT_MODIFIED_ENTRIES2 == gpt->modified); in SanityCheckTest()
932 BuildTestGptData(gpt); in SanityCheckTest()
934 RefreshCrc32(gpt); in SanityCheckTest()
935 tempptr = gpt->primary_entries; in SanityCheckTest()
936 gpt->primary_entries = gpt->secondary_entries; in SanityCheckTest()
937 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
938 EXPECT(MASK_SECONDARY == gpt->valid_headers); in SanityCheckTest()
939 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
940 gpt->primary_entries = tempptr; in SanityCheckTest()
943 BuildTestGptData(gpt); in SanityCheckTest()
944 gpt->primary_header[0]++; in SanityCheckTest()
945 gpt->primary_entries[0]++; in SanityCheckTest()
946 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
947 EXPECT(MASK_SECONDARY == gpt->valid_headers); in SanityCheckTest()
948 EXPECT(MASK_SECONDARY == gpt->valid_entries); in SanityCheckTest()
949 GptRepair(gpt); in SanityCheckTest()
950 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
951 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
952 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
953 EXPECT((GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1) == gpt->modified); in SanityCheckTest()
955 BuildTestGptData(gpt); in SanityCheckTest()
956 gpt->secondary_header[0]++; in SanityCheckTest()
957 gpt->secondary_entries[0]++; in SanityCheckTest()
958 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
959 EXPECT(MASK_PRIMARY == gpt->valid_headers); in SanityCheckTest()
960 EXPECT(MASK_PRIMARY == gpt->valid_entries); in SanityCheckTest()
961 GptRepair(gpt); in SanityCheckTest()
962 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
963 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
964 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
965 EXPECT((GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2) == gpt->modified); in SanityCheckTest()
968 BuildTestGptData(gpt); in SanityCheckTest()
969 gpt->primary_header[0]++; in SanityCheckTest()
970 gpt->secondary_entries[0]++; in SanityCheckTest()
971 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
972 EXPECT(MASK_SECONDARY == gpt->valid_headers); in SanityCheckTest()
973 EXPECT(MASK_PRIMARY == gpt->valid_entries); in SanityCheckTest()
974 GptRepair(gpt); in SanityCheckTest()
975 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
976 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
977 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
978 EXPECT((GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES2) == gpt->modified); in SanityCheckTest()
980 BuildTestGptData(gpt); in SanityCheckTest()
981 gpt->secondary_header[0]++; in SanityCheckTest()
982 gpt->primary_entries[0]++; in SanityCheckTest()
983 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
984 EXPECT(MASK_PRIMARY == gpt->valid_headers); in SanityCheckTest()
985 EXPECT(MASK_SECONDARY == gpt->valid_entries); in SanityCheckTest()
986 GptRepair(gpt); in SanityCheckTest()
987 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
988 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
989 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
990 EXPECT((GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES1) == gpt->modified); in SanityCheckTest()
996 BuildTestGptData(gpt); in SanityCheckTest()
997 gpt->secondary_entries[0]++; in SanityCheckTest()
998 RefreshCrc32(gpt); in SanityCheckTest()
999 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
1000 EXPECT(MASK_PRIMARY == gpt->valid_headers); in SanityCheckTest()
1001 EXPECT(MASK_PRIMARY == gpt->valid_entries); in SanityCheckTest()
1002 GptRepair(gpt); in SanityCheckTest()
1003 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
1004 EXPECT(MASK_BOTH == gpt->valid_headers); in SanityCheckTest()
1005 EXPECT(MASK_BOTH == gpt->valid_entries); in SanityCheckTest()
1006 EXPECT((GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2) == gpt->modified); in SanityCheckTest()
1009 gpt = GetEmptyGptData(); in SanityCheckTest()
1010 BuildTestGptData(gpt); in SanityCheckTest()
1011 gpt->primary_entries = NULL; in SanityCheckTest()
1012 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
1013 EXPECT(MASK_SECONDARY == gpt->valid_entries); in SanityCheckTest()
1014 gpt = GetEmptyGptData(); in SanityCheckTest()
1015 BuildTestGptData(gpt); in SanityCheckTest()
1016 gpt->secondary_entries = NULL; in SanityCheckTest()
1017 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
1018 EXPECT(MASK_PRIMARY == gpt->valid_entries); in SanityCheckTest()
1021 gpt = GetEmptyGptData(); in SanityCheckTest()
1022 BuildTestGptData(gpt); in SanityCheckTest()
1023 gpt->primary_header = NULL; in SanityCheckTest()
1024 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
1025 EXPECT(MASK_SECONDARY == gpt->valid_headers); in SanityCheckTest()
1026 gpt = GetEmptyGptData(); in SanityCheckTest()
1027 BuildTestGptData(gpt); in SanityCheckTest()
1028 gpt->secondary_header = NULL; in SanityCheckTest()
1029 EXPECT(GPT_SUCCESS == GptSanityCheck(gpt)); in SanityCheckTest()
1030 EXPECT(MASK_PRIMARY == gpt->valid_headers); in SanityCheckTest()
1037 GptData *gpt = GetEmptyGptData(); in EntryAttributeGetSetTest() local
1038 GptEntry *e = (GptEntry *)(gpt->primary_entries); in EntryAttributeGetSetTest()
1082 GptData *gpt = GetEmptyGptData(); in EntryTypeTest() local
1083 GptEntry *e = (GptEntry *)(gpt->primary_entries); in EntryTypeTest()
1122 GptData *gpt = GetEmptyGptData(); in NoValidKernelEntryTest() local
1123 GptEntry *e1 = (GptEntry *)(gpt->primary_entries); in NoValidKernelEntryTest()
1125 BuildTestGptData(gpt); in NoValidKernelEntryTest()
1128 RefreshCrc32(gpt); in NoValidKernelEntryTest()
1130 GptNextKernelEntry(gpt, NULL, NULL)); in NoValidKernelEntryTest()
1137 GptData *gpt = GetEmptyGptData(); in GetNextNormalTest() local
1138 GptEntry *e1 = (GptEntry *)(gpt->primary_entries); in GetNextNormalTest()
1142 BuildTestGptData(gpt); in GetNextNormalTest()
1145 RefreshCrc32(gpt); in GetNextNormalTest()
1146 GptInit(gpt); in GetNextNormalTest()
1148 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GetNextNormalTest()
1149 EXPECT(KERNEL_A == gpt->current_kernel); in GetNextNormalTest()
1153 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GetNextNormalTest()
1154 EXPECT(KERNEL_B == gpt->current_kernel); in GetNextNormalTest()
1159 GptNextKernelEntry(gpt, &start, &size)); in GetNextNormalTest()
1160 EXPECT(-1 == gpt->current_kernel); in GetNextNormalTest()
1164 GptNextKernelEntry(gpt, &start, &size)); in GetNextNormalTest()
1165 EXPECT(-1 == gpt->current_kernel); in GetNextNormalTest()
1172 GptData *gpt = GetEmptyGptData(); in GetNextPrioTest() local
1173 GptEntry *e1 = (GptEntry *)(gpt->primary_entries); in GetNextPrioTest()
1177 BuildTestGptData(gpt); in GetNextPrioTest()
1182 RefreshCrc32(gpt); in GetNextPrioTest()
1183 GptInit(gpt); in GetNextPrioTest()
1185 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GetNextPrioTest()
1186 EXPECT(KERNEL_B == gpt->current_kernel); in GetNextPrioTest()
1187 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GetNextPrioTest()
1188 EXPECT(KERNEL_Y == gpt->current_kernel); in GetNextPrioTest()
1189 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GetNextPrioTest()
1190 EXPECT(KERNEL_A == gpt->current_kernel); in GetNextPrioTest()
1192 GptNextKernelEntry(gpt, &start, &size)); in GetNextPrioTest()
1199 GptData *gpt = GetEmptyGptData(); in GetNextTriesTest() local
1200 GptEntry *e1 = (GptEntry *)(gpt->primary_entries); in GetNextTriesTest()
1204 BuildTestGptData(gpt); in GetNextTriesTest()
1209 RefreshCrc32(gpt); in GetNextTriesTest()
1210 GptInit(gpt); in GetNextTriesTest()
1212 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GetNextTriesTest()
1213 EXPECT(KERNEL_X == gpt->current_kernel); in GetNextTriesTest()
1214 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GetNextTriesTest()
1215 EXPECT(KERNEL_A == gpt->current_kernel); in GetNextTriesTest()
1217 GptNextKernelEntry(gpt, &start, &size)); in GetNextTriesTest()
1224 GptData *gpt = GetEmptyGptData(); in GptUpdateTest() local
1225 GptEntry *e = (GptEntry *)(gpt->primary_entries); in GptUpdateTest()
1226 GptEntry *e2 = (GptEntry *)(gpt->secondary_entries); in GptUpdateTest()
1230 BuildTestGptData(gpt); in GptUpdateTest()
1234 RefreshCrc32(gpt); in GptUpdateTest()
1235 GptInit(gpt); in GptUpdateTest()
1236 gpt->modified = 0; /* Nothing modified yet */ in GptUpdateTest()
1239 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GptUpdateTest()
1240 EXPECT(KERNEL_A == gpt->current_kernel); in GptUpdateTest()
1248 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); in GptUpdateTest()
1252 EXPECT(0 == gpt->modified); in GptUpdateTest()
1254 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); in GptUpdateTest()
1258 EXPECT(0 == gpt->modified); in GptUpdateTest()
1261 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GptUpdateTest()
1262 EXPECT(KERNEL_B == gpt->current_kernel); in GptUpdateTest()
1267 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); in GptUpdateTest()
1276 EXPECT(0x0F == gpt->modified); in GptUpdateTest()
1279 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); in GptUpdateTest()
1280 EXPECT(KERNEL_X == gpt->current_kernel); in GptUpdateTest()
1285 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); in GptUpdateTest()
1293 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); in GptUpdateTest()
1301 GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); in GptUpdateTest()
1302 gpt->current_kernel = CGPT_KERNEL_ENTRY_NOT_FOUND; in GptUpdateTest()
1304 GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); in GptUpdateTest()
1316 GptData *gpt = GetEmptyGptData(); in UpdateInvalidKernelTypeTest() local
1318 BuildTestGptData(gpt); in UpdateInvalidKernelTypeTest()
1320 gpt->current_kernel = 0; in UpdateInvalidKernelTypeTest()
1323 GptUpdateKernelEntry(gpt, 99)); in UpdateInvalidKernelTypeTest()
1331 GptData *gpt = GetEmptyGptData(); in DuplicateUniqueGuidTest() local
1332 GptHeader *h = (GptHeader *)gpt->primary_header; in DuplicateUniqueGuidTest()
1333 GptEntry *e = (GptEntry *)gpt->primary_entries; in DuplicateUniqueGuidTest()
1368 BuildTestGptData(gpt); in DuplicateUniqueGuidTest()
1369 ZeroEntries(gpt); in DuplicateUniqueGuidTest()
1379 RefreshCrc32(gpt); in DuplicateUniqueGuidTest()
1390 GptData *gpt = GetEmptyGptData(); in GetKernelGuidTest() local
1391 GptEntry *e = (GptEntry *)gpt->primary_entries; in GetKernelGuidTest()
1394 BuildTestGptData(gpt); in GetKernelGuidTest()
1395 gpt->current_kernel = 0; in GetKernelGuidTest()
1396 GetCurrentKernelUniqueGuid(gpt, &g); in GetKernelGuidTest()
1398 gpt->current_kernel = 1; in GetKernelGuidTest()
1399 GetCurrentKernelUniqueGuid(gpt, &g); in GetKernelGuidTest()
1424 GptData* gpt = GetEmptyGptData(); in CheckHeaderOffDevice() local
1425 BuildTestGptData(gpt); in CheckHeaderOffDevice()
1427 GptHeader* primary_header = (GptHeader*)gpt->primary_header; in CheckHeaderOffDevice()
1429 RefreshCrc32(gpt); in CheckHeaderOffDevice()
1432 EXPECT(1 == CheckHeader(primary_header, 0, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1433 gpt->gpt_drive_sectors, 0)); in CheckHeaderOffDevice()
1435 EXPECT(0 == CheckHeader(primary_header, 0, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1436 gpt->gpt_drive_sectors, GPT_FLAG_EXTERNAL)); in CheckHeaderOffDevice()
1438 BuildTestGptData(gpt); in CheckHeaderOffDevice()
1440 RefreshCrc32(gpt); in CheckHeaderOffDevice()
1442 EXPECT(1 == CheckHeader(primary_header, 0, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1443 gpt->gpt_drive_sectors, 0)); in CheckHeaderOffDevice()
1445 EXPECT(0 == CheckHeader(primary_header, 0, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1446 gpt->gpt_drive_sectors, GPT_FLAG_EXTERNAL)); in CheckHeaderOffDevice()
1449 RefreshCrc32(gpt); in CheckHeaderOffDevice()
1451 EXPECT(1 == CheckHeader(primary_header, 0, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1452 gpt->gpt_drive_sectors, GPT_FLAG_EXTERNAL)); in CheckHeaderOffDevice()
1455 BuildTestGptData(gpt); in CheckHeaderOffDevice()
1456 GptHeader* secondary_header = (GptHeader*)gpt->secondary_header; in CheckHeaderOffDevice()
1458 RefreshCrc32(gpt); in CheckHeaderOffDevice()
1459 EXPECT(1 == CheckHeader(secondary_header, 1, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1460 gpt->gpt_drive_sectors, 0)); in CheckHeaderOffDevice()
1461 EXPECT(0 == CheckHeader(secondary_header, 1, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1462 gpt->gpt_drive_sectors, GPT_FLAG_EXTERNAL)); in CheckHeaderOffDevice()
1464 BuildTestGptData(gpt); in CheckHeaderOffDevice()
1469 RefreshCrc32(gpt); in CheckHeaderOffDevice()
1470 EXPECT(1 == CheckHeader(secondary_header, 1, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1471 gpt->gpt_drive_sectors, 0)); in CheckHeaderOffDevice()
1472 EXPECT(0 == CheckHeader(secondary_header, 1, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1473 gpt->gpt_drive_sectors, GPT_FLAG_EXTERNAL)); in CheckHeaderOffDevice()
1476 RefreshCrc32(gpt); in CheckHeaderOffDevice()
1477 EXPECT(1 == CheckHeader(secondary_header, 1, gpt->streaming_drive_sectors, in CheckHeaderOffDevice()
1478 gpt->gpt_drive_sectors, GPT_FLAG_EXTERNAL)); in CheckHeaderOffDevice()