mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 04:50:30 +01:00
move test functions somewhere commonly accessible
This commit is contained in:
parent
4aab9ff556
commit
59bc300cee
3 changed files with 52 additions and 20 deletions
|
|
@ -3,7 +3,8 @@ EXTRA_DIST = \
|
|||
NetworkManagerVPN.h \
|
||||
wireless-helper.h \
|
||||
nm-dbus-glib-types.h \
|
||||
nm-glib-compat.h
|
||||
nm-glib-compat.h \
|
||||
nm-test-helpers.h
|
||||
|
||||
NetworkManagerincludedir=$(includedir)/NetworkManager
|
||||
|
||||
|
|
|
|||
48
include/nm-test-helpers.h
Normal file
48
include/nm-test-helpers.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* (C) Copyright 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_TEST_HELPERS_H
|
||||
#define NM_TEST_HELPERS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
FAIL(const char *test_name, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[500];
|
||||
|
||||
snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt);
|
||||
|
||||
va_start (args, fmt);
|
||||
vfprintf (stderr, buf, args);
|
||||
va_end (args);
|
||||
_exit (1);
|
||||
}
|
||||
|
||||
#define ASSERT(x, test_name, fmt, ...) \
|
||||
if (!(x)) { \
|
||||
FAIL (test_name, fmt, ## __VA_ARGS__); \
|
||||
}
|
||||
|
||||
#endif /* NM_TEST_HELPERS_H */
|
||||
|
||||
|
|
@ -35,31 +35,14 @@
|
|||
#include <nm-setting-wireless.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
|
||||
#include "nm-test-helpers.h"
|
||||
|
||||
#include "reader.h"
|
||||
#include "writer.h"
|
||||
|
||||
#define TEST_WIRED_FILE TEST_KEYFILES_DIR"/Test_Wired_Connection"
|
||||
#define TEST_WIRELESS_FILE TEST_KEYFILES_DIR"/Test_Wireless_Connection"
|
||||
|
||||
static void
|
||||
FAIL(const char *test_name, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[500];
|
||||
|
||||
snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt);
|
||||
|
||||
va_start (args, fmt);
|
||||
vfprintf (stderr, buf, args);
|
||||
va_end (args);
|
||||
_exit (1);
|
||||
}
|
||||
|
||||
#define ASSERT(x, test_name, fmt, ...) \
|
||||
if (!(x)) { \
|
||||
FAIL (test_name, fmt, ## __VA_ARGS__); \
|
||||
}
|
||||
|
||||
static void
|
||||
test_read_valid_wired_connection (void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue