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 * Tests for firmware image library. | 5 * Tests for firmware image library. |
6 */ | 6 */ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
11 #include "file_keys.h" | 11 #include "file_keys.h" |
12 #include "firmware_image.h" | 12 #include "firmware_image.h" |
13 #include "rsa_utility.h" | 13 #include "rsa_utility.h" |
14 #include "sha_utility.h" | 14 #include "sha_utility.h" |
15 #include "utility.h" | 15 #include "utility.h" |
16 | 16 |
| 17 /* ANSI Color coding sequences. */ |
| 18 #define COL_GREEN "\e[1;32m" |
| 19 #define COL_RED "\e[0;31m]" |
| 20 #define COL_STOP "\e[m" |
| 21 |
17 int TEST_EQ(int result, int expected_result, char* testname) { | 22 int TEST_EQ(int result, int expected_result, char* testname) { |
18 if (result == expected_result) { | 23 if (result == expected_result) { |
19 fprintf(stderr, "%s Test \e[1;32mSUCCEEDED\e[m\n", testname); | 24 fprintf(stderr, "%s Test " COL_GREEN " PASSED\n" COL_STOP, testname); |
20 return 1; | 25 return 1; |
21 } | 26 } |
22 else { | 27 else { |
23 fprintf(stderr, "%s Test \e[0;31mFAILED\e[m\n", testname); | 28 fprintf(stderr, "%s Test " COL_RED " FAILED\n" COL_STOP, testname); |
24 return 0; | 29 return 0; |
25 } | 30 } |
26 } | 31 } |
27 | 32 |
28 FirmwareImage* GenerateTestFirmwareImage(int algorithm, | 33 FirmwareImage* GenerateTestFirmwareImage(int algorithm, |
29 uint8_t* sign_key, | 34 uint8_t* sign_key, |
30 int key_version, | 35 int key_version, |
31 int firmware_version, | 36 int firmware_version, |
32 int firmware_len) { | 37 int firmware_len) { |
33 FirmwareImage* image = FirmwareImageNew(); | 38 FirmwareImage* image = FirmwareImageNew(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 225 |
221 failure: | 226 failure: |
222 Free(firmware_blob); | 227 Free(firmware_blob); |
223 Free(image); | 228 Free(image); |
224 Free(sign_key_buf); | 229 Free(sign_key_buf); |
225 Free(root_key_blob); | 230 Free(root_key_blob); |
226 Free(root_key); | 231 Free(root_key); |
227 | 232 |
228 return error_code; | 233 return error_code; |
229 } | 234 } |
OLD | NEW |