OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 #include "cgpt_test.h" | 6 #include "cgpt_test.h" |
7 #include <string.h> | 7 #include <string.h> |
8 #include "cgpt.h" | 8 #include "cgpt.h" |
9 #include "cgpt_internal.h" | 9 #include "cgpt_internal.h" |
10 #include "crc32.h" | 10 #include "crc32.h" |
11 #include "gpt.h" | 11 #include "gpt.h" |
12 #include "quick_sort_test.h" | 12 #include "quick_sort_test.h" |
13 #include "utility.h" | 13 #include "utility.h" |
14 | 14 |
15 /* Testing partition layout (sector_bytes=512) | 15 /* Testing partition layout (sector_bytes=512) |
16 * | 16 * |
17 * LBA Size Usage | 17 * LBA Size Usage |
| 18 * --------------------------------------------------------- |
18 * 0 1 PMBR | 19 * 0 1 PMBR |
19 * 1 1 primary partition header | 20 * 1 1 primary partition header |
20 * 2 32 primary partition entries (128B * 128) | 21 * 2 32 primary partition entries (128B * 128) |
21 * 34 100 kernel A | 22 * 34 100 kernel A (index: 0) |
22 * 134 100 kernel B | 23 * 134 100 root A (index: 1) |
23 * 234 100 root A | 24 * 234 100 root B (index: 2) |
24 * 334 100 root B | 25 * 334 100 kernel B (index: 3) |
25 * 434 32 secondary partition entries | 26 * 434 32 secondary partition entries |
26 * 466 1 secondary partition header | 27 * 466 1 secondary partition header |
27 * 467 | 28 * 467 |
28 */ | 29 */ |
| 30 #define KERNEL_A 0 |
| 31 #define ROOTFS_A 1 |
| 32 #define ROOTFS_B 2 |
| 33 #define KERNEL_B 3 |
| 34 |
29 #define DEFAULT_SECTOR_SIZE 512 | 35 #define DEFAULT_SECTOR_SIZE 512 |
30 #define MAX_SECTOR_SIZE 4096 | 36 #define MAX_SECTOR_SIZE 4096 |
31 #define DEFAULT_DRIVE_SECTORS 467 | 37 #define DEFAULT_DRIVE_SECTORS 467 |
32 #define PARTITION_ENTRIES_SIZE TOTAL_ENTRIES_SIZE /* 16384 */ | 38 #define PARTITION_ENTRIES_SIZE TOTAL_ENTRIES_SIZE /* 16384 */ |
33 | 39 |
34 /* Given a GptData pointer, first re-calculate entries CRC32 value, | 40 /* Given a GptData pointer, first re-calculate entries CRC32 value, |
35 * then reset header CRC32 value to 0, and calculate header CRC32 value. | 41 * then reset header CRC32 value to 0, and calculate header CRC32 value. |
36 * Both primary and secondary are updated. */ | 42 * Both primary and secondary are updated. */ |
37 void RefreshCrc32(GptData *gpt) { | 43 void RefreshCrc32(GptData *gpt) { |
38 GptHeader *header, *header2; | 44 GptHeader *header, *header2; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 static uint8_t secondary_header[MAX_SECTOR_SIZE]; | 86 static uint8_t secondary_header[MAX_SECTOR_SIZE]; |
81 static uint8_t secondary_entries[PARTITION_ENTRIES_SIZE]; | 87 static uint8_t secondary_entries[PARTITION_ENTRIES_SIZE]; |
82 | 88 |
83 Memset(&gpt, 0, sizeof(gpt)); | 89 Memset(&gpt, 0, sizeof(gpt)); |
84 gpt.primary_header = primary_header; | 90 gpt.primary_header = primary_header; |
85 gpt.primary_entries = primary_entries; | 91 gpt.primary_entries = primary_entries; |
86 gpt.secondary_header = secondary_header; | 92 gpt.secondary_header = secondary_header; |
87 gpt.secondary_entries = secondary_entries; | 93 gpt.secondary_entries = secondary_entries; |
88 ZeroHeadersEntries(&gpt); | 94 ZeroHeadersEntries(&gpt); |
89 | 95 |
| 96 /* Initialize GptData internal states. */ |
| 97 gpt.current_kernel = CGPT_KERNEL_ENTRY_NOT_FOUND; |
| 98 |
90 return &gpt; | 99 return &gpt; |
91 } | 100 } |
92 | 101 |
93 /* Fills in most of fields and creates the layout described in the top of this | 102 /* Fills in most of fields and creates the layout described in the top of this |
94 * file. Before calling this function, primary/secondary header/entries must | 103 * file. Before calling this function, primary/secondary header/entries must |
95 * have been pointed to the buffer, say, a gpt returned from GetEmptyGptData(). | 104 * have been pointed to the buffer, say, a gpt returned from GetEmptyGptData(). |
96 * This function returns a good (valid) copy of GPT layout described in top of | 105 * This function returns a good (valid) copy of GPT layout described in top of |
97 * this file. */ | 106 * this file. */ |
98 void BuildTestGptData(GptData *gpt) { | 107 void BuildTestGptData(GptData *gpt) { |
99 GptHeader *header, *header2; | 108 GptHeader *header, *header2; |
100 GptEntry *entries, *entries2; | 109 GptEntry *entries, *entries2; |
101 Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL; | 110 Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL; |
| 111 Guid chromeos_rootfs = GPT_ENT_TYPE_CHROMEOS_ROOTFS; |
102 | 112 |
103 gpt->sector_bytes = DEFAULT_SECTOR_SIZE; | 113 gpt->sector_bytes = DEFAULT_SECTOR_SIZE; |
104 gpt->drive_sectors = DEFAULT_DRIVE_SECTORS; | 114 gpt->drive_sectors = DEFAULT_DRIVE_SECTORS; |
| 115 gpt->current_kernel = CGPT_KERNEL_ENTRY_NOT_FOUND; |
105 | 116 |
106 /* build primary */ | 117 /* build primary */ |
107 header = (GptHeader*)gpt->primary_header; | 118 header = (GptHeader*)gpt->primary_header; |
108 entries = (GptEntry*)gpt->primary_entries; | 119 entries = (GptEntry*)gpt->primary_entries; |
109 Memcpy(header->signature, GPT_HEADER_SIGNATURE, sizeof(GPT_HEADER_SIGNATURE)); | 120 Memcpy(header->signature, GPT_HEADER_SIGNATURE, sizeof(GPT_HEADER_SIGNATURE)); |
110 header->revision = GPT_HEADER_REVISION; | 121 header->revision = GPT_HEADER_REVISION; |
111 header->size = sizeof(GptHeader) - sizeof(header->padding); | 122 header->size = sizeof(GptHeader) - sizeof(header->padding); |
112 header->reserved = 0; | 123 header->reserved = 0; |
113 header->my_lba = 1; | 124 header->my_lba = 1; |
114 header->first_usable_lba = 34; | 125 header->first_usable_lba = 34; |
115 header->last_usable_lba = DEFAULT_DRIVE_SECTORS - 1 - 32 - 1; /* 433 */ | 126 header->last_usable_lba = DEFAULT_DRIVE_SECTORS - 1 - 32 - 1; /* 433 */ |
116 header->entries_lba = 2; | 127 header->entries_lba = 2; |
117 header->number_of_entries = 128; /* 512B / 128B * 32sectors = 128 entries */ | 128 header->number_of_entries = 128; /* 512B / 128B * 32sectors = 128 entries */ |
118 header->size_of_entry = 128; /* bytes */ | 129 header->size_of_entry = 128; /* bytes */ |
119 Memcpy(&entries[0].type, &chromeos_kernel, sizeof(chromeos_kernel)); | 130 Memcpy(&entries[0].type, &chromeos_kernel, sizeof(chromeos_kernel)); |
120 entries[0].starting_lba = 34; | 131 entries[0].starting_lba = 34; |
121 entries[0].ending_lba = 133; | 132 entries[0].ending_lba = 133; |
122 Memcpy(&entries[1].type, &chromeos_kernel, sizeof(chromeos_kernel)); | 133 Memcpy(&entries[1].type, &chromeos_rootfs, sizeof(chromeos_rootfs)); |
123 entries[1].starting_lba = 134; | 134 entries[1].starting_lba = 134; |
124 entries[1].ending_lba = 233; | 135 entries[1].ending_lba = 233; |
125 Memcpy(&entries[2].type, &chromeos_kernel, sizeof(chromeos_kernel)); | 136 Memcpy(&entries[2].type, &chromeos_rootfs, sizeof(chromeos_rootfs)); |
126 entries[2].starting_lba = 234; | 137 entries[2].starting_lba = 234; |
127 entries[2].ending_lba = 333; | 138 entries[2].ending_lba = 333; |
128 Memcpy(&entries[3].type, &chromeos_kernel, sizeof(chromeos_kernel)); | 139 Memcpy(&entries[3].type, &chromeos_kernel, sizeof(chromeos_kernel)); |
129 entries[3].starting_lba = 334; | 140 entries[3].starting_lba = 334; |
130 entries[3].ending_lba = 433; | 141 entries[3].ending_lba = 433; |
131 header->padding = 0; | 142 header->padding = 0; |
132 | 143 |
133 /* build secondary */ | 144 /* build secondary */ |
134 header2 = (GptHeader*)gpt->secondary_header; | 145 header2 = (GptHeader*)gpt->secondary_header; |
135 entries2 = (GptEntry*)gpt->secondary_entries; | 146 entries2 = (GptEntry*)gpt->secondary_entries; |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 EXPECT(GPT_SUCCESS == GptInit(gpt)); | 892 EXPECT(GPT_SUCCESS == GptInit(gpt)); |
882 /* After header is repaired, the entries are valid actually. */ | 893 /* After header is repaired, the entries are valid actually. */ |
883 EXPECT((GPT_MODIFIED_HEADER1) == gpt->modified); | 894 EXPECT((GPT_MODIFIED_HEADER1) == gpt->modified); |
884 /* We expect the modified header/entries can pass GptInit(). */ | 895 /* We expect the modified header/entries can pass GptInit(). */ |
885 EXPECT(GPT_SUCCESS == GptInit(gpt)); | 896 EXPECT(GPT_SUCCESS == GptInit(gpt)); |
886 EXPECT(0 == gpt->modified); | 897 EXPECT(0 == gpt->modified); |
887 | 898 |
888 return TEST_OK; | 899 return TEST_OK; |
889 } | 900 } |
890 | 901 |
| 902 /* Invalidate all kernel entries and expect GptNextKernelEntry() cannot find |
| 903 * any usable kernel entry. |
| 904 */ |
| 905 int NoValidKernelEntryTest() { |
| 906 GptData *gpt; |
| 907 GptEntry *entries, *entries2; |
| 908 |
| 909 gpt = GetEmptyGptData(); |
| 910 entries = (GptEntry*)gpt->primary_entries; |
| 911 entries2 = (GptEntry*)gpt->secondary_entries; |
| 912 |
| 913 BuildTestGptData(gpt); |
| 914 entries[KERNEL_A].attributes |= CGPT_ATTRIBUTE_BAD_MASK; |
| 915 Memset(&entries[KERNEL_B].type, 0, sizeof(Guid)); |
| 916 RefreshCrc32(gpt); |
| 917 |
| 918 EXPECT(GPT_ERROR_NO_VALID_KERNEL == GptNextKernelEntry(gpt, NULL, NULL)); |
| 919 |
| 920 return TEST_OK; |
| 921 } |
| 922 |
| 923 /* This is the combination test. Both kernel A and B could be either inactive |
| 924 * or invalid. We expect GptNextKetnelEntry() returns good kernel or |
| 925 * GPT_ERROR_NO_VALID_KERNEL if no kernel is available. */ |
| 926 enum FAILURE_MASK { |
| 927 MASK_INACTIVE = 1, |
| 928 MASK_BAD_ENTRY = 2, |
| 929 MASK_FAILURE_BOTH = 3, |
| 930 }; |
| 931 void BreakAnEntry(GptEntry *entry, enum FAILURE_MASK failure) { |
| 932 if (failure & MASK_INACTIVE) |
| 933 Memset(&entry->type, 0, sizeof(Guid)); |
| 934 if (failure & MASK_BAD_ENTRY) |
| 935 entry->attributes |= CGPT_ATTRIBUTE_BAD_MASK; |
| 936 } |
| 937 |
| 938 int CombinationalNextKernelEntryTest() { |
| 939 GptData *gpt; |
| 940 enum { |
| 941 MASK_KERNEL_A = 1, |
| 942 MASK_KERNEL_B = 2, |
| 943 MASK_KERNEL_BOTH = 3, |
| 944 } kernel; |
| 945 enum FAILURE_MASK failure; |
| 946 uint64_t start_sector, size; |
| 947 int retval; |
| 948 |
| 949 for (kernel = MASK_KERNEL_A; kernel <= MASK_KERNEL_BOTH; ++kernel) { |
| 950 for (failure = MASK_INACTIVE; failure < MASK_FAILURE_BOTH; ++failure) { |
| 951 gpt = GetEmptyGptData(); |
| 952 BuildTestGptData(gpt); |
| 953 |
| 954 if (kernel & MASK_KERNEL_A) |
| 955 BreakAnEntry(GetEntry(gpt, PRIMARY, KERNEL_A), failure); |
| 956 if (kernel & MASK_KERNEL_B) |
| 957 BreakAnEntry(GetEntry(gpt, PRIMARY, KERNEL_B), failure); |
| 958 |
| 959 retval = GptNextKernelEntry(gpt, &start_sector, &size); |
| 960 |
| 961 if (kernel == MASK_KERNEL_A) { |
| 962 EXPECT(retval == GPT_SUCCESS); |
| 963 EXPECT(start_sector == 334); |
| 964 } else if (kernel == MASK_KERNEL_B) { |
| 965 EXPECT(retval == GPT_SUCCESS); |
| 966 EXPECT(start_sector == 34); |
| 967 } else { /* MASK_KERNEL_BOTH */ |
| 968 EXPECT(retval == GPT_ERROR_NO_VALID_KERNEL); |
| 969 } |
| 970 } |
| 971 } |
| 972 return TEST_OK; |
| 973 } |
| 974 |
| 975 /* Increase tries value from zero, expect it won't explode/overflow after |
| 976 * CGPT_ATTRIBUTE_TRIES_MASK. |
| 977 */ |
| 978 /* Tries would not count up after CGPT_ATTRIBUTE_MAX_TRIES. */ |
| 979 #define EXPECTED_TRIES(tries) \ |
| 980 ((tries >= CGPT_ATTRIBUTE_MAX_TRIES) ? CGPT_ATTRIBUTE_MAX_TRIES \ |
| 981 : tries) |
| 982 int IncreaseTriesTest() { |
| 983 GptData *gpt; |
| 984 int kernel_index[] = { |
| 985 KERNEL_B, |
| 986 KERNEL_A, |
| 987 }; |
| 988 int i, tries, j; |
| 989 |
| 990 gpt = GetEmptyGptData(); |
| 991 for (i = 0; i < ARRAY_SIZE(kernel_index); ++i) { |
| 992 GptEntry *entries[2] = { |
| 993 (GptEntry*)gpt->primary_entries, |
| 994 (GptEntry*)gpt->secondary_entries, |
| 995 }; |
| 996 int current; |
| 997 |
| 998 BuildTestGptData(gpt); |
| 999 current = gpt->current_kernel = kernel_index[i]; |
| 1000 |
| 1001 for (tries = 0; tries < 2 * CGPT_ATTRIBUTE_MAX_TRIES; ++tries) { |
| 1002 for (j = 0; j < ARRAY_SIZE(entries); ++j) { |
| 1003 EXPECT(EXPECTED_TRIES(tries) == |
| 1004 ((entries[j][current].attributes & CGPT_ATTRIBUTE_TRIES_MASK) >> |
| 1005 CGPT_ATTRIBUTE_TRIES_OFFSET)); |
| 1006 } |
| 1007 |
| 1008 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); |
| 1009 /* The expected tries value will be checked in next iteration. */ |
| 1010 |
| 1011 if (tries < CGPT_ATTRIBUTE_MAX_TRIES) |
| 1012 EXPECT((GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | |
| 1013 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2) == gpt->modified); |
| 1014 gpt->modified = 0; /* reset before next test */ |
| 1015 EXPECT(0 == |
| 1016 Memcmp(entries[PRIMARY], entries[SECONDARY], TOTAL_ENTRIES_SIZE)); |
| 1017 } |
| 1018 } |
| 1019 return TEST_OK; |
| 1020 } |
| 1021 |
| 1022 /* Mark a kernel as bad. Expect: |
| 1023 * 1. the both bad bits of kernel A in primary and secondary entries are set. |
| 1024 * 2. headers and entries are marked as modified. |
| 1025 * 3. primary and secondary entries are identical. |
| 1026 */ |
| 1027 int MarkBadKernelEntryTest() { |
| 1028 GptData *gpt; |
| 1029 GptEntry *entries, *entries2; |
| 1030 |
| 1031 gpt = GetEmptyGptData(); |
| 1032 entries = (GptEntry*)gpt->primary_entries; |
| 1033 entries2 = (GptEntry*)gpt->secondary_entries; |
| 1034 |
| 1035 BuildTestGptData(gpt); |
| 1036 gpt->current_kernel = KERNEL_A; |
| 1037 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); |
| 1038 EXPECT((GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | |
| 1039 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2) == gpt->modified); |
| 1040 EXPECT(entries[KERNEL_A].attributes & CGPT_ATTRIBUTE_BAD_MASK); |
| 1041 EXPECT(entries2[KERNEL_A].attributes & CGPT_ATTRIBUTE_BAD_MASK); |
| 1042 EXPECT(0 == Memcmp(entries, entries2, TOTAL_ENTRIES_SIZE)); |
| 1043 |
| 1044 return TEST_OK; |
| 1045 } |
| 1046 |
| 1047 /* Given an invalid kernel type, and expect GptUpdateKernelEntry() returns |
| 1048 * GPT_ERROR_INVALID_UPDATE_TYPE. */ |
| 1049 int UpdateInvalidKernelTypeTest() { |
| 1050 GptData *gpt; |
| 1051 |
| 1052 gpt = GetEmptyGptData(); |
| 1053 BuildTestGptData(gpt); |
| 1054 gpt->current_kernel = 0; /* anything, but not CGPT_KERNEL_ENTRY_NOT_FOUND */ |
| 1055 EXPECT(GPT_ERROR_INVALID_UPDATE_TYPE == |
| 1056 GptUpdateKernelEntry(gpt, 99)); /* any invalid update_type value */ |
| 1057 |
| 1058 return TEST_OK; |
| 1059 } |
| 1060 |
| 1061 /* A normal boot case: |
| 1062 * GptInit() |
| 1063 * GptNextKernelEntry() |
| 1064 * GptUpdateKernelEntry() |
| 1065 */ |
| 1066 int NormalBootCase() { |
| 1067 GptData *gpt; |
| 1068 GptEntry *entries; |
| 1069 uint64_t start_sector, size; |
| 1070 |
| 1071 gpt = GetEmptyGptData(); |
| 1072 entries = (GptEntry*)gpt->primary_entries; |
| 1073 BuildTestGptData(gpt); |
| 1074 |
| 1075 EXPECT(GPT_SUCCESS == GptInit(gpt)); |
| 1076 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start_sector, &size)); |
| 1077 EXPECT(start_sector == 34); /* Kernel A, see top of this file. */ |
| 1078 EXPECT(size == 100); |
| 1079 |
| 1080 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); |
| 1081 EXPECT(((entries[KERNEL_A].attributes & CGPT_ATTRIBUTE_TRIES_MASK) >> |
| 1082 CGPT_ATTRIBUTE_TRIES_OFFSET) == 1); |
| 1083 |
| 1084 return TEST_OK; |
| 1085 } |
| 1086 |
| 1087 /* Higher priority kernel should boot first. |
| 1088 * KERNEL_A is low priority |
| 1089 * KERNEL_B is high priority. |
| 1090 * We expect KERNEL_B is selected in first run, and then KERNEL_A. |
| 1091 * We also expect the GptNextKernelEntry() wraps back to KERNEL_B if it's called |
| 1092 * after twice. |
| 1093 */ |
| 1094 int HigherPriorityTest() { |
| 1095 GptData *gpt; |
| 1096 GptEntry *entries; |
| 1097 |
| 1098 gpt = GetEmptyGptData(); |
| 1099 entries = (GptEntry*)gpt->primary_entries; |
| 1100 BuildTestGptData(gpt); |
| 1101 |
| 1102 SetPriority(gpt, PRIMARY, KERNEL_A, 0); |
| 1103 SetPriority(gpt, PRIMARY, KERNEL_B, 1); |
| 1104 RefreshCrc32(gpt); |
| 1105 |
| 1106 EXPECT(GPT_SUCCESS == GptInit(gpt)); |
| 1107 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, NULL, NULL)); |
| 1108 EXPECT(KERNEL_B == gpt->current_kernel); |
| 1109 |
| 1110 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, NULL, NULL)); |
| 1111 EXPECT(KERNEL_A == gpt->current_kernel); |
| 1112 |
| 1113 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, NULL, NULL)); |
| 1114 EXPECT(KERNEL_B == gpt->current_kernel); |
| 1115 |
| 1116 return TEST_OK; |
| 1117 } |
| 1118 |
891 int main(int argc, char *argv[]) { | 1119 int main(int argc, char *argv[]) { |
892 int i; | 1120 int i; |
893 int error_count = 0; | 1121 int error_count = 0; |
894 struct { | 1122 struct { |
895 char *name; | 1123 char *name; |
896 test_func fp; | 1124 test_func fp; |
897 int retval; | 1125 int retval; |
898 } test_cases[] = { | 1126 } test_cases[] = { |
899 { TEST_CASE(TestBuildTestGptData), }, | 1127 { TEST_CASE(TestBuildTestGptData), }, |
900 { TEST_CASE(ParameterTests), }, | 1128 { TEST_CASE(ParameterTests), }, |
901 { TEST_CASE(SignatureTest), }, | 1129 { TEST_CASE(SignatureTest), }, |
902 { TEST_CASE(RevisionTest), }, | 1130 { TEST_CASE(RevisionTest), }, |
903 { TEST_CASE(SizeTest), }, | 1131 { TEST_CASE(SizeTest), }, |
904 { TEST_CASE(ReservedFieldsTest), }, | 1132 { TEST_CASE(ReservedFieldsTest), }, |
905 { TEST_CASE(MyLbaTest), }, | 1133 { TEST_CASE(MyLbaTest), }, |
906 { TEST_CASE(SizeOfPartitionEntryTest), }, | 1134 { TEST_CASE(SizeOfPartitionEntryTest), }, |
907 { TEST_CASE(NumberOfPartitionEntriesTest), }, | 1135 { TEST_CASE(NumberOfPartitionEntriesTest), }, |
908 { TEST_CASE(PartitionEntryLbaTest), }, | 1136 { TEST_CASE(PartitionEntryLbaTest), }, |
909 { TEST_CASE(FirstUsableLbaAndLastUsableLbaTest), }, | 1137 { TEST_CASE(FirstUsableLbaAndLastUsableLbaTest), }, |
910 { TEST_CASE(HeaderCrcTest), }, | 1138 { TEST_CASE(HeaderCrcTest), }, |
911 { TEST_CASE(EntriesCrcTest), }, | 1139 { TEST_CASE(EntriesCrcTest), }, |
912 { TEST_CASE(IdenticalEntriesTest), }, | 1140 { TEST_CASE(IdenticalEntriesTest), }, |
913 { TEST_CASE(SynonymousHeaderTest), }, | 1141 { TEST_CASE(SynonymousHeaderTest), }, |
914 { TEST_CASE(ValidEntryTest), }, | 1142 { TEST_CASE(ValidEntryTest), }, |
915 { TEST_CASE(OverlappedPartitionTest), }, | 1143 { TEST_CASE(OverlappedPartitionTest), }, |
916 { TEST_CASE(CorruptCombinationTest), }, | 1144 { TEST_CASE(CorruptCombinationTest), }, |
917 { TEST_CASE(TestQuickSortFixed), }, | 1145 { TEST_CASE(TestQuickSortFixed), }, |
918 { TEST_CASE(TestQuickSortRandom), }, | 1146 { TEST_CASE(TestQuickSortRandom), }, |
| 1147 { TEST_CASE(NoValidKernelEntryTest), }, |
| 1148 { TEST_CASE(CombinationalNextKernelEntryTest), }, |
| 1149 { TEST_CASE(IncreaseTriesTest), }, |
| 1150 { TEST_CASE(MarkBadKernelEntryTest), }, |
| 1151 { TEST_CASE(UpdateInvalidKernelTypeTest), }, |
| 1152 { TEST_CASE(NormalBootCase), }, |
| 1153 { TEST_CASE(HigherPriorityTest), }, |
919 }; | 1154 }; |
920 | 1155 |
921 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { | 1156 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { |
922 printf("Running %s() ...\n", test_cases[i].name); | 1157 printf("Running %s() ...\n", test_cases[i].name); |
923 test_cases[i].retval = test_cases[i].fp(); | 1158 test_cases[i].retval = test_cases[i].fp(); |
924 if (test_cases[i].retval) { | 1159 if (test_cases[i].retval) { |
925 printf(COL_RED "[ERROR]\n\n" COL_STOP); | 1160 printf(COL_RED "[ERROR]\n\n" COL_STOP); |
926 ++error_count; | 1161 ++error_count; |
927 } else { | 1162 } else { |
928 printf(COL_GREEN "[PASS]\n\n" COL_STOP); | 1163 printf(COL_GREEN "[PASS]\n\n" COL_STOP); |
929 } | 1164 } |
930 } | 1165 } |
931 | 1166 |
932 if (error_count) { | 1167 if (error_count) { |
933 printf("\n--------------------------------------------------\n"); | 1168 printf("\n--------------------------------------------------\n"); |
934 printf(COL_RED "The following %d test cases are failed:\n" COL_STOP, | 1169 printf(COL_RED "The following %d test cases are failed:\n" COL_STOP, |
935 error_count); | 1170 error_count); |
936 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { | 1171 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { |
937 if (test_cases[i].retval) | 1172 if (test_cases[i].retval) |
938 printf(" %s()\n", test_cases[i].name); | 1173 printf(" %s()\n", test_cases[i].name); |
939 } | 1174 } |
940 } | 1175 } |
941 | 1176 |
942 return (error_count) ? 1 : 0; | 1177 return (error_count) ? 1 : 0; |
943 } | 1178 } |
OLD | NEW |