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

Side by Side Diff: src/platform/vboot_reference/tests/big_kernel_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 if firmware image library deals with very large firmware. This 5 * Tests if firmware image library deals with very large firmware. This
6 * is a quick and dirty test for detecting integer overflow issues. 6 * is a quick and dirty test for detecting integer overflow issues.
7 */ 7 */
8 8
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 15 matching lines...) Expand all
26 const char* kKernelKeyPublicFile = KERNEL_KEY_BASE_NAME ".keyb"; 26 const char* kKernelKeyPublicFile = KERNEL_KEY_BASE_NAME ".keyb";
27 const char* kKernelKeyFile = KERNEL_KEY_BASE_NAME ".pem"; 27 const char* kKernelKeyFile = KERNEL_KEY_BASE_NAME ".pem";
28 28
29 int BigKernelTest() { 29 int BigKernelTest() {
30 int error_code = 0; 30 int error_code = 0;
31 uint64_t len; 31 uint64_t len;
32 uint8_t* kernel_blob = NULL; 32 uint8_t* kernel_blob = NULL;
33 RSAPublicKey* firmware_key = RSAPublicKeyFromFile(kFirmwareKeyPublicFile); 33 RSAPublicKey* firmware_key = RSAPublicKeyFromFile(kFirmwareKeyPublicFile);
34 uint8_t* firmware_key_blob = BufferFromFile(kFirmwareKeyPublicFile, &len); 34 uint8_t* firmware_key_blob = BufferFromFile(kFirmwareKeyPublicFile, &len);
35 uint8_t* kernel_sign_key_buf = BufferFromFile(kKernelKeyPublicFile, &len); 35 uint8_t* kernel_sign_key_buf = BufferFromFile(kKernelKeyPublicFile, &len);
36 fprintf(stderr, "Generating Big KernelImage..."); 36 debug("Generating Big KernelImage...");
37 KernelImage* image = 37 KernelImage* image =
38 GenerateTestKernelImage(3, /* RSA2048/SHA1 */ 38 GenerateTestKernelImage(3, /* RSA2048/SHA1 */
39 0, /* RSA1024/SHA1 */ 39 0, /* RSA1024/SHA1 */
40 kernel_sign_key_buf, 40 kernel_sign_key_buf,
41 1, /* Kernel Key Version. */ 41 1, /* Kernel Key Version. */
42 1, /* Kernel Version */ 42 1, /* Kernel Version */
43 BIG_KERNEL_SIZE, 43 BIG_KERNEL_SIZE,
44 kFirmwareKeyFile, 44 kFirmwareKeyFile,
45 kKernelKeyFile, 45 kKernelKeyFile,
46 'K'); /* Kernel Data Fill. */ 46 'K'); /* Kernel Data Fill. */
47 if (!firmware_key || !firmware_key_blob || !kernel_sign_key_buf || !image) { 47 if (!firmware_key || !firmware_key_blob || !kernel_sign_key_buf || !image) {
48 error_code = 1; 48 error_code = 1;
49 goto cleanup; 49 goto cleanup;
50 } 50 }
51 fprintf(stderr, "Done.\n"); 51 debug("Done.\n");
52 TEST_EQ(VerifyKernelImage(firmware_key, image, 0), 52 TEST_EQ(VerifyKernelImage(firmware_key, image, 0),
53 VERIFY_FIRMWARE_SUCCESS, 53 VERIFY_FIRMWARE_SUCCESS,
54 "Big KernelImage Verification"); 54 "Big KernelImage Verification");
55 kernel_blob = GetKernelBlob(image, &len); 55 kernel_blob = GetKernelBlob(image, &len);
56 TEST_EQ(VerifyKernel(firmware_key_blob, kernel_blob, 0), 56 TEST_EQ(VerifyKernel(firmware_key_blob, kernel_blob, 0),
57 VERIFY_FIRMWARE_SUCCESS, 57 VERIFY_FIRMWARE_SUCCESS,
58 "Big Kernel Blob Verification"); 58 "Big Kernel Blob Verification");
59 59
60 cleanup: 60 cleanup:
61 Free(kernel_blob); 61 Free(kernel_blob);
62 KernelImageFree(image); 62 KernelImageFree(image);
63 Free(kernel_sign_key_buf); 63 Free(kernel_sign_key_buf);
64 Free(firmware_key_blob); 64 Free(firmware_key_blob);
65 RSAPublicKeyFree(firmware_key); 65 RSAPublicKeyFree(firmware_key);
66 return error_code; 66 return error_code;
67 } 67 }
68 68
69 int main(int argc, char* argv[1]) 69 int main(int argc, char* argv[1])
70 { 70 {
71 int error_code = 0; 71 int error_code = 0;
72 error_code = BigKernelTest(); 72 error_code = BigKernelTest();
73 if (!gTestSuccess) 73 if (!gTestSuccess)
74 error_code = 255; 74 error_code = 255;
75 return error_code; 75 return error_code;
76 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698