diff options
author | Simon McVittie <smcv@collabora.com> | 2018-09-28 16:46:41 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2019-01-21 15:22:05 +0000 |
commit | cccb35dfef8ac4e28594154f8a9a6337fd9d8d7f (patch) | |
tree | d6a8c1beee4ddf06d6a809104c3f1ae247bff2dc /dbus/dbus-sysdeps-util.c | |
parent | b1cfd892fc69a08baa9e3351949630fbea7a6943 (diff) | |
download | dbus-cccb35dfef8ac4e28594154f8a9a6337fd9d8d7f.tar.gz |
test: Move sysdeps tests here
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus/dbus-sysdeps-util.c')
-rw-r--r-- | dbus/dbus-sysdeps-util.c | 127 |
1 files changed, 5 insertions, 122 deletions
diff --git a/dbus/dbus-sysdeps-util.c b/dbus/dbus-sysdeps-util.c index 4a7d08cc..66af910e 100644 --- a/dbus/dbus-sysdeps-util.c +++ b/dbus/dbus-sysdeps-util.c @@ -1,8 +1,11 @@ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-sysdeps-util.c Tests for dbus-sysdeps.h API * - * Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc. - * Copyright (C) 2003 CodeFactory AB + * Copyright 2002-2008 Red Hat, Inc. + * Copyright 2003 CodeFactory AB + * Copyright 2006 Ralf Habacker + * Copyright 2006 Sjoerd Simons + * Copyright 2016-2018 Collabora Ltd. * * Licensed under the Academic Free License version 2.1 * @@ -26,8 +29,6 @@ #include "dbus-sysdeps.h" #include "dbus-internals.h" #include "dbus-string.h" -#include "dbus-test.h" -#include <dbus/dbus-test-tap.h> #include <stdlib.h> @@ -82,121 +83,3 @@ _dbus_get_environment (void) return environment; } - -#ifdef DBUS_ENABLE_EMBEDDED_TESTS -static void -check_dirname (const char *filename, - const char *dirname) -{ - DBusString f, d; - - _dbus_string_init_const (&f, filename); - - if (!_dbus_string_init (&d)) - _dbus_test_fatal ("no memory"); - - if (!_dbus_string_get_dirname (&f, &d)) - _dbus_test_fatal ("no memory"); - - if (!_dbus_string_equal_c_str (&d, dirname)) - { - _dbus_warn ("For filename \"%s\" got dirname \"%s\" and expected \"%s\"", - filename, - _dbus_string_get_const_data (&d), - dirname); - exit (1); - } - - _dbus_string_free (&d); -} - -static void -check_path_absolute (const char *path, - dbus_bool_t expected) -{ - DBusString p; - - _dbus_string_init_const (&p, path); - - if (_dbus_path_is_absolute (&p) != expected) - { - _dbus_warn ("For path \"%s\" expected absolute = %d got %d", - path, expected, _dbus_path_is_absolute (&p)); - exit (1); - } -} - -/** - * Unit test for dbus-sysdeps.c. - * - * @returns #TRUE on success. - */ -dbus_bool_t -_dbus_sysdeps_test (const char *test_data_dir _DBUS_GNUC_UNUSED) -{ -#ifdef DBUS_WIN - check_dirname ("foo\\bar", "foo"); - check_dirname ("foo\\\\bar", "foo"); - check_dirname ("foo/\\/bar", "foo"); - check_dirname ("foo\\bar/", "foo"); - check_dirname ("foo//bar\\", "foo"); - check_dirname ("foo\\bar/", "foo"); - check_dirname ("foo/bar\\\\", "foo"); - check_dirname ("\\foo", "\\"); - check_dirname ("\\\\foo", "\\"); - check_dirname ("\\", "\\"); - check_dirname ("\\\\", "\\"); - check_dirname ("\\/", "\\"); - check_dirname ("/\\/", "/"); - check_dirname ("c:\\foo\\bar", "c:\\foo"); - check_dirname ("c:\\foo", "c:\\"); - check_dirname ("c:/foo", "c:/"); - check_dirname ("c:\\", "c:\\"); - check_dirname ("c:/", "c:/"); - check_dirname ("", "."); -#else - check_dirname ("foo", "."); - check_dirname ("foo/bar", "foo"); - check_dirname ("foo//bar", "foo"); - check_dirname ("foo///bar", "foo"); - check_dirname ("foo/bar/", "foo"); - check_dirname ("foo//bar/", "foo"); - check_dirname ("foo///bar/", "foo"); - check_dirname ("foo/bar//", "foo"); - check_dirname ("foo//bar////", "foo"); - check_dirname ("foo///bar///////", "foo"); - check_dirname ("/foo", "/"); - check_dirname ("////foo", "/"); - check_dirname ("/foo/bar", "/foo"); - check_dirname ("/foo//bar", "/foo"); - check_dirname ("/foo///bar", "/foo"); - check_dirname ("/", "/"); - check_dirname ("///", "/"); - check_dirname ("", "."); -#endif - -#ifdef DBUS_WIN - check_path_absolute ("c:/", TRUE); - check_path_absolute ("c:/foo", TRUE); - check_path_absolute ("", FALSE); - check_path_absolute ("foo", FALSE); - check_path_absolute ("foo/bar", FALSE); - check_path_absolute ("", FALSE); - check_path_absolute ("foo\\bar", FALSE); - check_path_absolute ("c:\\", TRUE); - check_path_absolute ("c:\\foo", TRUE); - check_path_absolute ("c:", TRUE); - check_path_absolute ("c:\\foo\\bar", TRUE); - check_path_absolute ("\\", TRUE); - check_path_absolute ("/", TRUE); -#else - check_path_absolute ("/", TRUE); - check_path_absolute ("/foo", TRUE); - check_path_absolute ("", FALSE); - check_path_absolute ("foo", FALSE); - check_path_absolute ("foo/bar", FALSE); -#endif - - return TRUE; -} -#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ |