plugins,test: setup new simple keyfile tester

This commit is contained in:
Aleksander Morgado
2018-12-16 13:23:34 +01:00
parent 2719265cbd
commit 147facd2ec
3 changed files with 99 additions and 1 deletions

1
.gitignore vendored
View File

@@ -163,6 +163,7 @@ Makefile.in
/plugins/test-suite.log
/plugins/test-udev-rules
/plugins/test-keyfiles
/plugins/test-modem-helpers-*
/plugins/test-service-*

View File

@@ -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
@@ -1134,6 +1137,18 @@ test_udev_rules_LDADD = \
$(top_builddir)/libmm-glib/libmm-glib.la \
$(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)

View File

@@ -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 ();
}