Merge lp:~jamesodhunt/upstart/bug-1089159 into lp:upstart

Proposed by James Hunt
Status: Merged
Merged at revision: 1539
Proposed branch: lp:~jamesodhunt/upstart/bug-1089159
Merge into: lp:upstart
Diff against target: 92 lines (+38/-9)
2 files modified
ChangeLog (+7/-0)
util/tests/test_utmp.c (+31/-9)
To merge this branch: bzr merge lp:~jamesodhunt/upstart/bug-1089159
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Approve
Review via email: mp+189032@code.launchpad.net

Description of the change

* util/tests/test_utmp.c: Update remaining tests to pause between
  writing utmp(x) records and reading them back to allow tests to detect
  whether the expected new records have replaced the artificially created
  original ones (LP: #1089159).

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Well, a similar sleep did solve the often accruing race. Let's throw the rest of them onto jenkins and see if that helps.
My machine cannot reproduce the failure with or without this patch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-10-02 08:59:20 +0000
3+++ ChangeLog 2013-10-03 10:13:41 +0000
4@@ -1,3 +1,10 @@
5+2013-10-03 James Hunt <james.hunt@ubuntu.com>
6+
7+ * util/tests/test_utmp.c: Update remaining tests to pause
8+ between writing utmp(x) records and reading them back to allow
9+ tests to detect whether the expected new records have replaced
10+ the artificially created original ones (LP: #1089159).
11+
12 2013-10-02 James Hunt <james.hunt@ubuntu.com>
13
14 * test/test_util_common.c:
15
16=== modified file 'util/tests/test_utmp.c'
17--- util/tests/test_utmp.c 2012-12-18 16:37:38 +0000
18+++ util/tests/test_utmp.c 2013-10-03 10:13:41 +0000
19@@ -857,21 +857,21 @@
20 gettimeofday (&tv, NULL);
21 record.ut_tv.tv_sec = tv.tv_sec;
22 record.ut_tv.tv_usec = tv.tv_usec;
23+ utmpxname (utmp_file);
24+
25+ setutxent ();
26+ pututxline (&record);
27+ endutxent ();
28+
29+ updwtmpx (wtmp_file, &record);
30+
31 /* utmp/wtmp records do not have nanosecond resolution
32 * yet the tests expect time to lapse, but it might not
33 * on very, very fast machines.
34 * https://jenkins.qa.ubuntu.com/view/Raring/view/AutoPkgTest/job/raring-adt-upstart/
35 * Is there a better way to fix the tests?
36 */
37- usleep(200);
38-
39- utmpxname (utmp_file);
40-
41- setutxent ();
42- pututxline (&record);
43- endutxent ();
44-
45- updwtmpx (wtmp_file, &record);
46+ usleep (200);
47
48 ret = utmp_write_runlevel (utmp_file, wtmp_file, '5', '2');
49
50@@ -970,6 +970,13 @@
51
52 updwtmpx (wtmp_file, &record);
53
54+ /* Allow time to pass so that the timestamp for the new
55+ * record is guaranteed to be different to the existing
56+ * timestamp allowing the test to detect if a record
57+ * other than the artificially-created existing one was
58+ * read back.
59+ */
60+ usleep (200);
61
62 ret = utmp_write_runlevel (utmp_file, wtmp_file, '2', 'S');
63
64@@ -1077,6 +1084,13 @@
65
66 updwtmpx (wtmp_file, &record);
67
68+ /* Allow time to pass so that the timestamp for the new
69+ * record is guaranteed to be different to the existing
70+ * timestamp allowing the test to detect if a record
71+ * other than the artificially-created existing one was
72+ * read back.
73+ */
74+ usleep (200);
75
76 ret = utmp_write_runlevel (utmp_file, wtmp_file, '2', 'S');
77
78@@ -1349,6 +1363,14 @@
79
80 updwtmpx (wtmp_file, &record);
81
82+ /* Allow time to pass so that the timestamp for the new
83+ * record is guaranteed to be different to the existing
84+ * timestamp allowing the test to detect if a record
85+ * other than the artificially-created existing one was
86+ * read back.
87+ */
88+ usleep (200);
89+
90 ret = utmp_write_shutdown (utmp_file, wtmp_file);
91
92 TEST_EQ (ret, 0);

Subscribers

People subscribed via source and target branches