Merge lp:~roadmr/checkbox/804369-808423 into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Merged at revision: 955
Proposed branch: lp:~roadmr/checkbox/804369-808423
Merge into: lp:checkbox
Diff against target: 131 lines (+26/-22)
3 files modified
debian/changelog (+6/-1)
scripts/keyboard_test (+9/-4)
scripts/sleep_test (+11/-17)
To merge this branch: bzr merge lp:~roadmr/checkbox/804369-808423
Reviewer Review Type Date Requested Status
Marc Tardif (community) Approve
Review via email: mp+67748@code.launchpad.net

Description of the change

Fixes two bugs that cropped up in test scripts:

- keyboard_test used GTK and failed because it hadn't been properly converted to PyGI.

- sleep_test assumed the status codes from NetworkManager, used to validate the connection is active upon wakeup, were organized in an array (contiguous, 0-indexed). NM 0.9 uses arbitrary integers to indicate connection statuses, breaking the assumption. I structured the connected statuses list so that it's easy to account for changes in NM, and if it changes, the test will just exit cleanly and innocently after a sensible timeout, instead of dying horribly with a scary backtrace.

As is the code should work fine on both Natty and Oneiric, though I guess going forward it's only going to be used in Oneiric.

To post a comment you must log in.
Revision history for this message
Marc Tardif (cr3) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-07-11 15:54:26 +0000
3+++ debian/changelog 2011-07-12 19:36:11 +0000
4@@ -1,11 +1,16 @@
5 checkbox (0.12.4) oneiric; urgency=low
6+
7+ * scripts/keyboard_test modified to account for pygi-related GTK API
8+ changes. (LP: #804369)
9+ * scripts/sleep_test: improve handling of NetworkManager DBus API
10+ changes. (LP: #808423)
11
12 [ Brendan Donegan]
13 * Refactored job definition files.
14 * Fixed dependencies and test naming.
15 * Added Online CPU before/after suspend test.
16
17- -- Daniel Manrique <daniel.manrique@canonical.com> Mon, 11 Jul 2011 11:42:10 -0400
18+ -- Daniel Manrique <daniel.manrique@canonical.com> Tue, 12 Jul 2011 15:25:57 -0400
19
20 checkbox (0.12.3) oneiric; urgency=low
21
22
23=== modified file 'scripts/keyboard_test'
24--- scripts/keyboard_test 2011-05-17 06:15:31 +0000
25+++ scripts/keyboard_test 2011-07-12 19:36:11 +0000
26@@ -31,16 +31,19 @@
27 termios.tcsetattr(fileno, termios.TCSANOW, saved_attributes)
28
29 def gtk_prompt():
30- from gi.repository import Gtk
31+ from gi.repository import Gtk,Gdk
32
33 # create a new window
34- window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
35+ window = Gtk.Window()
36+ window.set_type_hint(Gdk.WindowType.TOPLEVEL)
37 window.set_size_request(200, 100)
38 window.set_resizable(False)
39 window.set_title(_("Type Text"))
40 window.connect("delete_event", lambda w,e: Gtk.main_quit())
41
42- vbox = Gtk.VBox(False, 0)
43+ vbox = Gtk.VBox()
44+ vbox.set_homogeneous(False)
45+ vbox.set_spacing(0)
46 window.add(vbox)
47 vbox.show()
48
49@@ -49,7 +52,9 @@
50 vbox.pack_start(entry, True, True, 0)
51 entry.show()
52
53- hbox = Gtk.HBox(False, 0)
54+ hbox = Gtk.HBox()
55+ hbox.set_homogeneous(False)
56+ hbox.set_spacing(0)
57 vbox.add(hbox)
58 hbox.show()
59
60
61=== modified file 'scripts/sleep_test'
62--- scripts/sleep_test 2011-06-06 14:58:22 +0000
63+++ scripts/sleep_test 2011-07-12 19:36:11 +0000
64@@ -2,7 +2,7 @@
65 '''
66 Program to automate system entering and resuming from sleep states
67
68-Copyright (C) 2010 Canonical Ltd.
69+Copyright (C) 2010,2011 Canonical Ltd.
70
71 Author:
72 Jeff Lane <jeffrey.lane@canonical.com>
73@@ -44,10 +44,10 @@
74 TO DO:
75 * remove workaround once we get a fix for the pm scripts issue that causes the
76 wakealarm and alarm_IRQ entries to not be reset after resume from S4
77-* Add in post-resume check to determine of network has resumed
78 * Add in checks to factor in the consumer-test hibernate/suspend test cases
79
80 Changelog:
81+v1.1: Added handling of NetworkManager 0.9 status codes.
82 v1.0: Added code to support Hibernate (S4) and allow choice between S3 and S4
83 at run-time.
84 Created mechanism in SuspendTest() class to check /proc/driver/rtc as a
85@@ -299,18 +299,13 @@
86 HAL_INTERFACE = "org.freedesktop.Hal.Manager"
87 HAL_INTERFACE_DEVICE = "org.freedesktop.Hal.Device"
88
89- STATE_UNKNOWN = "unknown"
90- STATE_ASLEEP = "asleep"
91- STATE_CONNECTING = "connecting"
92- STATE_CONNECTED = "connected"
93- STATE_DISCONNECTED = "disconnected"
94
95- _state_table = [
96- STATE_UNKNOWN,
97- STATE_ASLEEP,
98- STATE_CONNECTING,
99- STATE_CONNECTED,
100- STATE_DISCONNECTED]
101+ #http://projects.gnome.org/NetworkManager/developers/
102+ #NetworkManager D-Bus API Specifications, look for the
103+ #NM_STATE enumeration to see which statuses indicate connection
104+ #established and put them in this list. "3" works for NM 0.7
105+ #and 0.8, while "60" and "70" work for NM 0.9.
106+ STATES_CONNECTED = [3, 60, 70]
107
108 def __init__(self):
109 try:
110@@ -325,10 +320,9 @@
111 except dbus.exceptions.DBusException:
112 raise NetworkManagerException, "Failed to connect to dbus service"
113
114- def get_state(self):
115+ def is_connected(self):
116 state = self.nm_service.state()
117- return self._state_table[state]
118-
119+ return state in self.STATES_CONNECTED
120
121 def check_network():
122 try:
123@@ -339,7 +333,7 @@
124 start = datetime.now()
125 logging.debug("Waiting 60 seconds for NetworkManager to reconnect.")
126 while True:
127- if nm.get_state() == nm.STATE_CONNECTED:
128+ if nm.is_connected():
129 return True
130 # give 60 seconds to NetworkManager to get to a CONNECTED state, then give up
131 if datetime.now() - start > timedelta(seconds=60):

Subscribers

People subscribed via source and target branches