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 <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "cgptlib.h" | 8 #include "cgptlib.h" |
9 #include "cgptlib_internal.h" | 9 #include "cgptlib_internal.h" |
10 #include "cgptlib_test.h" | 10 #include "cgptlib_test.h" |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 EXPECT(0 == GetEntryTries(e + KERNEL_A)); | 1061 EXPECT(0 == GetEntryTries(e + KERNEL_A)); |
1062 EXPECT(1 == GetEntrySuccessful(e2 + KERNEL_A)); | 1062 EXPECT(1 == GetEntrySuccessful(e2 + KERNEL_A)); |
1063 EXPECT(4 == GetEntryPriority(e2 + KERNEL_A)); | 1063 EXPECT(4 == GetEntryPriority(e2 + KERNEL_A)); |
1064 EXPECT(0 == GetEntryTries(e2 + KERNEL_A)); | 1064 EXPECT(0 == GetEntryTries(e2 + KERNEL_A)); |
1065 /* Trying successful kernel changes nothing */ | 1065 /* Trying successful kernel changes nothing */ |
1066 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); | 1066 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); |
1067 EXPECT(1 == GetEntrySuccessful(e + KERNEL_A)); | 1067 EXPECT(1 == GetEntrySuccessful(e + KERNEL_A)); |
1068 EXPECT(4 == GetEntryPriority(e + KERNEL_A)); | 1068 EXPECT(4 == GetEntryPriority(e + KERNEL_A)); |
1069 EXPECT(0 == GetEntryTries(e + KERNEL_A)); | 1069 EXPECT(0 == GetEntryTries(e + KERNEL_A)); |
1070 EXPECT(0 == gpt->modified); | 1070 EXPECT(0 == gpt->modified); |
1071 /* Marking it bad does, though */ | 1071 /* Marking it bad also does not update it. */ |
1072 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); | 1072 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); |
1073 EXPECT(0 == GetEntrySuccessful(e + KERNEL_A)); | 1073 EXPECT(1 == GetEntrySuccessful(e + KERNEL_A)); |
1074 EXPECT(0 == GetEntryPriority(e + KERNEL_A)); | 1074 EXPECT(4 == GetEntryPriority(e + KERNEL_A)); |
1075 EXPECT(0 == GetEntryTries(e + KERNEL_A)); | 1075 EXPECT(0 == GetEntryTries(e + KERNEL_A)); |
1076 /* Which affects both copies of the partition entries */ | 1076 EXPECT(0 == gpt->modified); |
1077 EXPECT(0 == GetEntrySuccessful(e2 + KERNEL_A)); | |
1078 EXPECT(0 == GetEntryPriority(e2 + KERNEL_A)); | |
1079 EXPECT(0 == GetEntryTries(e2 + KERNEL_A)); | |
1080 /* And that's caused the GPT to need updating */ | |
1081 EXPECT(0x0F == gpt->modified); | |
1082 | 1077 |
1083 /* Kernel with tries */ | 1078 /* Kernel with tries */ |
1084 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); | 1079 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); |
1085 EXPECT(KERNEL_B == gpt->current_kernel); | 1080 EXPECT(KERNEL_B == gpt->current_kernel); |
1086 EXPECT(0 == GetEntrySuccessful(e + KERNEL_B)); | 1081 EXPECT(0 == GetEntrySuccessful(e + KERNEL_B)); |
1087 EXPECT(3 == GetEntryPriority(e + KERNEL_B)); | 1082 EXPECT(3 == GetEntryPriority(e + KERNEL_B)); |
1088 EXPECT(2 == GetEntryTries(e + KERNEL_B)); | 1083 EXPECT(2 == GetEntryTries(e + KERNEL_B)); |
1089 /* Marking it bad clears it */ | 1084 /* Marking it bad clears it */ |
1090 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); | 1085 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_BAD)); |
1091 EXPECT(0 == GetEntrySuccessful(e + KERNEL_B)); | 1086 EXPECT(0 == GetEntrySuccessful(e + KERNEL_B)); |
1092 EXPECT(0 == GetEntryPriority(e + KERNEL_B)); | 1087 EXPECT(0 == GetEntryPriority(e + KERNEL_B)); |
1093 EXPECT(0 == GetEntryTries(e + KERNEL_B)); | 1088 EXPECT(0 == GetEntryTries(e + KERNEL_B)); |
| 1089 /* Which affects both copies of the partition entries */ |
| 1090 EXPECT(0 == GetEntrySuccessful(e2 + KERNEL_B)); |
| 1091 EXPECT(0 == GetEntryPriority(e2 + KERNEL_B)); |
| 1092 EXPECT(0 == GetEntryTries(e2 + KERNEL_B)); |
| 1093 /* And that's caused the GPT to need updating */ |
| 1094 EXPECT(0x0F == gpt->modified); |
1094 | 1095 |
1095 /* Another kernel with tries */ | 1096 /* Another kernel with tries */ |
1096 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); | 1097 EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); |
1097 EXPECT(KERNEL_X == gpt->current_kernel); | 1098 EXPECT(KERNEL_X == gpt->current_kernel); |
1098 EXPECT(0 == GetEntrySuccessful(e + KERNEL_X)); | 1099 EXPECT(0 == GetEntrySuccessful(e + KERNEL_X)); |
1099 EXPECT(2 == GetEntryPriority(e + KERNEL_X)); | 1100 EXPECT(2 == GetEntryPriority(e + KERNEL_X)); |
1100 EXPECT(2 == GetEntryTries(e + KERNEL_X)); | 1101 EXPECT(2 == GetEntryTries(e + KERNEL_X)); |
1101 /* Trying it uses up a try */ | 1102 /* Trying it uses up a try */ |
1102 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); | 1103 EXPECT(GPT_SUCCESS == GptUpdateKernelEntry(gpt, GPT_UPDATE_ENTRY_TRY)); |
1103 EXPECT(0 == GetEntrySuccessful(e + KERNEL_X)); | 1104 EXPECT(0 == GetEntrySuccessful(e + KERNEL_X)); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 printf(COL_RED "The following %d test cases are failed:\n" COL_STOP, | 1246 printf(COL_RED "The following %d test cases are failed:\n" COL_STOP, |
1246 error_count); | 1247 error_count); |
1247 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { | 1248 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { |
1248 if (test_cases[i].retval) | 1249 if (test_cases[i].retval) |
1249 printf(" %s()\n", test_cases[i].name); | 1250 printf(" %s()\n", test_cases[i].name); |
1250 } | 1251 } |
1251 } | 1252 } |
1252 | 1253 |
1253 return (error_count) ? 1 : 0; | 1254 return (error_count) ? 1 : 0; |
1254 } | 1255 } |
OLD | NEW |