Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: src/platform/vboot_reference/tests/kernel_rollback_tests.c

Issue 1607006: VBoot Reference: Output debug information using debug() instead of fprintf(). (Closed)
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * Tests for checking kernel rollback-prevention logic. 5 * Tests for checking kernel rollback-prevention logic.
6 */ 6 */
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 }; 51 };
52 52
53 /* Initialize rollback index state. */ 53 /* Initialize rollback index state. */
54 g_kernel_key_version = 1; 54 g_kernel_key_version = 1;
55 g_kernel_version = 1; 55 g_kernel_version = 1;
56 56
57 /* Note: This test just checks the rollback prevention mechanism and not 57 /* Note: This test just checks the rollback prevention mechanism and not
58 * the full blown kernel boot logic. Updates to the kernel attributes 58 * the full blown kernel boot logic. Updates to the kernel attributes
59 * in the paritition table are not tested. 59 * in the paritition table are not tested.
60 */ 60 */
61 fprintf(stderr, "Kernel A boot priority(15) > Kernel B boot priority(1)\n"); 61 debug("Kernel A boot priority(15) > Kernel B boot priority(1)\n");
62 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 62 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
63 &valid_kernelA, &valid_kernelB, 63 &valid_kernelA, &valid_kernelB,
64 DEV_MODE_DISABLED), 64 DEV_MODE_DISABLED),
65 BOOT_KERNEL_A_CONTINUE, 65 BOOT_KERNEL_A_CONTINUE,
66 "(Valid Kernel A (current version)\n" 66 "(Valid Kernel A (current version)\n"
67 " Valid Kernel B (current version) runs A):"); 67 " Valid Kernel B (current version) runs A):");
68 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 68 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
69 &corrupt_kernelA, &valid_kernelB, 69 &corrupt_kernelA, &valid_kernelB,
70 DEV_MODE_DISABLED), 70 DEV_MODE_DISABLED),
71 BOOT_KERNEL_B_CONTINUE, 71 BOOT_KERNEL_B_CONTINUE,
72 "(Corrupt Kernel A (current version)\n" 72 "(Corrupt Kernel A (current version)\n"
73 " Valid Kernel B (current version) runs B):"); 73 " Valid Kernel B (current version) runs B):");
74 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 74 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
75 &valid_kernelA, &corrupt_kernelB, 75 &valid_kernelA, &corrupt_kernelB,
76 DEV_MODE_DISABLED), 76 DEV_MODE_DISABLED),
77 BOOT_KERNEL_A_CONTINUE, 77 BOOT_KERNEL_A_CONTINUE,
78 "(Valid Kernel A (current version)\n" 78 "(Valid Kernel A (current version)\n"
79 " Corrupt Kernel B (current version) runs A):"); 79 " Corrupt Kernel B (current version) runs A):");
80 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 80 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
81 &corrupt_kernelA, &corrupt_kernelB, 81 &corrupt_kernelA, &corrupt_kernelB,
82 DEV_MODE_DISABLED), 82 DEV_MODE_DISABLED),
83 BOOT_KERNEL_RECOVERY_CONTINUE, 83 BOOT_KERNEL_RECOVERY_CONTINUE,
84 "(Corrupt Kernel A (current version)\n" 84 "(Corrupt Kernel A (current version)\n"
85 " Corrupt Kernel B (current version) runs Recovery):"); 85 " Corrupt Kernel B (current version) runs Recovery):");
86 86
87 fprintf(stderr, "\nSwapping boot priorities...\n" 87 debug("\nSwapping boot priorities...\n"
88 "Kernel B boot priority(15) > Kernel A boot priority(1)\n"); 88 "Kernel B boot priority(15) > Kernel A boot priority(1)\n");
89 valid_kernelA.boot_priority = corrupt_kernelA.boot_priority = 1; 89 valid_kernelA.boot_priority = corrupt_kernelA.boot_priority = 1;
90 valid_kernelB.boot_priority = corrupt_kernelB.boot_priority = 15; 90 valid_kernelB.boot_priority = corrupt_kernelB.boot_priority = 15;
91 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 91 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
92 &valid_kernelA, &valid_kernelB, 92 &valid_kernelA, &valid_kernelB,
93 DEV_MODE_DISABLED), 93 DEV_MODE_DISABLED),
94 BOOT_KERNEL_B_CONTINUE, 94 BOOT_KERNEL_B_CONTINUE,
95 "(Valid Kernel A (current version)\n" 95 "(Valid Kernel A (current version)\n"
96 " Valid Kernel B (current version) runs B):"); 96 " Valid Kernel B (current version) runs B):");
97 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 97 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
98 &corrupt_kernelA, &valid_kernelB, 98 &corrupt_kernelA, &valid_kernelB,
99 DEV_MODE_DISABLED), 99 DEV_MODE_DISABLED),
100 BOOT_KERNEL_B_CONTINUE, 100 BOOT_KERNEL_B_CONTINUE,
101 "(Corrupt Kernel A (current version)\n" 101 "(Corrupt Kernel A (current version)\n"
102 " Valid Kernel B (current version) runs B):"); 102 " Valid Kernel B (current version) runs B):");
103 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 103 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
104 &valid_kernelA, &corrupt_kernelB, 104 &valid_kernelA, &corrupt_kernelB,
105 DEV_MODE_DISABLED), 105 DEV_MODE_DISABLED),
106 BOOT_KERNEL_A_CONTINUE, 106 BOOT_KERNEL_A_CONTINUE,
107 "(Valid Kernel A (current version)\n" 107 "(Valid Kernel A (current version)\n"
108 " Corrupt Kernel B (current version) runs A):"); 108 " Corrupt Kernel B (current version) runs A):");
109 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 109 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
110 &corrupt_kernelA, &corrupt_kernelB, 110 &corrupt_kernelA, &corrupt_kernelB,
111 DEV_MODE_DISABLED), 111 DEV_MODE_DISABLED),
112 BOOT_KERNEL_RECOVERY_CONTINUE, 112 BOOT_KERNEL_RECOVERY_CONTINUE,
113 "(Corrupt Kernel A (current version)\n" 113 "(Corrupt Kernel A (current version)\n"
114 " Corrupt Kernel B (current version) runs Recovery):"); 114 " Corrupt Kernel B (current version) runs Recovery):");
115 115
116 fprintf(stderr, "\nUpdating stored version information. Obsoleting " 116 debug("\nUpdating stored version information. Obsoleting "
117 "exiting kernel images.\n"); 117 "exiting kernel images.\n");
118 g_kernel_key_version = 2; 118 g_kernel_key_version = 2;
119 g_kernel_version = 2; 119 g_kernel_version = 2;
120 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 120 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
121 &valid_kernelA, &valid_kernelB, 121 &valid_kernelA, &valid_kernelB,
122 DEV_MODE_DISABLED), 122 DEV_MODE_DISABLED),
123 BOOT_KERNEL_RECOVERY_CONTINUE, 123 BOOT_KERNEL_RECOVERY_CONTINUE,
124 "(Valid Kernel A (old version)\n" 124 "(Valid Kernel A (old version)\n"
125 " Valid Kernel B (old version) runs Recovery):"); 125 " Valid Kernel B (old version) runs Recovery):");
126 126
127 fprintf(stderr, "\nGenerating updated Kernel A blob with " 127 debug("\nGenerating updated Kernel A blob with "
128 "new version.\n"); 128 "new version.\n");
129 Free(valid_kernelA.kernel_blob); 129 Free(valid_kernelA.kernel_blob);
130 valid_kernelA.kernel_blob = GenerateRollbackTestKernelBlob(3, 3, 0); 130 valid_kernelA.kernel_blob = GenerateRollbackTestKernelBlob(3, 3, 0);
131 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub, 131 TEST_EQ(VerifyKernelDriver_f(firmware_key_pub,
132 &valid_kernelA, &valid_kernelB, 132 &valid_kernelA, &valid_kernelB,
133 DEV_MODE_DISABLED), 133 DEV_MODE_DISABLED),
134 BOOT_KERNEL_A_CONTINUE, 134 BOOT_KERNEL_A_CONTINUE,
135 "(Valid Kernel A (new version)\n" 135 "(Valid Kernel A (new version)\n"
136 " Valid Kernel B (old version) runs A):"); 136 " Valid Kernel B (old version) runs A):");
137 137
138 Free(firmware_key_pub); 138 Free(firmware_key_pub);
139 Free(valid_kernelA.kernel_blob); 139 Free(valid_kernelA.kernel_blob);
140 Free(valid_kernelB.kernel_blob); 140 Free(valid_kernelB.kernel_blob);
141 Free(corrupt_kernelA.kernel_blob); 141 Free(corrupt_kernelA.kernel_blob);
142 Free(corrupt_kernelB.kernel_blob); 142 Free(corrupt_kernelB.kernel_blob);
143 } 143 }
144 144
145 int main(int argc, char* argv[]) { 145 int main(int argc, char* argv[]) {
146 int error_code = 0; 146 int error_code = 0;
147 VerifyKernelDriverTest(); 147 VerifyKernelDriverTest();
148 if (!gTestSuccess) 148 if (!gTestSuccess)
149 error_code = 255; 149 error_code = 255;
150 return error_code; 150 return error_code;
151 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698