Merge authors:
  Dmitrijs Ledkovs (xnox)
Related merge proposals:
  https://code.launchpad.net/~xnox/upstart/test-static/+merge/140655
  proposed by: Dmitrijs Ledkovs (xnox)
------------------------------------------------------------
revno: 1420 [merge]
committer: James Hunt <[email protected]>
branch nick: upstart
timestamp: Wed 2012-12-19 16:08:40 +0000
message:
  * Merge of lp:~xnox/upstart/test-static.
added:
  init/tests/test_conf_static.c
modified:
  init/Makefile.am
  init/conf.c
  init/conf.h
  init/tests/test_conf.c


--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk

Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to 
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'init/Makefile.am'
--- init/Makefile.am	2012-12-14 15:54:35 +0000
+++ init/Makefile.am	2012-12-19 12:46:46 +0000
@@ -154,6 +154,7 @@
 	test_parse_job \
 	test_parse_conf \
 	test_conf \
+	test_conf_static \
 	test_xdg \
 	test_control
 
@@ -339,6 +340,20 @@
 	$(JSON_LIBS) \
 	-lrt
 
+test_conf_static_SOURCES = tests/test_conf_static.c
+test_conf_static_LDADD = \
+	system.o environ.o process.o \
+	job_class.o job_process.o job.o event.o event_operator.o blocked.o \
+	parse_job.o parse_conf.o control.o \
+	session.o log.o state.o \
+	com.ubuntu.Upstart.o \
+	com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
+	$(NIH_LIBS) \
+	$(NIH_DBUS_LIBS) \
+	$(DBUS_LIBS) \
+	$(JSON_LIBS) \
+	-lrt
+
 test_xdg_SOURCES = tests/test_xdg.c
 test_xdg_LDADD = \
 	xdg.o \

=== modified file 'init/conf.c'
--- init/conf.c	2012-09-09 20:01:22 +0000
+++ init/conf.c	2012-12-19 12:46:46 +0000
@@ -83,6 +83,9 @@
 static inline int is_conf_file_override(const char *path)
 	__attribute__ ((warn_unused_result));
 
+static inline char *toggle_conf_name   (const void *parent, const char *path)
+	__attribute__ ((warn_unused_result, malloc));
+
 /**
  * conf_sources:
  *
@@ -167,15 +170,12 @@
  * "foo.override", whereas if @path is "foo.override", it will return
  * "foo.conf".
  *
- * Note that this function should be static, but isn't to allow the
- * tests to access it.
- *
  * @parent: parent of returned path,
  * @path: path to a configuration file.
  *
  * Returns: newly allocated toggled path, or NULL on error.
  **/
-char *
+static inline char *
 toggle_conf_name (const void     *parent,
 		 const char     *path)
 {

=== modified file 'init/conf.h'
--- init/conf.h	2012-09-09 19:24:49 +0000
+++ init/conf.h	2012-12-19 12:46:46 +0000
@@ -127,9 +127,6 @@
 
 JobClass *  conf_select_job    (const char *name, const Session *session);
 
-char *toggle_conf_name         (const void *parent, const char *path)
-	__attribute__ ((warn_unused_result, malloc));
-
 #ifdef DEBUG
 
 /* used for debugging only */

=== modified file 'init/tests/test_conf.c'
--- init/tests/test_conf.c	2012-09-20 08:12:05 +0000
+++ init/tests/test_conf.c	2012-12-19 12:46:46 +0000
@@ -2417,53 +2417,6 @@
 }
 
 void
-test_toggle_conf_name (void)
-{
-	char override_ext[] = ".override";
-	char dirname[PATH_MAX];
-	char filename[PATH_MAX];
-	JobClass *job;
-	char *f;
-	char *p;
-
-	TEST_FUNCTION_FEATURE ("toggle_conf_name",
-			"changing conf to override");
-
-	TEST_FILENAME (dirname);
-	strcpy (filename, dirname);
-	strcat (filename, "/foo.conf");
-	f = toggle_conf_name (NULL, filename);
-	TEST_NE_P (f, NULL);
-
-	p = strstr (f, ".override");
-	TEST_NE_P (p, NULL);
-	TEST_EQ_P (p, f+strlen (f) - strlen (override_ext));
-	nih_free (f);
-
-	TEST_FEATURE ("changing override to conf");
-	strcpy (filename, dirname);
-	strcat (filename, "/bar.override");
-	f = toggle_conf_name (NULL, filename);
-	TEST_NE_P (f, NULL);
-
-	p = strstr (f, ".conf");
-	TEST_NE_P (p, NULL);
-	TEST_EQ_P (p, f+strlen (f) - strlen (".conf"));
-	nih_free (f);
-
-	/* test parent param */
-	job = job_class_new (NULL, "foo", NULL);
-	TEST_NE_P (job, NULL);
-
-	f = toggle_conf_name (job, filename);
-	TEST_NE_P (f, NULL);
-
-	TEST_EQ (TRUE, nih_alloc_parent (f, job));
-
-	nih_free (job);
-}
-
-void
 test_override (void)
 {
 	ConfSource *source;
@@ -4708,7 +4661,6 @@
 	test_source_reload_conf_dir ();
 	test_source_reload_file ();
 	test_source_reload ();
-	test_toggle_conf_name ();
 	test_override ();
 	test_file_destroy ();
 	test_select_job ();

=== added file 'init/tests/test_conf_static.c'
--- init/tests/test_conf_static.c	1970-01-01 00:00:00 +0000
+++ init/tests/test_conf_static.c	2012-12-19 12:46:46 +0000
@@ -0,0 +1,81 @@
+/* upstart
+ *
+ * test_conf.c - test suite for init/conf.c
+ *
+ * Copyright © 2012 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <limits.h>
+
+#include <nih/test.h>
+
+#include "conf.c"
+
+void
+test_toggle_conf_name (void)
+{
+	char override_ext[] = ".override";
+	char dirname[PATH_MAX];
+	char filename[PATH_MAX];
+	JobClass *job;
+	char *f;
+	char *p;
+
+	TEST_FUNCTION_FEATURE ("toggle_conf_name",
+			"changing conf to override");
+
+	TEST_FILENAME (dirname);
+	strcpy (filename, dirname);
+	strcat (filename, "/foo.conf");
+	f = toggle_conf_name (NULL, filename);
+	TEST_NE_P (f, NULL);
+
+	p = strstr (f, ".override");
+	TEST_NE_P (p, NULL);
+	TEST_EQ_P (p, f+strlen (f) - strlen (override_ext));
+	nih_free (f);
+
+	TEST_FEATURE ("changing override to conf");
+	strcpy (filename, dirname);
+	strcat (filename, "/bar.override");
+	f = toggle_conf_name (NULL, filename);
+	TEST_NE_P (f, NULL);
+
+	p = strstr (f, ".conf");
+	TEST_NE_P (p, NULL);
+	TEST_EQ_P (p, f+strlen (f) - strlen (".conf"));
+	nih_free (f);
+
+	/* test parent param */
+	job = job_class_new (NULL, "foo", NULL);
+	TEST_NE_P (job, NULL);
+
+	f = toggle_conf_name (job, filename);
+	TEST_NE_P (f, NULL);
+
+	TEST_EQ (TRUE, nih_alloc_parent (f, job));
+
+	nih_free (job);
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+	test_toggle_conf_name ();
+
+	return 0;
+}

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to