Merge lp:~roadmr/checkbox/environ-test into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Merged at revision: 1799
Proposed branch: lp:~roadmr/checkbox/environ-test
Merge into: lp:checkbox
Diff against target: 99 lines (+27/-1)
4 files modified
checkbox/tests/test_message_files.py (+19/-0)
debian/changelog (+3/-1)
jobs/power-management.txt.in (+1/-0)
jobs/stress.txt.in (+4/-0)
To merge this branch: bzr merge lp:~roadmr/checkbox/environ-test
Reviewer Review Type Date Requested Status
Marc Tardif (community) Approve
Review via email: mp+131637@code.launchpad.net

Commit message

Added a unit test to verify that all environment variables referenced in a job's command are also properly "exported" using environ if the command specifies a user.

Description of the change

Added a unit test to verify that all environment variables referenced in a job's command are also properly "exported" using environ if the command specifies a user.

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

This is getting borderline fuzzy, having to use a regular expression to find shell variables in the command, but it will certainly help to catch some omissions. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox/tests/test_message_files.py'
2--- checkbox/tests/test_message_files.py 2012-10-09 13:32:06 +0000
3+++ checkbox/tests/test_message_files.py 2012-10-26 15:14:28 +0000
4@@ -59,6 +59,25 @@
5 if message['plugin'] == 'shell':
6 self.assertTrue("description" in message, message['name'])
7
8+ def test_shell_jobs_with_root_have_needed_environ(self):
9+ import re
10+ shell_variables_regex = r'\$\{?([A-Z_]+)\}?'
11+ environ_variables_regex = r'([A-Z_]+)'
12+ for message in self.messages:
13+ if message['plugin'] == 'shell' and 'user' in message:
14+ shell_variables = []
15+ environ_variables = []
16+ for key in ['command', 'command_extended']:
17+ if key in message:
18+ shell_variables += re.findall(shell_variables_regex,
19+ message[key])
20+ if 'environ' in message:
21+ environ_variables = re.findall(environ_variables_regex,
22+ message['environ'])
23+ self.assertEquals(set(environ_variables),
24+ set(shell_variables),
25+ message['name'])
26+
27 def test_jobs_comply_with_schema(self):
28 globals = {}
29 exec(open("plugins/jobs_info.py").read(), globals)
30
31=== modified file 'debian/changelog'
32--- debian/changelog 2012-10-26 14:28:19 +0000
33+++ debian/changelog 2012-10-26 15:14:28 +0000
34@@ -37,6 +37,8 @@
35 * Added retrying pactl commands in case audio layer is not up yet
36 (LP: #1065908)
37 * Removed references to inexistent opts.verbose setting (LP: #1070829)
38+ * Added unit test to catch jobs with mismatching environ and actual
39+ variables used in shell command (LP: #955053)
40
41 [Marc Tardif]
42 * plugins/environment_info.py: Enabling environment to take precedence
43@@ -92,7 +94,7 @@
44 * checkbox/parsers/modinfo.py - added exception handling to address possible
45 bad output from modinfo causing a ValueError to occur. (LP: #1066118)
46
47- -- Daniel Manrique <roadmr@ubuntu.com> Wed, 24 Oct 2012 10:00:12 -0400
48+ -- Daniel Manrique <roadmr@ubuntu.com> Thu, 25 Oct 2012 17:35:57 -0400
49
50 checkbox (0.14.6) quantal; urgency=low
51
52
53=== modified file 'jobs/power-management.txt.in'
54--- jobs/power-management.txt.in 2012-10-23 09:46:09 +0000
55+++ jobs/power-management.txt.in 2012-10-26 15:14:28 +0000
56@@ -12,6 +12,7 @@
57
58 plugin: shell
59 name: power-management/fwts_wakealarm
60+environ: CHECKBOX_DATA
61 user: root
62 _description: Test ACPI Wakealarm (fwts wakealarm)
63 requires:
64
65=== modified file 'jobs/stress.txt.in'
66--- jobs/stress.txt.in 2012-10-19 13:28:52 +0000
67+++ jobs/stress.txt.in 2012-10-26 15:14:28 +0000
68@@ -11,6 +11,7 @@
69 plugin: shell
70 name: power-management/hibernate_30_cycles
71 depends: power-management/rtc
72+environ: CHECKBOX_DATA
73 user: root
74 command:
75 if type -P fwts >/dev/null; then
76@@ -33,6 +34,7 @@
77 plugin: shell
78 name: power-management/suspend_30_cycles
79 depends: power-management/rtc
80+environ: CHECKBOX_DATA
81 user: root
82 command:
83 if type -P fwts >/dev/null; then
84@@ -55,6 +57,7 @@
85 plugin: shell
86 name: stress/hibernate_250_cycles
87 depends: power-management/rtc
88+environ: CHECKBOX_DATA
89 user: root
90 command:
91 if type -P fwts >/dev/null; then
92@@ -77,6 +80,7 @@
93 plugin: shell
94 name: stress/suspend_250_cycles
95 depends: power-management/rtc
96+environ: CHECKBOX_DATA
97 user: root
98 command:
99 if type -P fwts >/dev/null; then

Subscribers

People subscribed via source and target branches