summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-12-16 13:23:34 +0100
committerAleksander Morgado <aleksander@aleksander.es>2019-03-03 23:16:59 +0100
commit79b251a8f739a1da13faef5525f10b20d9e90537 (patch)
treec273086eccd5a0d261d568597f6d4ae370dbb889
parent4431224d85516fd8bd49f0a6bdac00ebd24ddbed (diff)
downloadModemManager-79b251a8f739a1da13faef5525f10b20d9e90537.tar.gz
plugins,test: setup new simple keyfile tester
-rw-r--r--.gitignore1
-rw-r--r--plugins/Makefile.am17
-rw-r--r--plugins/tests/test-keyfiles.c82
3 files changed, 99 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 9846a32f4..73c75c372 100644
--- a/.gitignore
+++ b/.gitignore
@@ -163,6 +163,7 @@ Makefile.in
/plugins/test-suite.log
/plugins/test-udev-rules
+/plugins/test-keyfiles
/plugins/test-modem-helpers-*
/plugins/test-service-*
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 2e7660ab5..016ef55e4 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1080,7 +1080,10 @@ dist_udevrules_DATA += dell/77-mm-dell-port-types.rules
dist_pkgdata_DATA += dell/mm-dell-dw5821e-carrier-mapping.conf
-AM_CFLAGS += -DTESTUDEVRULESDIR_DELL=\"${srcdir}/dell\"
+AM_CFLAGS += \
+ -DTESTUDEVRULESDIR_DELL=\"${srcdir}/dell\" \
+ -DTESTKEYFILE_DELL_DW5821E=\"${srcdir}/dell/mm-dell-dw5821e-carrier-mapping.conf\" \
+ $(NULL)
################################################################################
# plugin: quectel
@@ -1135,5 +1138,17 @@ test_udev_rules_LDADD = \
$(NULL)
################################################################################
+# keyfile tester
+################################################################################
+
+noinst_PROGRAMS += test-keyfiles
+test_keyfiles_SOURCES = \
+ tests/test-keyfiles.c \
+ $(NULL)
+test_keyfiles_LDADD = \
+ $(top_builddir)/libmm-glib/libmm-glib.la \
+ $(NULL)
+
+################################################################################
TEST_PROGS += $(noinst_PROGRAMS)
diff --git a/plugins/tests/test-keyfiles.c b/plugins/tests/test-keyfiles.c
new file mode 100644
index 000000000..9604643ee
--- /dev/null
+++ b/plugins/tests/test-keyfiles.c
@@ -0,0 +1,82 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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:
+ *
+ * Copyright (C) 2018 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <string.h>
+#include <stdio.h>
+#include <locale.h>
+
+#define _LIBMM_INSIDE_MM
+#include <libmm-glib.h>
+
+#include "mm-log.h"
+
+/************************************************************/
+
+static void
+common_test (const gchar *keyfile_path)
+{
+ GKeyFile *keyfile;
+ GError *error = NULL;
+ gboolean ret;
+
+ keyfile = g_key_file_new ();
+ ret = g_key_file_load_from_file (keyfile, keyfile_path, G_KEY_FILE_NONE, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_key_file_unref (keyfile);
+}
+
+/************************************************************/
+
+static void
+test_dell_dw5821e (void)
+{
+ common_test (TESTKEYFILE_DELL_DW5821E);
+}
+
+/************************************************************/
+
+void
+_mm_log (const char *loc,
+ const char *func,
+ guint32 level,
+ const char *fmt,
+ ...)
+{
+#if defined ENABLE_TEST_MESSAGE_TRACES
+ /* Dummy log function */
+ va_list args;
+ gchar *msg;
+
+ va_start (args, fmt);
+ msg = g_strdup_vprintf (fmt, args);
+ va_end (args);
+ g_print ("%s\n", msg);
+ g_free (msg);
+#endif
+}
+
+int main (int argc, char **argv)
+{
+ setlocale (LC_ALL, "");
+
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/MM/test-keyfiles/dell/dw5821e", test_dell_dw5821e);
+
+ return g_test_run ();
+}