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

Side by Side Diff: src/platform/vboot_reference/tests/kernel_verify_benchmark.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 * Timing benchmark for verifying a firmware image. 5 * Timing benchmark for verifying a firmware image.
6 */ 6 */
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 firmware_key_size = siglen_map[firmware_sign_algorithm] * 8; /* in bits. */ 66 firmware_key_size = siglen_map[firmware_sign_algorithm] * 8; /* in bits. */
67 kernel_key_size = siglen_map[kernel_sign_algorithm] * 8; /* in bits. */ 67 kernel_key_size = siglen_map[kernel_sign_algorithm] * 8; /* in bits. */
68 snprintf(firmware_sign_key_file, FILE_NAME_SIZE, "testkeys/key_rsa%d.pem", 68 snprintf(firmware_sign_key_file, FILE_NAME_SIZE, "testkeys/key_rsa%d.pem",
69 firmware_key_size); 69 firmware_key_size);
70 snprintf(kernel_sign_key_file, FILE_NAME_SIZE, "testkeys/key_rsa%d.pem", 70 snprintf(kernel_sign_key_file, FILE_NAME_SIZE, "testkeys/key_rsa%d.pem",
71 kernel_key_size); 71 kernel_key_size);
72 snprintf(file_name, FILE_NAME_SIZE, "testkeys/key_rsa%d.keyb", 72 snprintf(file_name, FILE_NAME_SIZE, "testkeys/key_rsa%d.keyb",
73 kernel_key_size); 73 kernel_key_size);
74 kernel_sign_key = BufferFromFile(file_name, &len); 74 kernel_sign_key = BufferFromFile(file_name, &len);
75 if (!kernel_sign_key) { 75 if (!kernel_sign_key) {
76 fprintf(stderr, "Couldn't read pre-processed public kernel signing key.\n"); 76 debug("Couldn't read pre-processed public kernel signing key.\n");
77 error_code = 1; 77 error_code = 1;
78 goto cleanup; 78 goto cleanup;
79 } 79 }
80 80
81 /* Generate test images. */ 81 /* Generate test images. */
82 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) { 82 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) {
83 kernel_blobs[i] = GenerateTestKernelBlob(firmware_sign_algorithm, 83 kernel_blobs[i] = GenerateTestKernelBlob(firmware_sign_algorithm,
84 kernel_sign_algorithm, 84 kernel_sign_algorithm,
85 kernel_sign_key, 85 kernel_sign_key,
86 1, /* kernel key version. */ 86 1, /* kernel key version. */
87 1, /* kernel version. */ 87 1, /* kernel version. */
88 g_kernel_sizes_to_test[i], 88 g_kernel_sizes_to_test[i],
89 firmware_sign_key_file, 89 firmware_sign_key_file,
90 kernel_sign_key_file); 90 kernel_sign_key_file);
91 if (!kernel_blobs[i]) { 91 if (!kernel_blobs[i]) {
92 fprintf(stderr, "Couldn't generate test firmware images.\n"); 92 debug("Couldn't generate test firmware images.\n");
93 error_code = 1; 93 error_code = 1;
94 goto cleanup; 94 goto cleanup;
95 } 95 }
96 } 96 }
97 97
98 /* Get pre-processed key used for verification. */ 98 /* Get pre-processed key used for verification. */
99 snprintf(file_name, FILE_NAME_SIZE, "testkeys/key_rsa%d.keyb", 99 snprintf(file_name, FILE_NAME_SIZE, "testkeys/key_rsa%d.keyb",
100 firmware_key_size); 100 firmware_key_size);
101 firmware_key_blob = BufferFromFile(file_name, &len); 101 firmware_key_blob = BufferFromFile(file_name, &len);
102 if (!firmware_key_blob) { 102 if (!firmware_key_blob) {
103 fprintf(stderr, "Couldn't read pre-processed firmware public key.\n"); 103 debug("Couldn't read pre-processed firmware public key.\n");
104 error_code = 1; 104 error_code = 1;
105 goto cleanup; 105 goto cleanup;
106 } 106 }
107 107
108 /* Now run the timing tests. */ 108 /* Now run the timing tests. */
109 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) { 109 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) {
110 StartTimer(&ct); 110 StartTimer(&ct);
111 for (j = 0; j < NUM_OPERATIONS; ++j) { 111 for (j = 0; j < NUM_OPERATIONS; ++j) {
112 if (VERIFY_KERNEL_SUCCESS != 112 if (VERIFY_KERNEL_SUCCESS !=
113 VerifyKernel(firmware_key_blob, kernel_blobs[i], 0)) 113 VerifyKernel(firmware_key_blob, kernel_blobs[i], 0))
114 fprintf(stderr, "Warning: Kernel Verification Failed.\n"); 114 debug("Warning: Kernel Verification Failed.\n");
115 } 115 }
116 StopTimer(&ct); 116 StopTimer(&ct);
117 msecs = (float) GetDurationMsecs(&ct) / NUM_OPERATIONS; 117 msecs = (float) GetDurationMsecs(&ct) / NUM_OPERATIONS;
118 fprintf(stderr, 118 fprintf(stderr,
119 "# Kernel (%s, Algo = %s / %s):" 119 "# Kernel (%s, Algo = %s / %s):"
120 "\t%.02f ms/verification\n", 120 "\t%.02f ms/verification\n",
121 g_kernel_size_labels[i], 121 g_kernel_size_labels[i],
122 algo_strings[firmware_sign_algorithm], 122 algo_strings[firmware_sign_algorithm],
123 algo_strings[kernel_sign_algorithm], 123 algo_strings[kernel_sign_algorithm],
124 msecs); 124 msecs);
(...skipping 24 matching lines...) Expand all
149 if (siglen_map[j] > siglen_map[i]) 149 if (siglen_map[j] > siglen_map[i])
150 continue; 150 continue;
151 if (siglen_map[j] == siglen_map[i] && hash_size_map[j] > hash_size_map[i]) 151 if (siglen_map[j] == siglen_map[i] && hash_size_map[j] > hash_size_map[i])
152 continue; 152 continue;
153 if (0 != (error_code = SpeedTestAlgorithm(i, j))) 153 if (0 != (error_code = SpeedTestAlgorithm(i, j)))
154 return error_code; 154 return error_code;
155 } 155 }
156 } 156 }
157 return 0; 157 return 0;
158 } 158 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/kernel_rollback_tests.c ('k') | src/platform/vboot_reference/tests/rollback_index_mock.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698