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

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

Issue 2857012: Batched update of factory tests. (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: finished comment Created 10 years, 6 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
(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
6 # DESCRIPTION :
7 #
8 # This is an example factory test that does not really do anything --
9 # it displays a message in the center of the testing area, as
10 # communicated by arguments to run_once(). This test makes use of the
11 # factory_test library to display its UI, and to monitor keyboard
12 # events for test-switching triggers. This test can be terminated by
13 # typing SHIFT-Q.
14
15 from autotest_lib.client.bin import test
16 from autotest_lib.client.bin import utils
17 from autotest_lib.client.common_lib import error
18 from autotest_lib.client.common_lib import factory_test
19
20 import gobject
21 import gtk
22 import pango
23 import os
24 import sys
25
26
27 _STATE_WAIT_INSERT = 1
28 _STATE_WAIT_REMOVE = 2
29
30
31 def find_root_dev():
32 rootdev = utils.system_output('rootdev')
33 return os.path.basename(rootdev[:-1])
34
35
36 def find_all_storage_dev():
37 lssys = utils.run('ls -d /sys/block/sd*')
38 devices = lssys.stdout.rsplit('\n')
39 new_devices = set(os.path.basename(d.rstrip()) for d in devices if d)
40 return new_devices
41
42
43 class factory_ExternalStorage(test.test):
44 version = 1
45
46 def key_release_callback(self, widget, event):
47 char = event.keyval in range(32,127) and chr(event.keyval) or None
48 factory_test.XXX_log('key_release_callback %s(%s)' %
49 (event.keyval, char))
50 factory_test.test_switch_on_trigger(event)
51 return True
52
53 def register_callbacks(self, window):
54 window.connect('key-release-event', self.key_release_callback)
55 window.add_events(gtk.gdk.KEY_RELEASE_MASK)
56
57 def rescan_storage(self, test_tag):
58 if self._state == _STATE_WAIT_INSERT:
59 new_devices = find_all_storage_dev()
60 diff = new_devices - self._devices
61 if diff:
62 self._devices = new_devices
63 factory_test.XXX_log('found new devs : %s' % diff)
64 self._target_device = diff.pop()
65 devpath = '/dev/%s' % self._target_device
66 self._prompt.set_test('testing drive %s...', devpath)
67 gtk.main_iteration()
68 test._result = self.job.run_test('hardware_StorageFio',
69 dev=devpath, tag=test_tag)
70 self._prompt.set_test('remove USB drive...')
71 self._state = _STATE_WAIT_REMOVE
72 else:
73 diff = self._devices - find_all_storage_dev()
74 if diff:
75 if diff != set(self._target_device):
76 raise error.TestFail('too many devs removed (%s vs %s)' %
77 (diff, self._target_device))
78 gtk.main_quit()
79 return True
80
81 def run_once(self, test_widget_size=None, trigger_set=None,
82 result_file_path=None, test_tag_prefix=None, test_count=None):
83
84 factory_test.XXX_log('factory_ExternalStorage %s %s' %
85 (test_tag_prefix, test_count))
86
87 test_tag = '%s_%s' % (test_tag_prefix, test_count)
88
89 factory_test.init(trigger_set=trigger_set,
90 result_file_path=result_file_path)
91
92 label = gtk.Label('')
93 label.modify_font(pango.FontDescription('courier new condensed 20'))
94 label.set_alignment(0.5, 0.5)
95 label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('light green'))
96 self._prompt = label
97
98 test_widget = gtk.EventBox()
99 test_widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
100 test_widget.add(label)
101
102 self._prompt.set_text('insert USB drive...')
103 self._state = _STATE_WAIT_INSERT
104 self._result = False
105 self._devices = find_all_storage_dev()
106 gobject.timeout_add(250, self.rescan_storage, test_tag)
107
108 factory_test.run_test_widget(
109 test_widget=test_widget,
110 test_widget_size=test_widget_size,
111 window_registration_callback=self.register_callbacks)
112
113 factory_test.XXX_log('exiting factory_ExternalStorage')
OLDNEW
« no previous file with comments | « client/site_tests/factory_Display/factory_Display.py ('k') | client/site_tests/factory_RebootStub/factory_RebootStub.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698