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
=== modified file 'ChangeLog'
--- ChangeLog 2013-10-02 08:59:20 +0000
+++ ChangeLog 2013-10-03 10:13:41 +0000
@@ -1,3 +1,10 @@
12013-10-03 James Hunt <james.hunt@ubuntu.com>
2
3 * util/tests/test_utmp.c: Update remaining tests to pause
4 between writing utmp(x) records and reading them back to allow
5 tests to detect whether the expected new records have replaced
6 the artificially created original ones (LP: #1089159).
7
12013-10-02 James Hunt <james.hunt@ubuntu.com>82013-10-02 James Hunt <james.hunt@ubuntu.com>
29
3 * test/test_util_common.c:10 * test/test_util_common.c:
411
=== modified file 'util/tests/test_utmp.c'
--- util/tests/test_utmp.c 2012-12-18 16:37:38 +0000
+++ util/tests/test_utmp.c 2013-10-03 10:13:41 +0000
@@ -857,21 +857,21 @@
857 gettimeofday (&tv, NULL);857 gettimeofday (&tv, NULL);
858 record.ut_tv.tv_sec = tv.tv_sec;858 record.ut_tv.tv_sec = tv.tv_sec;
859 record.ut_tv.tv_usec = tv.tv_usec;859 record.ut_tv.tv_usec = tv.tv_usec;
860 utmpxname (utmp_file);
861
862 setutxent ();
863 pututxline (&record);
864 endutxent ();
865
866 updwtmpx (wtmp_file, &record);
867
860 /* utmp/wtmp records do not have nanosecond resolution868 /* utmp/wtmp records do not have nanosecond resolution
861 * yet the tests expect time to lapse, but it might not869 * yet the tests expect time to lapse, but it might not
862 * on very, very fast machines.870 * on very, very fast machines.
863 * https://jenkins.qa.ubuntu.com/view/Raring/view/AutoPkgTest/job/raring-adt-upstart/871 * https://jenkins.qa.ubuntu.com/view/Raring/view/AutoPkgTest/job/raring-adt-upstart/
864 * Is there a better way to fix the tests?872 * Is there a better way to fix the tests?
865 */873 */
866 usleep(200);874 usleep (200);
867
868 utmpxname (utmp_file);
869
870 setutxent ();
871 pututxline (&record);
872 endutxent ();
873
874 updwtmpx (wtmp_file, &record);
875875
876 ret = utmp_write_runlevel (utmp_file, wtmp_file, '5', '2');876 ret = utmp_write_runlevel (utmp_file, wtmp_file, '5', '2');
877877
@@ -970,6 +970,13 @@
970970
971 updwtmpx (wtmp_file, &record);971 updwtmpx (wtmp_file, &record);
972972
973 /* Allow time to pass so that the timestamp for the new
974 * record is guaranteed to be different to the existing
975 * timestamp allowing the test to detect if a record
976 * other than the artificially-created existing one was
977 * read back.
978 */
979 usleep (200);
973980
974 ret = utmp_write_runlevel (utmp_file, wtmp_file, '2', 'S');981 ret = utmp_write_runlevel (utmp_file, wtmp_file, '2', 'S');
975982
@@ -1077,6 +1084,13 @@
10771084
1078 updwtmpx (wtmp_file, &record);1085 updwtmpx (wtmp_file, &record);
10791086
1087 /* Allow time to pass so that the timestamp for the new
1088 * record is guaranteed to be different to the existing
1089 * timestamp allowing the test to detect if a record
1090 * other than the artificially-created existing one was
1091 * read back.
1092 */
1093 usleep (200);
10801094
1081 ret = utmp_write_runlevel (utmp_file, wtmp_file, '2', 'S');1095 ret = utmp_write_runlevel (utmp_file, wtmp_file, '2', 'S');
10821096
@@ -1349,6 +1363,14 @@
13491363
1350 updwtmpx (wtmp_file, &record);1364 updwtmpx (wtmp_file, &record);
13511365
1366 /* Allow time to pass so that the timestamp for the new
1367 * record is guaranteed to be different to the existing
1368 * timestamp allowing the test to detect if a record
1369 * other than the artificially-created existing one was
1370 * read back.
1371 */
1372 usleep (200);
1373
1352 ret = utmp_write_shutdown (utmp_file, wtmp_file);1374 ret = utmp_write_shutdown (utmp_file, wtmp_file);
13531375
1354 TEST_EQ (ret, 0);1376 TEST_EQ (ret, 0);

Subscribers

People subscribed via source and target branches