Merge lp:~vorlon/upstart/flaky-log-serialization-test into lp:upstart

Proposed by Steve Langasek
Status: Merged
Merged at revision: 1573
Proposed branch: lp:~vorlon/upstart/flaky-log-serialization-test
Merge into: lp:upstart
Diff against target: 160 lines (+25/-70)
3 files modified
ChangeLog (+11/-0)
init/tests/test_state.c (+14/-53)
test/test_util_common.h (+0/-17)
To merge this branch: bzr merge lp:~vorlon/upstart/flaky-log-serialization-test
Reviewer Review Type Date Requested Status
James Hunt Approve
Review via email: mp+195458@code.launchpad.net

Description of the change

A proposal to address the test failure seen here in jenkins:

  https://jenkins.qa.ubuntu.com/view/Trusty/view/AutoPkgTest/job/trusty-adt-upstart/14/ARCH=amd64,label=adt/

I don't have an explanation for why the test is failing the way it did here,
but in point of fact, the failure is entirely irrelevant to the point of the
test, which is for testing serialization of unflushed logs. We can get
information about the handling of unflushed logs without the complex
synchronization points in the current code.

To post a comment you must log in.
1575. By Steve Langasek

drop TIMED_BLOCK() macro, no longer used.

Revision history for this message
James Hunt (jamesodhunt) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2013-11-14 14:28:26 +0000
+++ ChangeLog 2013-11-15 23:47:52 +0000
@@ -1,3 +1,14 @@
12013-11-15 Steve Langasek <steve.langasek@ubuntu.com>
2
3 * init/tests/test_state.c: test_log_serialise():
4 - simplify the test for unflushed logs; there's no need
5 to let any writes to the logfile succeed before serializing,
6 we only need one synchronization point to make sure we have a
7 non-empty log buffer.
8 - drop a spurious check of nih_io_watches at a point where its
9 content cannot possibly have changed.
10 * test/test_util_common.h: drop TIMED_BLOCK() macro, no longer used.
11
12013-11-14 James Hunt <james.hunt@ubuntu.com>122013-11-14 James Hunt <james.hunt@ubuntu.com>
213
3 * NEWS: Release 1.1114 * NEWS: Release 1.11
415
=== modified file 'init/tests/test_state.c'
--- init/tests/test_state.c 2013-11-13 14:25:38 +0000
+++ init/tests/test_state.c 2013-11-15 23:47:52 +0000
@@ -2044,7 +2044,7 @@
2044 char filename[PATH_MAX];2044 char filename[PATH_MAX];
2045 pid_t pid;2045 pid_t pid;
2046 int wait_fd;2046 int wait_fd;
2047 int fds[2] = { -1 };2047 int fd;
2048 struct stat statbuf;2048 struct stat statbuf;
2049 mode_t old_perms;2049 mode_t old_perms;
2050 int status;2050 int status;
@@ -2094,33 +2094,23 @@
20942094
2095 TEST_EQ (openpty (&pty_master, &pty_slave, NULL, NULL, NULL), 0);2095 TEST_EQ (openpty (&pty_master, &pty_slave, NULL, NULL, NULL), 0);
20962096
2097 /* Provide a log file which is accessible initially */2097 /* Make file inaccessible to ensure data cannot be written
2098 * and will thus be added to the unflushed buffer.
2099 */
2100 fd = open (filename, O_CREAT | O_EXCL, 0);
2101 TEST_NE (fd, -1);
2102 close (fd);
2103
2104 /* Set up logging that we know won't go anywhere yet */
2098 log = log_new (NULL, filename, pty_master, 0);2105 log = log_new (NULL, filename, pty_master, 0);
2099 TEST_NE_P (log, NULL);2106 TEST_NE_P (log, NULL);
2100 TEST_FALSE (NIH_LIST_EMPTY (nih_io_watches));2107 TEST_FALSE (NIH_LIST_EMPTY (nih_io_watches));
21012108
2102 assert0 (pipe (fds));
2103
2104 TEST_CHILD_WAIT (pid, wait_fd) {2109 TEST_CHILD_WAIT (pid, wait_fd) {
2105 char *str = "hello\n";
2106 char buf[1];2110 char buf[1];
2107 size_t str_len;2111
2108
2109 str_len = strlen (str);
2110
2111 close (fds[1]);
2112 close (pty_master);2112 close (pty_master);
21132113
2114 /* Write initial data */
2115 ret = write (pty_slave, str, str_len);
2116 TEST_EQ ((size_t)ret, str_len);
2117
2118 /* let parent continue */
2119 TEST_CHILD_RELEASE (wait_fd);
2120
2121 /* now wait for parent */
2122 assert (read (fds[0], buf, 1) == 1);
2123
2124 len = TEST_ARRAY_SIZE (test_data);2114 len = TEST_ARRAY_SIZE (test_data);
2125 errno = 0;2115 errno = 0;
21262116
@@ -2128,6 +2118,9 @@
2128 ret = write (pty_slave, test_data, len);2118 ret = write (pty_slave, test_data, len);
2129 TEST_EQ ((size_t)ret, len);2119 TEST_EQ ((size_t)ret, len);
21302120
2121 /* let parent continue */
2122 TEST_CHILD_RELEASE (wait_fd);
2123
2131 /* keep child running until the parent is ready (to2124 /* keep child running until the parent is ready (to
2132 * simulate a job which continues to run across2125 * simulate a job which continues to run across
2133 * a re-exec).2126 * a re-exec).
@@ -2136,38 +2129,6 @@
2136 }2129 }
21372130
2138 close (pty_slave);2131 close (pty_slave);
2139 close (fds[0]);
2140
2141 TEST_FALSE (NIH_LIST_EMPTY (nih_io_watches));
2142
2143 got = FALSE;
2144 TIMED_BLOCK (5) {
2145 TEST_FORCE_WATCH_UPDATE ();
2146 if (! stat (filename, &statbuf)) {
2147 got = TRUE;
2148 break;
2149 }
2150 sleep (1);
2151 }
2152
2153 TEST_EQ (got, TRUE);
2154
2155 /* save */
2156 old_perms = statbuf.st_mode;
2157
2158 /* Make file inaccessible to ensure data cannot be written
2159 * and will thus be added to the unflushed buffer.
2160 */
2161 TEST_EQ (chmod (filename, 0x0), 0);
2162
2163 /* Artificially stop us writing to the already open log file with
2164 * perms 000.
2165 */
2166 close (log->fd);
2167 log->fd = -1;
2168
2169 /* release child */
2170 assert (write (fds[1], "\n", 1) == 1);
21712132
2172 /* Ensure that unflushed buffer contains data */2133 /* Ensure that unflushed buffer contains data */
2173 TEST_WATCH_UPDATE ();2134 TEST_WATCH_UPDATE ();
@@ -2193,7 +2154,7 @@
2193 TEST_EQ (waitpid (pid, &status, 0), pid);2154 TEST_EQ (waitpid (pid, &status, 0), pid);
21942155
2195 /* Restore access to allow log to be written on destruction */2156 /* Restore access to allow log to be written on destruction */
2196 TEST_EQ (chmod (filename, old_perms), 0);2157 TEST_EQ (chmod (filename, 0644), 0);
21972158
2198 nih_free (log);2159 nih_free (log);
2199 nih_free (new_log);2160 nih_free (new_log);
22002161
=== modified file 'test/test_util_common.h'
--- test/test_util_common.h 2013-11-13 14:25:38 +0000
+++ test/test_util_common.h 2013-11-15 23:47:52 +0000
@@ -670,23 +670,6 @@
670#define TEST_STR_ARRAY_NOT_CONTAINS(_array, _pattern) \670#define TEST_STR_ARRAY_NOT_CONTAINS(_array, _pattern) \
671 _TEST_STR_ARRAY_CONTAINS (_array, _pattern, TRUE)671 _TEST_STR_ARRAY_CONTAINS (_array, _pattern, TRUE)
672672
673
674/**
675 * TIMED_BLOCK:
676 * @secs: Seconds to run for.
677 *
678 * Run a block of code repeatedly for @secs seconds.
679 * Have the loop call sleep(3) to avoid a busy wait.
680 **/
681#define TIMED_BLOCK(secs) \
682 for (time_t _start_time = 0, _now = 0, _wait_secs = (time_t)secs;\
683 ; _now = time (NULL)) \
684 if (! _start_time) { \
685 _start_time = _now = time (NULL); \
686 } else if ((_start_time + _wait_secs) < _now) { \
687 break; \
688 } else
689
690extern int test_user_mode;673extern int test_user_mode;
691674
692/* Prototypes */675/* Prototypes */

Subscribers

People subscribed via source and target branches