Merge lp:~vorlon/upstart/more-log-flushing-tests into lp:upstart

Proposed by Steve Langasek
Status: Merged
Merged at revision: 1578
Proposed branch: lp:~vorlon/upstart/more-log-flushing-tests
Merge into: lp:upstart
Diff against target: 62 lines (+22/-2)
2 files modified
ChangeLog (+7/-0)
init/tests/test_log.c (+15/-2)
To merge this branch: bzr merge lp:~vorlon/upstart/more-log-flushing-tests
Reviewer Review Type Date Requested Status
James Hunt Approve
Review via email: mp+196432@code.launchpad.net

Description of the change

As with lp:~vorlon/upstart/flaky-log-serialization-test, some of the tests
in test_log.c fail because they assume the specified log file will not be
writable. This is not always the case, even if the target file is in the
root directory! So instead, if we don't want the log to be flushed, create
our own file and make sure it's inacessible.

To post a comment you must log in.
Revision history for this message
James Hunt (jamesodhunt) wrote :

LGTM - merged.

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-11-18 10:31:21 +0000
3+++ ChangeLog 2013-11-23 22:24:34 +0000
4@@ -1,3 +1,10 @@
5+2013-11-23 Steve Langasek <steve.langasek@ubuntu.com>
6+
7+ * init/tests/test_log.c: don't assume the root filesystem is not
8+ writable. If we want to make sure log data stays in the buffer
9+ instead of being flushed to disk, create a log file that we
10+ control and know can't be written to.
11+
12 2013-11-16 Dmitrijs Ledkovs <xnox@ubuntu.com>
13
14 * init/xdg.c, util/Makefile.am, test/Makefile.am, init/conf.c:
15
16=== modified file 'init/tests/test_log.c'
17--- init/tests/test_log.c 2013-06-25 09:19:05 +0000
18+++ init/tests/test_log.c 2013-11-23 22:24:34 +0000
19@@ -1136,6 +1136,8 @@
20 int pty_master;
21 int pty_slave;
22 int found_fd;
23+ char filename[1024];
24+ int fd;
25
26 TEST_FUNCTION ("log_destroy");
27
28@@ -1179,7 +1181,16 @@
29
30 TEST_EQ (openpty (&pty_master, &pty_slave, NULL, NULL, NULL), 0);
31
32- log = log_new (NULL, "/bar", pty_master, 0);
33+ TEST_FILENAME (filename);
34+
35+ /* Make file inaccessible to ensure data cannot be written
36+ * and will thus be added to the unflushed buffer.
37+ */
38+ fd = open (filename, O_CREAT | O_EXCL, 0);
39+ TEST_NE (fd, -1);
40+ close (fd);
41+
42+ log = log_new (NULL, filename, pty_master, 0);
43 TEST_NE_P (log, NULL);
44
45 ret = write (pty_slave, str, strlen (str));
46@@ -1200,7 +1211,7 @@
47
48 TEST_EQ (openpty (&pty_master, &pty_slave, NULL, NULL, NULL), 0);
49
50- log = log_new (NULL, "/bar", pty_master, 0);
51+ log = log_new (NULL, filename, pty_master, 0);
52 TEST_NE_P (log, NULL);
53
54 found_fd = 0;
55@@ -1238,6 +1249,8 @@
56 }
57 }
58
59+ TEST_EQ (unlink (filename), 0);
60+
61 /* Freeing the log object should have removed the watch */
62 TEST_EQ (found_fd, 0);
63

Subscribers

People subscribed via source and target branches