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/firmware_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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) 53 for (i = 0; i < NUM_SIZES_TO_TEST; ++i)
54 firmware_blobs[i] = NULL; 54 firmware_blobs[i] = NULL;
55 55
56 key_size = siglen_map[algorithm] * 8; /* in bits. */ 56 key_size = siglen_map[algorithm] * 8; /* in bits. */
57 snprintf(firmware_sign_key_file, FILE_NAME_SIZE, "testkeys/key_rsa%d.pem", 57 snprintf(firmware_sign_key_file, FILE_NAME_SIZE, "testkeys/key_rsa%d.pem",
58 key_size); 58 key_size);
59 59
60 snprintf(file_name, FILE_NAME_SIZE, "testkeys/key_rsa%d.keyb", key_size); 60 snprintf(file_name, FILE_NAME_SIZE, "testkeys/key_rsa%d.keyb", key_size);
61 firmware_sign_key = BufferFromFile(file_name, &len); 61 firmware_sign_key = BufferFromFile(file_name, &len);
62 if (!firmware_sign_key) { 62 if (!firmware_sign_key) {
63 fprintf(stderr, "Couldn't read pre-processed firmware signing key.\n"); 63 debug("Couldn't read pre-processed firmware signing key.\n");
64 error_code = 1; 64 error_code = 1;
65 goto cleanup; 65 goto cleanup;
66 } 66 }
67 67
68 /* Generate test images. */ 68 /* Generate test images. */
69 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) { 69 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) {
70 firmware_blobs[i] = GenerateTestFirmwareBlob(algorithm, 70 firmware_blobs[i] = GenerateTestFirmwareBlob(algorithm,
71 firmware_sign_key, 71 firmware_sign_key,
72 1, /* firmware key version. */ 72 1, /* firmware key version. */
73 1, /* firmware version. */ 73 1, /* firmware version. */
74 g_firmware_sizes_to_test[i], 74 g_firmware_sizes_to_test[i],
75 "testkeys/key_rsa8192.pem", 75 "testkeys/key_rsa8192.pem",
76 firmware_sign_key_file); 76 firmware_sign_key_file);
77 if (!firmware_blobs[i]) { 77 if (!firmware_blobs[i]) {
78 fprintf(stderr, "Couldn't generate test firmware images.\n"); 78 debug("Couldn't generate test firmware images.\n");
79 error_code = 1; 79 error_code = 1;
80 goto cleanup; 80 goto cleanup;
81 } 81 }
82 } 82 }
83 83
84 /* Get pre-processed key used for verification. */ 84 /* Get pre-processed key used for verification. */
85 root_key_blob = BufferFromFile("testkeys/key_rsa8192.keyb", &len); 85 root_key_blob = BufferFromFile("testkeys/key_rsa8192.keyb", &len);
86 if (!root_key_blob) { 86 if (!root_key_blob) {
87 fprintf(stderr, "Couldn't read pre-processed rootkey.\n"); 87 debug("Couldn't read pre-processed rootkey.\n");
88 error_code = 1; 88 error_code = 1;
89 goto cleanup; 89 goto cleanup;
90 } 90 }
91 91
92 /* Now run the timing tests. */ 92 /* Now run the timing tests. */
93 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) { 93 for (i = 0; i < NUM_SIZES_TO_TEST; ++i) {
94 StartTimer(&ct); 94 StartTimer(&ct);
95 for (j = 0; j < NUM_OPERATIONS; ++j) { 95 for (j = 0; j < NUM_OPERATIONS; ++j) {
96 if (VERIFY_FIRMWARE_SUCCESS != 96 if (VERIFY_FIRMWARE_SUCCESS !=
97 VerifyFirmware(root_key_blob, firmware_blobs[i])) 97 VerifyFirmware(root_key_blob, firmware_blobs[i]))
98 fprintf(stderr, "Warning: Firmware Verification Failed.\n"); 98 debug("Warning: Firmware Verification Failed.\n");
99 } 99 }
100 StopTimer(&ct); 100 StopTimer(&ct);
101 msecs = (float) GetDurationMsecs(&ct) / NUM_OPERATIONS; 101 msecs = (float) GetDurationMsecs(&ct) / NUM_OPERATIONS;
102 fprintf(stderr, 102 fprintf(stderr,
103 "# Firmware (%s, Algo = %s):" 103 "# Firmware (%s, Algo = %s):"
104 "\t%.02f ms/verification\n", 104 "\t%.02f ms/verification\n",
105 g_firmware_size_labels[i], 105 g_firmware_size_labels[i],
106 algo_strings[algorithm], 106 algo_strings[algorithm],
107 msecs); 107 msecs);
108 fprintf(stdout, "ms_firmware_%s_rsa%d_%s:%.02f\n", 108 fprintf(stdout, "ms_firmware_%s_rsa%d_%s:%.02f\n",
(...skipping 12 matching lines...) Expand all
121 121
122 122
123 int main(int argc, char* argv[]) { 123 int main(int argc, char* argv[]) {
124 int i, error_code = 0; 124 int i, error_code = 0;
125 for (i = 0; i < kNumAlgorithms; ++i) { 125 for (i = 0; i < kNumAlgorithms; ++i) {
126 if (0 != (error_code = SpeedTestAlgorithm(i))) 126 if (0 != (error_code = SpeedTestAlgorithm(i)))
127 return error_code; 127 return error_code;
128 } 128 }
129 return 0; 129 return 0;
130 } 130 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/big_kernel_tests.c ('k') | src/platform/vboot_reference/tests/kernel_rollback_tests.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698