From 8e0c10ee607cfea17167fbcd540b18d7f23d9fec Mon Sep 17 00:00:00 2001 From: Bruno Haible
Date: Thu, 28 Sep 2017 00:31:04 +0200 Subject: [PATCH 2/2] Tests for module 'strlcpy'. * tests/test-strlcpy.c: New file, based on tests/unistr/test-strncpy.h. * modules/strlcpy-tests: New file. * tests/test-string-c++.cc: Check the signature of strlcpy. --- ChangeLog | 5 ++ modules/strlcpy-tests | 19 ++++++++ tests/test-string-c++.cc | 5 ++ tests/test-strlcpy.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 modules/strlcpy-tests create mode 100644 tests/test-strlcpy.c diff --git a/ChangeLog b/ChangeLog index c005f1c..8fa21e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2017-09-27 Bruno Haible + Tests for module 'strlcpy'. + * tests/test-strlcpy.c: New file, based on tests/unistr/test-strncpy.h. + * modules/strlcpy-tests: New file. + * tests/test-string-c++.cc: Check the signature of strlcpy. + New module 'strlcpy'. * lib/string.in.h (_GL_ATTRIBUTE_RETURN_CHECK): New macro. (strlcpy): New declaration. diff --git a/modules/strlcpy-tests b/modules/strlcpy-tests new file mode 100644 index 0000000..fab82e2 --- /dev/null +++ b/modules/strlcpy-tests @@ -0,0 +1,19 @@ +Files: +tests/test-strlcpy.c +tests/zerosize-ptr.h +tests/macros.h +m4/mmap-anon.m4 + +Depends-on: +extensions +getpagesize + +configure.ac: +gl_FUNC_MMAP_ANON +AC_CHECK_HEADERS_ONCE([sys/mman.h]) +AC_CHECK_FUNCS_ONCE([mprotect]) + +Makefile.am: +TESTS += test-strlcpy +check_PROGRAMS += test-strlcpy +test_strlcpy_SOURCES = test-strlcpy.c diff --git a/tests/test-string-c++.cc b/tests/test-string-c++.cc index 877cf68..c3df903 100644 --- a/tests/test-string-c++.cc +++ b/tests/test-string-c++.cc @@ -142,6 +142,11 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::strerror_r, int, (int, char *, size_t)); SIGNATURE_CHECK (GNULIB_NAMESPACE::strsignal, char *, (int)); #endif +#if GNULIB_TEST_STRLCPY +SIGNATURE_CHECK (GNULIB_NAMESPACE::strlcpy, size_t, + (char *, const char *, size_t)); +#endif + #if GNULIB_TEST_STRVERSCMP SIGNATURE_CHECK (GNULIB_NAMESPACE::strverscmp, int, (const char *, const char *)); diff --git a/tests/test-strlcpy.c b/tests/test-strlcpy.c new file mode 100644 index 0000000..9d5eee9 --- /dev/null +++ b/tests/test-strlcpy.c @@ -0,0 +1,117 @@ +/* Tests of strlcpy(). + Copyright (C) 2010-2017 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 + the Free Software Foundation; either version 3 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, see