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

Side by Side Diff: client/site_tests/factory_Wipe/factory_Wipe.py

Issue 3156047: modify factory_Wipe to fit into new flow (with factory_Verify) (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: fix as reviewer suggeted Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « client/bin/factory.py ('k') | client/site_tests/factory_Wipe/force_run » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import os 5 import os
6 import time
7 6
8 from autotest_lib.client.bin import factory 7 from autotest_lib.client.bin import factory
9 from autotest_lib.client.bin import factory_ui_lib as ful
10 from autotest_lib.client.bin import test, utils 8 from autotest_lib.client.bin import test, utils
11 from autotest_lib.client.common_lib import error 9 from autotest_lib.client.common_lib import error
12 10
13 11
14 GPIO_ROOT = '/home/gpio'
15 GOOGLE_REQUIRED_TESTS = [ 'hardware_Components', 'hardware_DeveloperRecovery' ]
16
17
18 def init_gpio(gpio_root=GPIO_ROOT):
19 """ initializes GPIO in GPIO_ROOT """
20 if os.path.exists(gpio_root):
21 utils.system("rm -rf '%s'" % gpio_root)
22 utils.system("mkdir '%s'" % (gpio_root))
23 utils.system("/usr/sbin/gpio_setup")
24
25
26 class factory_Wipe(test.test): 12 class factory_Wipe(test.test):
27 version = 2 13 version = 3
28 14
29 def wipe_stateful_partition(self, secure_wipe): 15 def wipe_stateful_partition(self, secure_wipe):
30 # Stub test to switch to boot from the release image, 16 # Stub test to switch to boot from the release image,
31 # and tag stateful partition to indicate wipe on reboot. 17 # and tag stateful partition to indicate wipe on reboot.
32 os.chdir(self.srcdir) 18 os.chdir(self.srcdir)
33 19
34 factory.log('switch to boot from release image and prepare wipe') 20 factory.log('switch to boot from release image and prepare wipe')
35 21
36 # Tag the current image to be wiped according to preference 22 # Tag the current image to be wiped according to preference
37 # (secure or fast). 23 # (secure or fast).
38 tag_filename = '/mnt/stateful_partition/factory_install_reset' 24 tag_filename = '/mnt/stateful_partition/factory_install_reset'
39 if secure_wipe: 25 if secure_wipe:
40 utils.run('touch %s' % tag_filename) 26 utils.run('touch %s' % tag_filename)
41 else: 27 else:
42 utils.run('echo "fast" > %s' % tag_filename) 28 utils.run('echo "fast" > %s' % tag_filename)
43 29
44 # Copy the wipe splash image to state partition. 30 # Copy the wipe splash image to state partition.
45 utils.run('cp -f wipe_splash.png /mnt/stateful_partition/') 31 utils.run('cp -f wipe_splash.png /mnt/stateful_partition/')
46 # Switch to the release image. 32 # Switch to the release image.
47 utils.run('./switch_partitions.sh') 33 utils.run('./switch_partitions.sh')
48 # Time for reboot. 34 # Time for reboot.
49 utils.run('shutdown -r now') 35 utils.run('shutdown -r now')
50 36
51 def check_developer_switch(self, do_check):
52 if not do_check:
53 factory.log('WARNING: DEVELOPER SWITCH BUTTON ' +
54 'IS NOT TESTED/ENABLED!');
55 return True
56
57 init_gpio()
58 status = open(os.path.join(GPIO_ROOT, "developer_switch")).read()
59 status_val = int(status)
60 if status_val != 0:
61 raise error.TestFail('Developer Switch Button is enabled')
62
63 def flashrom_write_protect(self, do_check):
64 # enable write protection (and test it) for flashrom
65
66 if not do_check:
67 factory.log('WARNING: FLASHROM WRITE PROTECTION ' +
68 'IS NOT TESTED/ENABLED!');
69 return True
70
71 factory.log('enable write protect (factory_EnableWriteProtect)')
72 self.job.run_test('factory_EnableWriteProtect')
73
74 # verify if write protection range is properly fixed,
75 # and all bits in RW is writable.
76 factory.log('verify write protect (hardware_EepromWriteProtect)')
77 if not self.job.run_test('hardware_EepromWriteProtect'):
78 raise error.TestFail('Flashrom write protection test failed.')
79
80 def run_once(self, 37 def run_once(self,
81 secure_wipe, 38 secure_wipe,
82 write_protect=True,
83 check_developer_switch=True,
84 status_file_path=None, 39 status_file_path=None,
85 test_list=None, 40 test_list=None,
86 force_skip_required_test_check=False): 41 only_run_from_factory_finalize_unless_testing=True):
87 42
88 if force_skip_required_test_check: 43 test_name = factory.FINAL_VERIFY_TEST_NAME
89 # alert user what he is doing 44 if only_run_from_factory_finalize_unless_testing:
90 alert_seconds = 3 45 if factory.lookup_status_by_unique_name(
91 for i in range(alert_seconds): 46 test_name, test_list, status_file_path) != factory.PASSED:
92 factory.log('WARNING: REQUIRED TEST CHECK IS BYPASSED. ' + 47 raise error.TestFail('You need to pass %s first.' % test_name)
93 'THIS DEVICE CANNOT BE QUALIFIED.')
94 factory.log("Waiting %d seconds before test start." % alert_seconds)
95 for i in range(alert_seconds, 0, -1):
96 factory.log(">> wipe test will start in %d seconds..." % i)
97 time.sleep(1)
98 else: 48 else:
99 # first, check if all previous tests are passed. 49 factory.log('WARNING: Final Verification is bypassed.\n' +
100 status_map = ful.StatusMap(test_list, status_file_path) 50 'THIS DEVICE CANNOT BE QUALIFIED.')
101 failed = status_map.filter(ful.FAILED)
102 if failed:
103 raise error.TestFail('Some tests were failed. ' +
104 'Cannot start wipe.')
105 51
106 # check if all Google Required Tests are passed
107 passed = [t.formal_name for t in status_map.filter(ful.PASSED)]
108 if not set(GOOGLE_REQUIRED_TESTS).issubset(passed):
109 missing = list(set(GOOGLE_REQUIRED_TESTS).difference(passed))
110 raise error.TestFail('You need to execute following ' +
111 'Google Required Tests: %s' %
112 (','.join(missing)))
113
114 # apply each final tests
115 self.check_developer_switch(check_developer_switch)
116 self.flashrom_write_protect(write_protect)
117 self.wipe_stateful_partition(secure_wipe) 52 self.wipe_stateful_partition(secure_wipe)
OLDNEW
« no previous file with comments | « client/bin/factory.py ('k') | client/site_tests/factory_Wipe/force_run » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698