| 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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 EXPECT((GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2) == gpt->modified); | 804 EXPECT((GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2) == gpt->modified); |
| 805 | 805 |
| 806 return TEST_OK; | 806 return TEST_OK; |
| 807 } | 807 } |
| 808 | 808 |
| 809 | 809 |
| 810 static int EntryAttributeGetSetTest() { | 810 static int EntryAttributeGetSetTest() { |
| 811 GptData* gpt = GetEmptyGptData(); | 811 GptData* gpt = GetEmptyGptData(); |
| 812 GptEntry* e = (GptEntry*)(gpt->primary_entries); | 812 GptEntry* e = (GptEntry*)(gpt->primary_entries); |
| 813 | 813 |
| 814 e->attributes = 0x0000000000000000LLU; | 814 e->attrs.whole = 0x0000000000000000LLU; |
| 815 SetEntrySuccessful(e, 1); | 815 SetEntrySuccessful(e, 1); |
| 816 EXPECT(0x0100000000000000LLU == e->attributes); | 816 EXPECT(0x0100000000000000LLU == e->attrs.whole); |
| 817 EXPECT(1 == GetEntrySuccessful(e)); | 817 EXPECT(1 == GetEntrySuccessful(e)); |
| 818 e->attributes = 0xFFFFFFFFFFFFFFFFLLU; | 818 e->attrs.whole = 0xFFFFFFFFFFFFFFFFLLU; |
| 819 SetEntrySuccessful(e, 0); | 819 SetEntrySuccessful(e, 0); |
| 820 EXPECT(0xFEFFFFFFFFFFFFFFLLU == e->attributes); | 820 EXPECT(0xFEFFFFFFFFFFFFFFLLU == e->attrs.whole); |
| 821 EXPECT(0 == GetEntrySuccessful(e)); | 821 EXPECT(0 == GetEntrySuccessful(e)); |
| 822 | 822 |
| 823 e->attributes = 0x0000000000000000LLU; | 823 e->attrs.whole = 0x0000000000000000LLU; |
| 824 SetEntryTries(e, 15); | 824 SetEntryTries(e, 15); |
| 825 EXPECT(15 == GetEntryTries(e)); | 825 EXPECT(15 == GetEntryTries(e)); |
| 826 EXPECT(0x00F0000000000000LLU == e->attributes); | 826 EXPECT(0x00F0000000000000LLU == e->attrs.whole); |
| 827 e->attributes = 0xFFFFFFFFFFFFFFFFLLU; | 827 e->attrs.whole = 0xFFFFFFFFFFFFFFFFLLU; |
| 828 SetEntryTries(e, 0); | 828 SetEntryTries(e, 0); |
| 829 EXPECT(0xFF0FFFFFFFFFFFFFLLU == e->attributes); | 829 EXPECT(0xFF0FFFFFFFFFFFFFLLU == e->attrs.whole); |
| 830 EXPECT(0 == GetEntryTries(e)); | 830 EXPECT(0 == GetEntryTries(e)); |
| 831 | 831 |
| 832 e->attributes = 0x0000000000000000LLU; | 832 e->attrs.whole = 0x0000000000000000LLU; |
| 833 SetEntryPriority(e, 15); | 833 SetEntryPriority(e, 15); |
| 834 EXPECT(0x000F000000000000LLU == e->attributes); | 834 EXPECT(0x000F000000000000LLU == e->attrs.whole); |
| 835 EXPECT(15 == GetEntryPriority(e)); | 835 EXPECT(15 == GetEntryPriority(e)); |
| 836 e->attributes = 0xFFFFFFFFFFFFFFFFLLU; | 836 e->attrs.whole = 0xFFFFFFFFFFFFFFFFLLU; |
| 837 SetEntryPriority(e, 0); | 837 SetEntryPriority(e, 0); |
| 838 EXPECT(0xFFF0FFFFFFFFFFFFLLU == e->attributes); | 838 EXPECT(0xFFF0FFFFFFFFFFFFLLU == e->attrs.whole); |
| 839 EXPECT(0 == GetEntryPriority(e)); | 839 EXPECT(0 == GetEntryPriority(e)); |
| 840 | 840 |
| 841 e->attributes = 0xFFFFFFFFFFFFFFFFLLU; | 841 e->attrs.whole = 0xFFFFFFFFFFFFFFFFLLU; |
| 842 EXPECT(1 == GetEntrySuccessful(e)); | 842 EXPECT(1 == GetEntrySuccessful(e)); |
| 843 EXPECT(15 == GetEntryPriority(e)); | 843 EXPECT(15 == GetEntryPriority(e)); |
| 844 EXPECT(15 == GetEntryTries(e)); | 844 EXPECT(15 == GetEntryTries(e)); |
| 845 | 845 |
| 846 e->attributes = 0x0123000000000000LLU; | 846 e->attrs.whole = 0x0123000000000000LLU; |
| 847 EXPECT(1 == GetEntrySuccessful(e)); | 847 EXPECT(1 == GetEntrySuccessful(e)); |
| 848 EXPECT(2 == GetEntryTries(e)); | 848 EXPECT(2 == GetEntryTries(e)); |
| 849 EXPECT(3 == GetEntryPriority(e)); | 849 EXPECT(3 == GetEntryPriority(e)); |
| 850 | 850 |
| 851 return TEST_OK; | 851 return TEST_OK; |
| 852 } | 852 } |
| 853 | 853 |
| 854 | 854 |
| 855 static int EntryTypeTest() { | 855 static int EntryTypeTest() { |
| 856 GptData* gpt = GetEmptyGptData(); | 856 GptData* gpt = GetEmptyGptData(); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 printf(COL_RED "The following %d test cases are failed:\n" COL_STOP, | 1131 printf(COL_RED "The following %d test cases are failed:\n" COL_STOP, |
| 1132 error_count); | 1132 error_count); |
| 1133 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { | 1133 for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) { |
| 1134 if (test_cases[i].retval) | 1134 if (test_cases[i].retval) |
| 1135 printf(" %s()\n", test_cases[i].name); | 1135 printf(" %s()\n", test_cases[i].name); |
| 1136 } | 1136 } |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 return (error_count) ? 1 : 0; | 1139 return (error_count) ? 1 : 0; |
| 1140 } | 1140 } |
| OLD | NEW |