[network-manager-vpnc/th/vpn-editor-split-bgo766170: 7/19] properties/tests: refactor tests to run via TESTS instead of check-local target
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-vpnc/th/vpn-editor-split-bgo766170: 7/19] properties/tests: refactor tests to run via TESTS instead of check-local target
- Date: Sat, 14 May 2016 21:57:19 +0000 (UTC)
commit e79a03561c2d3f35bf2520ba1dc93f5d0495c4e8
Author: Thomas Haller <thaller redhat com>
Date: Mon May 9 10:45:21 2016 +0200
properties/tests: refactor tests to run via TESTS instead of check-local target
And thus, don't expect the test-paths as command line arguments.
.gitignore | 4 +++
nm-test-helpers.h | 2 +-
properties/tests/Makefile.am | 19 ++++++-------
properties/tests/test-import-export.c | 48 +++++++++++++++++++-------------
4 files changed, 42 insertions(+), 31 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 536c35c..f327b7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,10 @@ m4/libtool.m4
m4/lt*.m4
appdata/network-manager-vpnc.metainfo.xml
+/test-driver
+*/tests/*.log
+*/tests/*.trs
+
/cscope.*
auth-dialog/nm-vpnc-auth-dialog
diff --git a/nm-test-helpers.h b/nm-test-helpers.h
index 840e25f..5015a1b 100644
--- a/nm-test-helpers.h
+++ b/nm-test-helpers.h
@@ -37,7 +37,7 @@ FAIL(const char *test_name, const char *fmt, ...)
va_start (args, fmt);
vfprintf (stderr, buf, args);
va_end (args);
- _exit (1);
+ g_assert_not_reached ();
}
#define ASSERT(x, test_name, fmt, ...) \
diff --git a/properties/tests/Makefile.am b/properties/tests/Makefile.am
index 6602ef1..301dacf 100644
--- a/properties/tests/Makefile.am
+++ b/properties/tests/Makefile.am
@@ -1,6 +1,7 @@
-SUBDIRS=pcf
+SUBDIRS = pcf
-noinst_PROGRAMS = test-import-export
+noinst_PROGRAMS = \
+ test-import-export
test_import_export_SOURCES = \
test-import-export.c
@@ -13,7 +14,10 @@ test_import_export_CPPFLAGS = \
$(DBUS_CFLAGS) \
-I"$(top_srcdir)/" \
-I"$(top_srcdir)/shared/" \
- -I"$(top_srcdir)/properties/"
+ -I"$(top_srcdir)/properties/" \
+ -DTEST_SRCDIR="\"$(abs_srcdir)\"" \
+ -DTEST_BUILDDIR="\"$(abs_builddir)\""
+
test_import_export_LDADD = \
$(GTHREAD_LIBS) \
@@ -23,10 +27,5 @@ test_import_export_LDADD = \
$(LIBNMA_LIBS) \
$(top_builddir)/properties/libnm-vpn-plugin-vpnc.la
-if WITH_TESTS
-
-check-local: test-import-export
- $(abs_builddir)/test-import-export $(abs_srcdir)/pcf $(abs_builddir)/pcf
-
-endif
-
+TESTS = \
+ test-import-export
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index a7d5009..a34f721 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -22,6 +22,7 @@
#include "nm-default.h"
#include <string.h>
+#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <locale.h>
@@ -32,6 +33,9 @@
#include "nm-test-helpers.h"
#include "nm-utils/nm-test-utils.h"
+#define SRCDIR TEST_SRCDIR"/pcf"
+#define TMPDIR TEST_BUILDDIR"/pcf-tmp"
+
typedef struct {
const char *name;
const char *value;
@@ -747,16 +751,20 @@ test_empty_keyfile_string_null (const char *dir)
int main (int argc, char **argv)
{
GError *error = NULL;
+ int errsv;
char *basename;
NMVpnEditorPlugin *plugin = NULL;
- if (argc != 3)
- FAIL ("args", "usage: %s <pcf path> <tmp path>", argv[0]);
-
#if !GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
#endif
+ if (mkdir (TMPDIR, 0755) != 0) {
+ errsv = errno;
+ if (errsv != EEXIST)
+ g_error ("failed creating \"%s\": %s", TMPDIR, g_strerror (errsv));
+ }
+
plugin = nm_vpn_editor_plugin_factory (&error);
if (error)
FAIL ("plugin-init", "failed to initialize UI plugin: %s", error->message);
@@ -764,23 +772,23 @@ int main (int argc, char **argv)
"plugin-init", "failed to initialize UI plugin");
/* The tests */
- test_basic_import (plugin, argv[1]);
- test_everything_via_vpn (plugin, argv[1]);
- test_no_natt (plugin, argv[1]);
- test_nat_cisco (plugin, argv[1]);
- test_nat_natt (plugin, argv[1]);
- test_nat_force_natt (plugin, argv[1]);
- test_always_ask (plugin, argv[1]);
- test_non_utf8_import (plugin, argv[1]);
- test_legacy_ike_port_0_import (plugin, argv[1]);
- test_legacy_ike_port_1_import (plugin, argv[1]);
-
- test_basic_export (plugin, argv[1], argv[2]);
- test_nat_export (plugin, argv[1], argv[2], NM_VPNC_NATT_MODE_CISCO);
- test_nat_export (plugin, argv[1], argv[2], NM_VPNC_NATT_MODE_NATT);
- test_nat_export (plugin, argv[1], argv[2], NM_VPNC_NATT_MODE_NATT_ALWAYS);
-
- test_empty_keyfile_string_null (argv[1]);
+ test_basic_import (plugin, SRCDIR);
+ test_everything_via_vpn (plugin, SRCDIR);
+ test_no_natt (plugin, SRCDIR);
+ test_nat_cisco (plugin, SRCDIR);
+ test_nat_natt (plugin, SRCDIR);
+ test_nat_force_natt (plugin, SRCDIR);
+ test_always_ask (plugin, SRCDIR);
+ test_non_utf8_import (plugin, SRCDIR);
+ test_legacy_ike_port_0_import (plugin, SRCDIR);
+ test_legacy_ike_port_1_import (plugin, SRCDIR);
+
+ test_basic_export (plugin, SRCDIR, TMPDIR);
+ test_nat_export (plugin, SRCDIR, TMPDIR, NM_VPNC_NATT_MODE_CISCO);
+ test_nat_export (plugin, SRCDIR, TMPDIR, NM_VPNC_NATT_MODE_NATT);
+ test_nat_export (plugin, SRCDIR, TMPDIR, NM_VPNC_NATT_MODE_NATT_ALWAYS);
+
+ test_empty_keyfile_string_null (SRCDIR);
g_object_unref (plugin);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]