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

Side by Side Diff: autotest/firmware_VbootCrypto/firmware_VbootCrypto.py

Issue 3143029: vboot_reference: add in the VbootCrypto tests into vboot_reference git repo (Closed) Base URL: http://src.chromium.org/git/vboot_reference.git
Patch Set: Updated Makefile some, and .py file to reflect parallel make changes into main autotest tree Created 10 years, 3 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
« no previous file with comments | « autotest/firmware_VbootCrypto/control ('k') | autotest/firmware_VbootCrypto/src/Makefile » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import os
6
7 from autotest_lib.client.bin import test, utils
8 from autotest_lib.client.common_lib import error
9
10 class firmware_VbootCrypto(test.test):
11 """
12 Tests for correctness of verified boot reference crypto implementation.
13 """
14 version = 1
15 preserve_srcdir = True
16
17 # TODO(gauravsh): Disable this autotest until we have a way
18 # of running these in a 64-bit environment (since for x86, this
19 # code is run in 64-bit mode.
20 #
21 # This issue is tracked as Issue 3792 on the Chromium OS Bug Tracker.
22 # http://code.google.com/p/chromium-os/issues/detail?id=3792
23 def setup_Disabled(self):
24 os.chdir(self.srcdir)
25 utils.make('clean all')
26
27
28 # Parses the [result] and output the key-value pairs.
29 def __output_result_keyvals(self, results):
30 for keyval in results.splitlines():
31 if keyval.strip().startswith('#'):
32 continue
33 key, val = keyval.split(':')
34 self.keyvals[key.strip()] = float(val)
35
36
37 def __generate_test_cases(self):
38 gen_test_case_cmd = os.path.join(self.srcdir, "tests",
39 "gen_test_cases.sh")
40 return_code = utils.system(gen_test_case_cmd, ignore_status = True)
41 if return_code == 255:
42 return False
43 if return_code == 1:
44 raise error.TestError("Couldn't generate test cases")
45 return True
46
47
48 def __sha_test(self):
49 sha_test_cmd = os.path.join(self.srcdir, "tests", "sha_tests")
50 return_code = utils.system(sha_test_cmd, ignore_status=True)
51 if return_code == 255:
52 return False
53 if return_code == 1:
54 raise error.TestError("SHA Test Error")
55 return True
56
57
58 def __rsa_test(self):
59 os.chdir(self.srcdir)
60 rsa_test_cmd = os.path.join(self.srcdir, "tests",
61 "run_rsa_tests.sh")
62 return_code = utils.system(rsa_test_cmd, ignore_status=True)
63 if return_code == 255:
64 return False
65 if return_code == 1:
66 raise error.TestError("RSA Test Error")
67 return True
68
69
70 def __image_verification_test(self):
71 image_verification_cmd = "cd %s && ./run_image_verification_tests.sh" \
72 % os.path.join(self.srcdir, "tests")
73 return_code = utils.system(image_verification_cmd,
74 ignore_status=True)
75 if return_code == 255:
76 return False
77 if return_code == 1:
78 raise error.TestError("Image Verification Test Error")
79 return True
80
81
82 def __sha_benchmark(self):
83 sha_benchmark_cmd = os.path.join(self.srcdir, "tests",
84 "sha_benchmark")
85 self.results = utils.system_output(sha_benchmark_cmd,
86 retain_output=True)
87 self.__output_result_keyvals(self.results)
88
89
90 def __rsa_benchmark(self):
91 rsa_benchmark_cmd = "cd %s && ./rsa_verify_benchmark" % \
92 os.path.join(self.srcdir, "tests")
93 self.results = utils.system_output(rsa_benchmark_cmd,
94 retain_output=True)
95 self.__output_result_keyvals(self.results)
96
97
98 def __verify_image_benchmark(self):
99 firmware_benchmark_cmd = "cd %s && ./firmware_verify_benchmark" % \
100 os.path.join(self.srcdir, "tests")
101 kernel_benchmark_cmd = "cd %s && ./kernel_verify_benchmark" % \
102 os.path.join(self.srcdir, "tests")
103 self.results = utils.system_output(firmware_benchmark_cmd,
104 retain_output=True)
105 self.__output_result_keyvals(self.results)
106 self.results = utils.system_output(kernel_benchmark_cmd,
107 retain_output=True)
108 self.__output_result_keyvals(self.results)
109
110
111 def __rollback_tests(self):
112 firmware_rollback_test_cmd = "cd %s && ./firmware_rollback_tests" % \
113 os.path.join(self.srcdir, "tests")
114 kernel_rollback_test_cmd = "cd %s && ./kernel_rollback_tests" % \
115 os.path.join(self.srcdir, "tests")
116 return_code = utils.system(firmware_rollback_test_cmd,
117 ignore_status=True)
118 if return_code == 255:
119 return False
120 if return_code == 1:
121 raise error.TestError("Firmware Rollback Test Error")
122
123 return_code = utils.system(kernel_rollback_test_cmd,
124 ignore_status=True)
125 if return_code == 255:
126 return False
127 if return_code == 1:
128 raise error.TestError("KernelRollback Test Error")
129 return True
130
131
132 def __splicing_tests(self):
133 firmware_splicing_test_cmd = "cd %s && ./firmware_splicing_tests" % \
134 os.path.join(self.srcdir, "tests")
135 kernel_splicing_test_cmd = "cd %s && ./kernel_splicing_tests" % \
136 os.path.join(self.srcdir, "tests")
137 return_code = utils.system(firmware_splicing_test_cmd,
138 ignore_status=True)
139 if return_code == 255:
140 return False
141 if return_code == 1:
142 raise error.TestError("Firmware Splicing Test Error")
143
144 return_code = utils.system(kernel_splicing_test_cmd,
145 ignore_status=True)
146 if return_code == 255:
147 return False
148 if return_code == 1:
149 raise error.TestError("Kernel Splicing Test Error")
150 return True
151
152
153 def run_crypto(self):
154 success = self.__sha_test()
155 if not success:
156 raise error.TestFail("SHA Test Failed")
157 success = self.__rsa_test()
158 if not success:
159 raise error.TestFail("RSA Test Failed")
160
161
162 def run_verification(self):
163 success = self.__image_verification_test()
164 if not success:
165 raise error.TestFail("Image Verification Test Failed")
166
167
168 def run_benchmarks(self):
169 self.keyvals = {}
170 self.__sha_benchmark()
171 self.__rsa_benchmark()
172 self.__verify_image_benchmark()
173 self.write_perf_keyval(self.keyvals)
174
175
176 def run_rollback(self):
177 success = self.__rollback_tests()
178 if not success:
179 raise error.TestFail("Rollback Tests Failed")
180
181
182 def run_splicing(self):
183 success = self.__splicing_tests()
184 if not success:
185 raise error.TestFail("Splicing Tests Failed")
186
187
188 def run_once(self, suite='crypto'):
189 self.__generate_test_cases()
190 getattr(self, 'run_' + suite)()
OLDNEW
« no previous file with comments | « autotest/firmware_VbootCrypto/control ('k') | autotest/firmware_VbootCrypto/src/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698