From 3bd9c3d70ab02c439c0a6880127d5c28c3017e6e Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 7 Aug 2018 10:54:41 +0200 Subject: [PATCH] glob-h: Add tests. * tests/test-glob-h.c: New file, partially based on tests/test-glob.c. * tests/test-glob.c: Reorder #includes. Remove tests that are moved to tests/test-glob-h.c. * modules/glob-h-tests: New file. * tests/test-glob-h-c++.cc: Renamed from tests/test-glob-c++.cc. Add conditions. * modules/glob-h-c++-tests: Renamed from modules/glob-c++-tests. * modules/glob-tests (Depends-on): Remove glob-c++-tests. --- ChangeLog | 12 +++++++ modules/glob-c++-tests | 19 ----------- modules/glob-h-c++-tests | 19 +++++++++++ modules/glob-h-tests | 12 +++++++ modules/glob-tests | 1 - tests/{test-glob-c++.cc => test-glob-h-c++.cc} | 8 ++++- tests/{test-glob-c++.cc => test-glob-h.c} | 47 ++++++++++++++++++-------- tests/test-glob.c | 10 ++---- 8 files changed, 85 insertions(+), 43 deletions(-) delete mode 100644 modules/glob-c++-tests create mode 100644 modules/glob-h-c++-tests create mode 100644 modules/glob-h-tests copy tests/{test-glob-c++.cc => test-glob-h-c++.cc} (87%) rename tests/{test-glob-c++.cc => test-glob-h.c} (51%) diff --git a/ChangeLog b/ChangeLog index 2873cd0fa8..a1c0abbaba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2018-08-07 Bruno Haible + glob-h: Add tests. + * tests/test-glob-h.c: New file, partially based on tests/test-glob.c. + * tests/test-glob.c: Reorder #includes. Remove tests that are moved to + tests/test-glob-h.c. + * modules/glob-h-tests: New file. + * tests/test-glob-h-c++.cc: Renamed from tests/test-glob-c++.cc. Add + conditions. + * modules/glob-h-c++-tests: Renamed from modules/glob-c++-tests. + * modules/glob-tests (Depends-on): Remove glob-c++-tests. + +2018-08-07 Bruno Haible + glob-h: New module. * lib/glob.in.h: Use nearly the usual gnulib idioms for header file replacements. diff --git a/modules/glob-c++-tests b/modules/glob-c++-tests deleted file mode 100644 index daa3ec71ac..0000000000 --- a/modules/glob-c++-tests +++ /dev/null @@ -1,19 +0,0 @@ -Files: -tests/test-glob-c++.cc -tests/signature.h - -Status: -c++-test - -Depends-on: -ansi-c++-opt - -configure.ac: - -Makefile.am: -if ANSICXX -TESTS += test-glob-c++ -check_PROGRAMS += test-glob-c++ -test_glob_c___SOURCES = test-glob-c++.cc -test_glob_c___LDADD = $(LDADD) $(LIBINTL) $(LIB_CLOCK_GETTIME) -endif diff --git a/modules/glob-h-c++-tests b/modules/glob-h-c++-tests new file mode 100644 index 0000000000..de42019ea9 --- /dev/null +++ b/modules/glob-h-c++-tests @@ -0,0 +1,19 @@ +Files: +tests/test-glob-h-c++.cc +tests/signature.h + +Status: +c++-test + +Depends-on: +ansi-c++-opt + +configure.ac: + +Makefile.am: +if ANSICXX +TESTS += test-glob-h-c++ +check_PROGRAMS += test-glob-h-c++ +test_glob_h_c___SOURCES = test-glob-h-c++.cc +test_glob_h_c___LDADD = $(LDADD) $(LIBINTL) $(LIB_CLOCK_GETTIME) +endif diff --git a/modules/glob-h-tests b/modules/glob-h-tests new file mode 100644 index 0000000000..0e9e5bd8d8 --- /dev/null +++ b/modules/glob-h-tests @@ -0,0 +1,12 @@ +Files: +tests/test-glob-h.c +tests/macros.h + +Depends-on: +glob-h-c++-tests + +configure.ac: + +Makefile.am: +TESTS += test-glob-h +check_PROGRAMS += test-glob-h diff --git a/modules/glob-tests b/modules/glob-tests index abc3666edd..3adbe6c80e 100644 --- a/modules/glob-tests +++ b/modules/glob-tests @@ -4,7 +4,6 @@ tests/signature.h tests/macros.h Depends-on: -glob-c++-tests symlink configure.ac: diff --git a/tests/test-glob-c++.cc b/tests/test-glob-h-c++.cc similarity index 87% copy from tests/test-glob-c++.cc copy to tests/test-glob-h-c++.cc index ec0150a3e7..ff644bd8cf 100644 --- a/tests/test-glob-c++.cc +++ b/tests/test-glob-h-c++.cc @@ -24,12 +24,18 @@ #include "signature.h" +#if GNULIB_TEST_GLOB SIGNATURE_CHECK (GNULIB_NAMESPACE::glob, int, (const char *, int, _gl_glob_errfunc_fn, glob_t *)); +#endif +#if GNULIB_TEST_GLOB SIGNATURE_CHECK (GNULIB_NAMESPACE::globfree, void, (glob_t *)); +#endif -//SIGNATURE_CHECK (GNULIB_NAMESPACE::glob_pattern_p, int, (const char *, int)); +#if GNULIB_TEST_GLOB +SIGNATURE_CHECK (GNULIB_NAMESPACE::glob_pattern_p, int, (const char *, int)); +#endif int diff --git a/tests/test-glob-c++.cc b/tests/test-glob-h.c similarity index 51% rename from tests/test-glob-c++.cc rename to tests/test-glob-h.c index ec0150a3e7..88caecb4fd 100644 --- a/tests/test-glob-c++.cc +++ b/tests/test-glob-h.c @@ -1,5 +1,5 @@ -/* Test of glob/globfree functions in C++ mode. - Copyright (C) 2010-2018 Free Software Foundation, Inc. +/* Test of substitute. + Copyright (C) 2009-2018 Free Software Foundation, Inc. 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 @@ -14,25 +14,44 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Written by Bruno Haible , 2010. */ +/* Written by Simon Josefsson , 2009. */ -#define GNULIB_NAMESPACE gnulib #include #include -#include "signature.h" - - -SIGNATURE_CHECK (GNULIB_NAMESPACE::glob, int, - (const char *, int, _gl_glob_errfunc_fn, glob_t *)); - -SIGNATURE_CHECK (GNULIB_NAMESPACE::globfree, void, (glob_t *)); - -//SIGNATURE_CHECK (GNULIB_NAMESPACE::glob_pattern_p, int, (const char *, int)); - +#include "macros.h" + +/* Check that size_t is defined. */ +size_t a; + +/* Check that the various GLOB_* macros are defined. */ +int flags[] = + { + GLOB_APPEND, + GLOB_DOOFFS, + GLOB_ERR, + GLOB_MARK, + GLOB_NOCHECK, + GLOB_NOESCAPE, + GLOB_NOSORT + }; +int ret[] = + { + GLOB_ABORTED, + GLOB_NOMATCH, + GLOB_NOSPACE + }; int main () { + glob_t g; + + /* Make sure glob_t struct members exists. */ + ASSERT (sizeof (g.gl_pathc)); + ASSERT (sizeof (g.gl_pathv)); + ASSERT (sizeof (g.gl_offs)); + + return 0; } diff --git a/tests/test-glob.c b/tests/test-glob.c index 50b20ea6a6..cd21b5c371 100644 --- a/tests/test-glob.c +++ b/tests/test-glob.c @@ -20,15 +20,14 @@ #include -#include -#include - #include "signature.h" SIGNATURE_CHECK (glob, int, (char const *, int, int (*) (char const *, int), glob_t *)); SIGNATURE_CHECK (globfree, void, (glob_t *)); +#include #include +#include #include "macros.h" @@ -41,11 +40,6 @@ main () int res; glob_t g; - /* Make sure glob_t struct members exists. */ - ASSERT (sizeof (g.gl_pathc)); - ASSERT (sizeof (g.gl_pathv)); - ASSERT (sizeof (g.gl_offs)); - res = glob (".", 0, NULL, &g); ASSERT (res == 0 && g.gl_pathc == 1); globfree (&g); -- 2.11.4.GIT