Merge lp:~vorlon/upstart/check-for-overlayfs into lp:upstart

Proposed by Steve Langasek on 2013-11-04
Status: Merged
Merged at revision: 1560
Proposed branch: lp:~vorlon/upstart/check-for-overlayfs
Merge into: lp:upstart
Diff against target: 174 lines (+133/-2) (has conflicts)
4 files modified
ChangeLog (+16/-0)
test/Makefile.am (+14/-1)
test/test_util_common.c (+1/-1)
test/tests/test_util_check_env.c (+102/-0)
Text conflict in ChangeLog
To merge this branch: bzr merge lp:~vorlon/upstart/check-for-overlayfs
Reviewer Review Type Date Requested Status
James Hunt 2013-11-04 Approve on 2013-11-06
Review via email: mp+193726@code.launchpad.net
To post a comment you must log in.
James Hunt (jamesodhunt) wrote :

On reflection, we have 2 working implementations, so let's adopt the most efficient :)

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-03 02:56:57 +0000
3+++ ChangeLog 2013-11-04 01:15:45 +0000
4@@ -1,3 +1,4 @@
5+<<<<<<< TREE
6 2013-10-25 Steve Langasek <steve.langasek@ubuntu.com>
7
8 * init/main.c, init/system.c, init/system.h: allow mount options
9@@ -88,6 +89,21 @@
10 running in user mode (for 'check-config').
11
12 2013-10-04 Steve Langasek <steve.langasek@ubuntu.com>
13+=======
14+2013-10-17 James Hunt <james.hunt@ubuntu.com>
15+
16+ * test/tests/test_util_check_env.c:
17+ - check_for_overlayfs(): Only consider temporary work area.
18+
19+2013-10-16 James Hunt <james.hunt@ubuntu.com>
20+
21+ * test/tests/test_util_check_env.c: New test to look for
22+ overlayfs filesystems which could cause tests to fail.
23+ * test/Makefile.am: Added test_util_check_env meta-test.
24+ * test/test_util_common.c: Formatting.
25+
26+2013-10-04 Steve Langasek <steve.langasek@ubuntu.com
27+>>>>>>> MERGE-SOURCE
28
29 * extra/upstart-local-bridge.c: use SOCKET_PATH in our event
30 environment, instead of clobbering PATH. (LP: #1235480)
31
32=== modified file 'test/Makefile.am'
33--- test/Makefile.am 2013-06-25 09:19:05 +0000
34+++ test/Makefile.am 2013-11-04 01:15:45 +0000
35@@ -18,4 +18,17 @@
36 -I$(top_srcdir)/intl
37
38 check_LIBRARIES = libtest_util_common.a
39-libtest_util_common_a_SOURCES = test_util_common.c test_util_common.h
40+libtest_util_common_a_SOURCES = \
41+ test_util_common.c \
42+ test_util_common.h
43+
44+TESTS = test_util_check_env
45+check_PROGRAMS = $(TESTS)
46+
47+.PHONY: tests
48+tests: $(check_PROGRAMS)
49+
50+test_util_check_env_SOURCES = tests/test_util_check_env.c
51+test_util_check_env_LDADD = \
52+ libtest_util_common.a \
53+ $(NIH_LIBS)
54
55=== modified file 'test/test_util_common.c'
56--- test/test_util_common.c 2013-11-03 02:54:03 +0000
57+++ test/test_util_common.c 2013-11-04 01:15:45 +0000
58@@ -162,7 +162,7 @@
59 * within a reasonable period of time.
60 */
61 for (i = 0; i < loops; i++) {
62- sleep (1);
63+ sleep (1);
64
65 RUN_COMMAND (NULL, cmd, &output, &lines);
66
67
68=== added directory 'test/tests'
69=== added file 'test/tests/test_util_check_env.c'
70--- test/tests/test_util_check_env.c 1970-01-01 00:00:00 +0000
71+++ test/tests/test_util_check_env.c 2013-11-04 01:15:45 +0000
72@@ -0,0 +1,102 @@
73+/* upstart
74+ *
75+ * test_util_check_env.c - meta test to ensure environment sane for
76+ * running tests.
77+ *
78+ * Copyright © 2013 Canonical Ltd.
79+ * Author: James Hunt <james.hunt@canonical.com>
80+ *
81+ * This program is free software; you can redistribute it and/or modify
82+ * it under the terms of the GNU General Public License version 2, as
83+ * published by the Free Software Foundation.
84+ *
85+ * This program is distributed in the hope that it will be useful,
86+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
87+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88+ * GNU General Public License for more details.
89+ *
90+ * You should have received a copy of the GNU General Public License along
91+ * with this program; if not, write to the Free Software Foundation, Inc.,
92+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
93+ */
94+
95+#include <stdio.h>
96+#include <stdlib.h>
97+#include <sys/stat.h>
98+#include <limits.h>
99+#include <unistd.h>
100+#include <mntent.h>
101+
102+#include <nih/string.h>
103+#include <nih/test.h>
104+#include <nih/logging.h>
105+
106+#include "test_util_common.h"
107+
108+/**
109+ * check_for_overlayfs:
110+ *
111+ * Determine if the mount point used by the tests for creating temporary
112+ * files is using overlayfs.
113+ *
114+ * Returns: TRUE if temporary work area is on overlayfs, else FALSE.
115+ **/
116+int
117+check_for_overlayfs (void)
118+{
119+ struct statfs statbuf;
120+ char path[PATH_MAX];
121+#define OVERLAYFS_SUPER_MAGIC 0x794c764f
122+ int found = FALSE;
123+
124+ /* Create a file in the temporary work area */
125+ TEST_FILENAME (path);
126+ fclose (fopen (path, "w"));
127+
128+ /* Check it exits */
129+ assert0 (statfs (path, &statbuf));
130+
131+ if (statbuf.f_type == OVERLAYFS_SUPER_MAGIC) {
132+ nih_warn ("Mountpoint for '%s' (needed by the Upstart tests) is an overlayfs "
133+ "filesystem, which does not support inotify.",
134+ path);
135+ found = TRUE;
136+ }
137+
138+ assert0 (unlink (path));
139+
140+ return found;
141+}
142+
143+/**
144+ * test_checks:
145+ *
146+ * Perform any checks necessary before real tests are run.
147+ **/
148+void
149+test_checks (void)
150+{
151+ TEST_GROUP ("test environment");
152+
153+ /*
154+ * Warn (*) if overlayfs detected.
155+ *
156+ * (*) - Don't fail in the hope that one day someone might fix
157+ * overlayfs.
158+ */
159+ TEST_FEATURE ("checking for overlayfs");
160+ if (check_for_overlayfs ()) {
161+ nih_warn ("Found overlayfs mounts");
162+ nih_warn ("This environment will probably cause tests to fail mysteriously!!");
163+ nih_warn ("See bug LP:#882147 for further details.");
164+ }
165+}
166+
167+int
168+main (int argc,
169+ char *argv[])
170+{
171+ test_checks ();
172+
173+ return 0;
174+}

Subscribers

People subscribed via source and target branches