Fix make distcheck, rework tests, reorganise files
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Fri, 27 Jul 2012 15:50:22 +0000 (16:50 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Mon, 30 Jul 2012 11:49:29 +0000 (12:49 +0100)
This commit fixes make distcheck by making the LUC handler test part of
"make installcheck" and by disabling the legacy app tests in "make
check".

For the LUC handler test to not interfere with the LUC on the system,
the boot-manager binary is now aware of a LUC_PATH environment variable
that overrides the LUC_PATH string defined at build-time. This way we
can use a different LUC file for the test.

This commit also drops the nsm-dummy/dbus/ and nsm-dummy/systemd/
directories and moves the corresponding files to nsm-dummy/.

12 files changed:
boot-manager/Makefile.am
boot-manager/boot-manager-service.c
boot-manager/glib-extensions.h
configure.ac
nsm-dummy/Makefile.am
nsm-dummy/busconf/Makefile.am
nsm-dummy/com.contiautomotive.NodeStateManager.Consumer.service.in [moved from nsm-dummy/dbus/com.contiautomotive.NodeStateManager.Consumer.service.in with 100% similarity]
nsm-dummy/com.contiautomotive.NodeStateManager.LifecycleControl.service.in [moved from nsm-dummy/dbus/com.contiautomotive.NodeStateManager.LifecycleControl.service.in with 100% similarity]
nsm-dummy/nsm-dummy.service.in [moved from nsm-dummy/systemd/nsm-dummy.service.in with 100% similarity]
tests/boot-manager/Makefile.am
tests/boot-manager/test-luc-handler
tests/legacy-app-handler/Makefile.am

index 3548916..4ef33aa 100644 (file)
@@ -63,6 +63,10 @@ boot_manager_LDADD =                                                 \
        $(SYSTEMD_DAEMON_LIBS)                                          \
        $(top_builddir)/common/libcommon.la
 
+%.service: %.service.in
+       sed -e "s,\@libdir\@,$(libdir),g"                               \
+           -e "s,\@BOOT_MANAGER_VERSION_API\@,$(BOOT_MANAGER_VERSION_API),g" < $< > $@
+
 dbus_servicedir = $(datadir)/dbus-1/system-services
 
 dbus_service_in_files =                                                        \
@@ -70,10 +74,6 @@ dbus_service_in_files =                                                      \
 
 dbus_service_DATA = $(dbus_service_in_files:.service.in=.service)
 
-%.service: %.service.in
-       sed -e "s,\@libdir\@,$(libdir),g"                               \
-           -e "s,\@BOOT_MANAGER_VERSION_API\@,$(BOOT_MANAGER_VERSION_API),g" < $< > $@
-
 systemd_servicedir = $(libdir)/systemd/system
 
 systemd_service_in_files =                                             \
@@ -81,10 +81,6 @@ systemd_service_in_files =                                           \
 
 systemd_service_DATA = $(systemd_service_in_files:.service.in=.service)
 
-%.service: %.service.in
-       sed -e "s,\@libdir\@,$(libdir),g"                               \
-           -e "s,\@BOOT_MANAGER_VERSION_API\@,$(BOOT_MANAGER_VERSION_API),g" < $< > $@
-
 CLEANFILES =                                                           \
        $(dbus_service_DATA)                                            \
        $(systemd_service_DATA)
index 2134a2f..7bf659c 100644 (file)
@@ -459,16 +459,23 @@ GVariant *
 boot_manager_service_read_luc (BootManagerService *service,
                                GError            **error)
 {
-  GVariant *context;
-  GFile    *luc_file;
-  char     *data;
-  gsize     data_len;
+  const gchar *luc_path;
+  GVariant    *context;
+  GFile       *luc_file;
+  char        *data;
+  gsize        data_len;
 
   g_return_val_if_fail (BOOT_MANAGER_IS_SERVICE (service), NULL);
   g_return_val_if_fail ((error == NULL || *error == NULL), NULL);
 
+  /* check which configuration file to use; the LUC_PATH environment variable
+   * has priority over the build-time LUC_PATH definition */
+  luc_path = g_getenv ("LUC_PATH");
+  if (luc_path == NULL)
+    luc_path = LUC_PATH;
+
   /* initialize the GFile */
-  luc_file = g_file_new_for_path (LUC_PATH);
+  luc_file = g_file_new_for_path (luc_path);
 
   /* read the contents of the file */
   if (!g_file_load_contents (luc_file, NULL, &data, &data_len, NULL, error))
@@ -492,15 +499,22 @@ void
 boot_manager_service_write_luc (BootManagerService *service,
                                 GError            **error)
 {
-  GError *err = NULL;
-  GFile  *luc_file;
-  GFile  *luc_dir;
+  const gchar *luc_path;
+  GError      *err = NULL;
+  GFile       *luc_file;
+  GFile       *luc_dir;
 
   g_return_if_fail (BOOT_MANAGER_IS_SERVICE (service));
   g_return_if_fail (error == NULL || *error == NULL);
 
+  /* check which configuration file to use; the LUC_PATH environment variable
+   * has priority over the build-time LUC_PATH definition */
+  luc_path = g_getenv ("LUC_PATH");
+  if (luc_path == NULL)
+    luc_path = LUC_PATH;
+
   /* initialize the GFiles */
-  luc_file = g_file_new_for_path (LUC_PATH);
+  luc_file = g_file_new_for_path (luc_path);
   luc_dir = g_file_get_parent (luc_file);
 
   /* make sure the last user context's directory exists */
index bd822b1..8602841 100644 (file)
@@ -18,7 +18,7 @@ GVariant *g_variant_lookup_value_with_int_key (GVariant           *dictionary,
                                                const gint          key,
                                                const GVariantType *expected_type);
 gboolean  g_variant_string_array_has_string   (GVariant           *array,
-                                                          const gchar         *str);
+                                               const gchar        *str);
 gint      g_int_pointer_compare               (gconstpointer       a,
                                                gconstpointer       b);
 
index 250216f..ea78a1d 100644 (file)
@@ -140,8 +140,6 @@ boot-manager/busconf/Makefile
 boot-manager/Makefile
 legacy-app-handler/Makefile
 nsm-dummy/busconf/Makefile
-nsm-dummy/dbus/Makefile
-nsm-dummy/systemd/Makefile
 nsm-dummy/Makefile
 tests/Makefile
 tests/boot-manager/Makefile
index 273e42a..b73f511 100644 (file)
@@ -1,9 +1,7 @@
 # vi:set ts=8 sw=8 noet ai nocindent:
 
 SUBDIRS =                                                              \
-       busconf                                                         \
-       dbus                                                            \
-       systemd
+       busconf
 
 nsm_dummydir =                                                         \
        $(libdir)/boot-manager-$(BOOT_MANAGER_VERSION_API)
@@ -46,3 +44,29 @@ nsm_dummy_LDADD =                                                    \
        $(SYSTEMD_DAEMON_LIBS)                                          \
        $(top_builddir)/common/libcommon.la
 
+%.service: %.service.in
+       sed -e "s,\@libdir\@,$(libdir),g"                               \
+           -e "s,\@BOOT_MANAGER_VERSION_API\@,$(BOOT_MANAGER_VERSION_API),g" < $< > $@
+
+dbus_servicedir = $(datadir)/dbus-1/system-services
+
+dbus_service_in_files =                                                        \
+       com.contiautomotive.NodeStateManager.Consumer.service.in        \
+       com.contiautomotive.NodeStateManager.LifecycleControl.service.in
+
+dbus_service_DATA = $(dbus_service_in_files:.service.in=.service)
+
+systemd_servicedir = ${libdir}/systemd/system
+
+systemd_service_in_files =                                             \
+       nsm-dummy.service.in
+
+systemd_service_DATA = $(systemd_service_in_files:.service.in=.service)
+
+CLEANFILES =                                                           \
+       $(dbus_service_DATA)                                            \
+       $(systemd_service_DATA)
+
+EXTRA_DIST =                                                           \
+       $(dbus_service_in_files)                                        \
+       $(systemd_service_in_files)
index c8047ad..aa05965 100644 (file)
@@ -2,5 +2,8 @@
 
 nsm_dummy_confdir = $(sysconfdir)/dbus-1/system.d
 
-nsm_dummy_conf_DATA =                                          \
+nsm_dummy_conf_DATA =                                                  \
        com.contiautomotive.NodeStateManager.conf
+
+EXTRA_DIST =                                                           \
+       $(nsm_dummy_conf_DATA)
index 1ee9562..0b4aecb 100644 (file)
@@ -1,13 +1,25 @@
 # vi:set ts=8 sw=8 noet ai nocindent:
 
-TESTS =                                                                        \
+installcheck-local: $(noinst_SCRIPTS) $(noinst_PROGRAMS)
+       @echo "============================="
+       @echo "Running test for LUC handling"
+       @if ./test-luc-handler; then                                    \
+           echo "Test for LUC handling passed";                        \
+       else                                                            \
+           echo "Test for LUC handling failed";                        \
+       fi
+       @echo "============================="
+
+noinst_SCRIPTS =                                                       \
        test-luc-handler
 
 EXTRA_DIST =                                                           \
        test-luc-handler
 
-export LUC_PATH =                                                      \
-       $(sysconfdir)/boot-manager/last-user-context
+export LUC_PATH = last-user-context
+
+export BOOT_MANAGER_CMD =                                              \
+       $(libdir)/boot-manager-$(BOOT_MANAGER_VERSION_API)/boot-manager
 
 noinst_PROGRAMS =                                                      \
        gvariant-writer
index 5785910..003877d 100755 (executable)
@@ -1,8 +1,11 @@
 #!/bin/bash
 
+
 #set -e
+#set -x
+
 
-#function to compare the LastUserContext
+# function to compare the LastUserContext
 # $1 is the context
 # $2 is the path to the file to compare the context to
 compare_luc()
@@ -11,6 +14,7 @@ compare_luc()
   diff -q "$LUC_PATH" "$2"
 }
 
+
 # function to begin registration
 begin()
 {
@@ -21,6 +25,7 @@ begin()
      &> /dev/null
 }
 
+
 # function to make a registration call
 register()
 {
@@ -31,6 +36,7 @@ register()
     "$1" &> /dev/null
 }
 
+
 # function to begin registration
 end()
 {
@@ -49,28 +55,46 @@ fail()
   exit 1
 }
 
+
+# clean up before running the test scripts
 rm -f temp
 rm -f "$LUC_PATH"
 
 
-#Test a simple dictionary
+# kill any existing instances of the boot manager
+skill -SIGKILL boot-manager 2>&1 >/dev/null
+
+# start the boot manager manually
+$BOOT_MANAGER_CMD &
+
+# wait for ten seconds, hoping the boot manager will become available
+sleep 2
+
+# kill the boot manager when the test script exits
+trap "skill -SIGKILL boot-manager 2>&1 >/dev/null" EXIT
+
+
+# test a simple dictionary
 begin
 register "{0: ['app1.unit']}"
 end
 [ -z "$(compare_luc "{0: ['app1.unit']}" "temp")" ] \
   || fail "Registration was not identical"
 
-#Test whether RegisterWithLUC() writes by itself
+
+# test whether RegisterWithLUC() writes by itself
 register "{1: ['app2.service']}"
 [ "$(compare_luc "{1: ['app2.service']}" "temp" )" ] \
   || fail "Registration happened with only RegisterWithLUC() called"
 
-#Test whether calling FinishLUCRegistration() by itself changes the file
+
+# test whether calling FinishLUCRegistration() by itself changes the file
 end
 [ -z "$(compare_luc "{0: ['app1.unit']}" "temp")" ] \
   || fail "FinishLUCRegistration() without BeginLUCRegistration() changed the file"
 
-#Test whether a complex dictionary works
+
+# test whether a complex dictionary works
 dict="{0: ['app1.unit'], 1: ['app1.unit', 'app3.unit'], 2: ['app2.unit']}"
 begin
 register "$dict"
@@ -78,7 +102,8 @@ end
 [ -z "$(compare_luc "$dict" "temp")" ] \
   || fail "Failed to register a complex dictionary type"
 
-#Test with multiple RegisterWithLUC() calls
+
+# test with multiple RegisterWithLUC() calls
 dict="{0: ['app1.unit'], 1: ['app3.unit']}"
 begin
 register "{0: ['app1.unit']}"
@@ -87,7 +112,8 @@ end
 [ -z "$(compare_luc "$dict" "temp")" ] \
   || fail "Failed to register correctly when multiple calls are used"
 
-#Test that using multiply RegisterWithLUC() calls changes the order of the apps
+
+# test that using multiply RegisterWithLUC() calls changes the order of the apps
 dict="{1: ['app2.unit', 'app1.unit']}"
 begin
 register "{1: ['app1.unit', 'app2.unit']}"
index 15b21e0..7757305 100644 (file)
@@ -1,32 +1,23 @@
 # vi:set ts=8 sw=8 noet ai nocindent:
 
-testscriptdir = $(libdir)/boot-manager-$(BOOT_MANAGER_VERSION_API)
-
-testscript_DATA =                                                      \
-       legacy-app-handler-test
-
-testconfdir = $(sysconfdir)/dbus-1/system.d
-
-testconf_DATA =                                                                \
-       legacy-app-handler-test.conf
-
-servicedir = $(libdir)/systemd/system
-
 service_in_files =                                                     \
        legacy-app-handler-test1.service.in                             \
        legacy-app-handler-test2.service.in                             \
        legacy-app-handler-test3.service.in
 
-service_DATA = $(service_in_files:.service.in=.service)
+noinst_DATA =                                                          \
+       legacy-app-handler-test                                         \
+       legacy-app-handler-test.conf                                    \
+       $(service_in_files:.service.in=.service)
 
 %.service: %.service.in
        sed -e "s,\@libdir\@,$(libdir),g"                               \
            -e "s,\@BOOT_MANAGER_VERSION_API\@,$(BOOT_MANAGER_VERSION_API),g" < $< > $@
 
 CLEANFILES =                                                           \
-       $(service_DATA)
+       *.service
 
 EXTRA_DIST =                                                           \
-       $(service_in_files)                                             \
-       $(testconf_DATA)                                                \
-       $(testscript_DATA)
+       legacy-app-handler-test                                         \
+       legacy-app-handler-test.conf                                    \
+       $(service_in_files)