summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2018-03-31 18:29:58 -0700
committerRuss Allbery <eagle@eyrie.org>2018-04-01 16:14:31 -0700
commit62e412902ea3c8cd5a7d2c1349c4e073903c7f74 (patch)
treea30ce1f0016d0dc3d239f34736335121152a1c27 /tests
parentc28f50baa00835cb73804bd81d283e10ddf5d797 (diff)
Update to rra-c-util 7.1 and C TAP Harness 4.3
Validate command argument count, the length of command arguments, and the length of blocks of output from the server fit into the data type used in the wire protocol. Check the port argument to remctl and remctld to ensure that it is a valid port number. Update to rra-c-util 7.1: * Avoid spurious test failures from the network library. * Fix configure output when a Kerberos install prefix was provided. * Fix new warnings in GCC 7 and add new warning flags. * Fix all warnings from the Clang static analyzer. * Fix warnings under Clang with most warnings enabled. Update to C TAP Harness 4.3: * On test failures, report left/right instead of wanted/expected. * Fix string comparisons involving NULL pointers.
Diffstat (limited to 'tests')
-rw-r--r--tests/README8
-rwxr-xr-xtests/data/generate-krb5-conf6
-rw-r--r--tests/data/valgrind.supp76
-rwxr-xr-xtests/docs/pod-spelling-t6
-rwxr-xr-xtests/docs/pod-t6
-rwxr-xr-xtests/perl/module-version-t8
-rw-r--r--tests/portable/asprintf-t.c23
-rw-r--r--tests/portable/daemon-t.c18
-rw-r--r--tests/portable/getaddrinfo-t.c19
-rw-r--r--tests/portable/getnameinfo-t.c18
-rw-r--r--tests/portable/getopt-t.c6
-rw-r--r--tests/portable/inet_aton-t.c64
-rw-r--r--tests/portable/inet_ntoa-t.c28
-rw-r--r--tests/portable/inet_ntop-t.c30
-rw-r--r--tests/portable/mkstemp-t.c17
-rw-r--r--tests/portable/setenv-t.c18
-rw-r--r--tests/portable/snprintf-t.c11
-rw-r--r--tests/server/anonymous-t.c5
-rw-r--r--tests/server/user-t.c7
-rw-r--r--tests/tap/basic.c76
-rw-r--r--tests/tap/basic.h15
-rw-r--r--tests/tap/kerberos.c35
-rw-r--r--tests/tap/kerberos.h11
-rw-r--r--tests/tap/kerberos.sh6
-rw-r--r--tests/tap/libtap.sh4
-rw-r--r--tests/tap/macros.h4
-rw-r--r--tests/tap/messages.c9
-rw-r--r--tests/tap/messages.h7
-rw-r--r--tests/tap/perl/Test/RRA.pm57
-rw-r--r--tests/tap/perl/Test/RRA/Automake.pm78
-rw-r--r--tests/tap/perl/Test/RRA/Config.pm12
-rw-r--r--tests/tap/perl/Test/RRA/ModuleVersion.pm10
-rw-r--r--tests/tap/process.c16
-rw-r--r--tests/tap/process.h6
-rw-r--r--tests/tap/remctl.c6
-rw-r--r--tests/tap/remctl.h6
-rw-r--r--tests/tap/remctl.sh4
-rw-r--r--tests/tap/string.c6
-rw-r--r--tests/tap/string.h6
-rw-r--r--tests/util/buffer-t.c18
-rw-r--r--tests/util/fakewrite.c22
-rw-r--r--tests/util/fakewrite.h58
-rw-r--r--tests/util/fdflag-t.c6
-rw-r--r--tests/util/messages-krb5-t.c10
-rw-r--r--tests/util/messages-t.c145
-rw-r--r--tests/util/network/addr-ipv4-t.c11
-rw-r--r--tests/util/network/addr-ipv6-t.c17
-rw-r--r--tests/util/network/client-t.c14
-rw-r--r--tests/util/network/server-t.c36
-rw-r--r--tests/util/vector-t.c18
-rwxr-xr-xtests/util/xmalloc-t8
-rw-r--r--tests/util/xmalloc.c16
-rw-r--r--tests/util/xwrite-t.c37
53 files changed, 839 insertions, 325 deletions
diff --git a/tests/README b/tests/README
index ef91452..186d2d5 100644
--- a/tests/README
+++ b/tests/README
@@ -153,7 +153,7 @@ Writing TAP Tests
Complete API documentation for the basic C TAP library that comes with
C TAP Harness is available at:
- <http://www.eyrie.org/~eagle/software/c-tap-harness/>
+ <https://www.eyrie.org/~eagle/software/c-tap-harness/>
It's common to need additional test functions and utility functions
for your C tests, particularly if you have to set up and tear down a
@@ -170,7 +170,7 @@ Writing TAP Tests
Libraries of additional useful TAP test functions are available in
rra-c-util at:
- <http://www.eyrie.org/~eagle/software/rra-c-util/>
+ <https://www.eyrie.org/~eagle/software/rra-c-util/>
Some of the code there is particularly useful when testing programs
that require Kerberos keys.
@@ -240,7 +240,7 @@ Writing TAP Tests
License
This file is part of the documentation of C TAP Harness, which can be
- found at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ found at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
Copyright 2010, 2016 Russ Allbery <eagle@eyrie.org>
@@ -248,3 +248,5 @@ License
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty.
+
+ SPDX-License-Identifier: FSFAP
diff --git a/tests/data/generate-krb5-conf b/tests/data/generate-krb5-conf
index 47489bb..d116306 100755
--- a/tests/data/generate-krb5-conf
+++ b/tests/data/generate-krb5-conf
@@ -6,11 +6,11 @@
# sets the default realm as indicated.
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2006, 2007, 2008, 2010, 2011
+# Copyright 2006-2008, 2010-2011
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -30,6 +30,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
set -e
diff --git a/tests/data/valgrind.supp b/tests/data/valgrind.supp
index 8be538f..e6b50c0 100644
--- a/tests/data/valgrind.supp
+++ b/tests/data/valgrind.supp
@@ -8,10 +8,11 @@
# and related software.
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2011, 2012, 2013, 2014
+# Copyright 2017 Russ Allbery <eagle@eyrie.org>
+# Copyright 2011-2014
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -31,6 +32,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
{
dlopen-dlerror
@@ -39,6 +42,13 @@
fun:_dlerror_run
}
{
+ heimdal-base-once
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:heim_base_once_f
+}
+{
heimdal-gss-config
Memcheck:Leak
fun:*alloc
@@ -111,6 +121,29 @@
fun:krb5_gss_save_error_string
}
{
+ mit-gss-mechs
+ Memcheck:Leak
+ fun:glob
+ fun:loadConfigFiles
+ fun:updateMechList
+ fun:build_mechSet
+ fun:gss_indicate_mechs
+}
+{
+ mit-kadmin-ovku-error
+ Memcheck:Leak
+ fun:*alloc*
+ fun:initialize_ovku_error_table_r
+}
+{
+ mit-krb5-changepw
+ Memcheck:Leak
+ fun:*alloc
+ fun:change_set_password
+ fun:krb5_change_password
+ fun:krb5_get_init_creds_password
+}
+{
mit-krb5-pkinit-openssl-init
Memcheck:Leak
fun:*alloc
@@ -125,6 +158,13 @@
fun:krb5_preauth_request_context_init
}
{
+ mit-krb5-pkinit-openssl-request-2
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:k5_preauth_request_context_init
+}
+{
mit-krb5-plugin-dirs
Memcheck:Leak
fun:calloc
@@ -146,6 +186,38 @@
fun:register_module.isra.1
}
{
+ mit-krb5-preauth-init
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:k5_init_preauth_context
+}
+{
+ mit-krb5-preauth-init
+ Memcheck:Leak
+ fun:strdup
+ fun:add_to_list
+ fun:profile_get_values
+ ...
+ fun:clpreauth_prep_questions
+}
+{
+ mit-krb5-preauth-init-2
+ Memcheck:Leak
+ fun:*alloc
+ fun:init_list
+ fun:profile_get_values
+ ...
+ fun:clpreauth_prep_questions
+}
+{
+ mit-krb5-profile
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ fun:profile_open_file
+}
+{
portable-setenv
Memcheck:Leak
fun:malloc
diff --git a/tests/docs/pod-spelling-t b/tests/docs/pod-spelling-t
index 0b93f8d..0419c24 100755
--- a/tests/docs/pod-spelling-t
+++ b/tests/docs/pod-spelling-t
@@ -3,11 +3,11 @@
# Checks all POD files in the tree for spelling errors using Test::Spelling.
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2012, 2013, 2014
+# Copyright 2012-2014
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -27,6 +27,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
use 5.006;
use strict;
diff --git a/tests/docs/pod-t b/tests/docs/pod-t
index 7955306..7ea3409 100755
--- a/tests/docs/pod-t
+++ b/tests/docs/pod-t
@@ -4,11 +4,11 @@
# distribution, for POD formatting errors.
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2012, 2013, 2014
+# Copyright 2012-2014
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,6 +28,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
use 5.006;
use strict;
diff --git a/tests/perl/module-version-t b/tests/perl/module-version-t
index 4a45e77..878cc2d 100755
--- a/tests/perl/module-version-t
+++ b/tests/perl/module-version-t
@@ -9,6 +9,8 @@
#
# When given the --update option, instead fixes all of the Perl modules found
# to have the correct version.
+#
+# SPDX-License-Identifier: MIT
use 5.006;
use strict;
@@ -178,6 +180,10 @@ SOFTWARE.
=head1 SEE ALSO
This module is maintained in the rra-c-util package. The current version is
-available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/portable/asprintf-t.c b/tests/portable/asprintf-t.c
index e556d95..3b10a66 100644
--- a/tests/portable/asprintf-t.c
+++ b/tests/portable/asprintf-t.c
@@ -2,17 +2,19 @@
* asprintf and vasprintf test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2014, 2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2009, 2011
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
@@ -23,9 +25,10 @@
int test_asprintf(char **, const char *, ...)
__attribute__((__format__(printf, 2, 3)));
-int test_vasprintf(char **, const char *, va_list);
+int test_vasprintf(char **, const char *, va_list)
+ __attribute__((__format__(printf, 2, 0)));
-static int
+static int __attribute__((__format__(printf, 2, 3)))
vatest(char **result, const char *format, ...)
{
va_list args;
diff --git a/tests/portable/daemon-t.c b/tests/portable/daemon-t.c
index f3d473a..1cc6509 100644
--- a/tests/portable/daemon-t.c
+++ b/tests/portable/daemon-t.c
@@ -2,17 +2,19 @@
* daemon test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2014 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008-2009, 2011-2012
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
diff --git a/tests/portable/getaddrinfo-t.c b/tests/portable/getaddrinfo-t.c
index 5625099..d123010 100644
--- a/tests/portable/getaddrinfo-t.c
+++ b/tests/portable/getaddrinfo-t.c
@@ -2,17 +2,20 @@
* getaddrinfo test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2003-2005, 2016 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2015 Julien ÉLIE <julien@trigofacile.com>
+ * Copyright 2007-2009, 2011-2013
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
diff --git a/tests/portable/getnameinfo-t.c b/tests/portable/getnameinfo-t.c
index a8efe91..835c60e 100644
--- a/tests/portable/getnameinfo-t.c
+++ b/tests/portable/getnameinfo-t.c
@@ -2,17 +2,19 @@
* getnameinfo test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2005-2006, 2014 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2007-2011
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
diff --git a/tests/portable/getopt-t.c b/tests/portable/getopt-t.c
index 6e06282..3e3b564 100644
--- a/tests/portable/getopt-t.c
+++ b/tests/portable/getopt-t.c
@@ -2,10 +2,10 @@
* getopt test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2008, 2009
+ * Copyright 2008-2009
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
diff --git a/tests/portable/inet_aton-t.c b/tests/portable/inet_aton-t.c
index 346e861..4b22cc9 100644
--- a/tests/portable/inet_aton-t.c
+++ b/tests/portable/inet_aton-t.c
@@ -2,17 +2,19 @@
* inet_aton test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2000-2001, 2004, 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2007-2009, 2011
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
@@ -25,7 +27,7 @@ int test_inet_aton(const char *, struct in_addr *);
static void
-test_addr(const char *string, unsigned long addr)
+test_addr(const char *string, uint32_t addr)
{
int success;
struct in_addr in;
@@ -55,32 +57,32 @@ main(void)
plan(92);
test_addr( "0.0.0.0", 0);
- test_addr( "127.0.0.000000", 0x7f000000UL);
- test_addr( "255.255.255.255", 0xffffffffUL);
- test_addr( "172.200.232.199", 0xacc8e8c7UL);
- test_addr( "1.2.3.4", 0x01020304UL);
+ test_addr( "127.0.0.000000", 0x7f000000U);
+ test_addr( "255.255.255.255", 0xffffffffU);
+ test_addr( "172.200.232.199", 0xacc8e8c7U);
+ test_addr( "1.2.3.4", 0x01020304U);
test_addr( "0x0.0x0.0x0.0x0", 0);
- test_addr("0x7f.0x000.0x0.0x00", 0x7f000000UL);
- test_addr("0xff.0xFf.0xFF.0xff", 0xffffffffUL);
- test_addr("0xAC.0xc8.0xe8.0xC7", 0xacc8e8c7UL);
- test_addr("0xAa.0xbB.0xCc.0xdD", 0xaabbccddUL);
- test_addr("0xEe.0xfF.0.0x00000", 0xeeff0000UL);
- test_addr("0x1.0x2.0x00003.0x4", 0x01020304UL);
+ test_addr("0x7f.0x000.0x0.0x00", 0x7f000000U);
+ test_addr("0xff.0xFf.0xFF.0xff", 0xffffffffU);
+ test_addr("0xAC.0xc8.0xe8.0xC7", 0xacc8e8c7U);
+ test_addr("0xAa.0xbB.0xCc.0xdD", 0xaabbccddU);
+ test_addr("0xEe.0xfF.0.0x00000", 0xeeff0000U);
+ test_addr("0x1.0x2.0x00003.0x4", 0x01020304U);
test_addr( "000000.00.000.00", 0);
- test_addr( "0177.0", 0x7f000000UL);
- test_addr("0377.0377.0377.0377", 0xffffffffUL);
- test_addr("0254.0310.0350.0307", 0xacc8e8c7UL);
- test_addr("00001.02.3.00000004", 0x01020304UL);
-
- test_addr( "16909060", 0x01020304UL);
- test_addr( "172.062164307", 0xacc8e8c7UL);
- test_addr( "172.0xc8.0xe8c7", 0xacc8e8c7UL);
- test_addr( "127.1", 0x7f000001UL);
- test_addr( "0xffffffff", 0xffffffffUL);
- test_addr( "127.0xffffff", 0x7fffffffUL);
- test_addr( "127.127.0xffff", 0x7f7fffffUL);
+ test_addr( "0177.0", 0x7f000000U);
+ test_addr("0377.0377.0377.0377", 0xffffffffU);
+ test_addr("0254.0310.0350.0307", 0xacc8e8c7U);
+ test_addr("00001.02.3.00000004", 0x01020304U);
+
+ test_addr( "16909060", 0x01020304U);
+ test_addr( "172.062164307", 0xacc8e8c7U);
+ test_addr( "172.0xc8.0xe8c7", 0xacc8e8c7U);
+ test_addr( "127.1", 0x7f000001U);
+ test_addr( "0xffffffff", 0xffffffffU);
+ test_addr( "127.0xffffff", 0x7fffffffU);
+ test_addr( "127.127.0xffff", 0x7f7fffffU);
test_fail( "");
test_fail( "Donald Duck!");
diff --git a/tests/portable/inet_ntoa-t.c b/tests/portable/inet_ntoa-t.c
index 79764de..4a655ad 100644
--- a/tests/portable/inet_ntoa-t.c
+++ b/tests/portable/inet_ntoa-t.c
@@ -2,17 +2,19 @@
* inet_ntoa test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2000-2001, 2004, 2016-2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2009, 2011
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
@@ -25,7 +27,7 @@ char *test_inet_ntoa(struct in_addr);
static void
-test_addr(const char *expected, unsigned long addr)
+test_addr(const char *expected, uint32_t addr)
{
struct in_addr in;
@@ -40,10 +42,10 @@ main(void)
plan(5);
test_addr( "0.0.0.0", 0x0);
- test_addr( "127.0.0.0", 0x7f000000UL);
- test_addr("255.255.255.255", 0xffffffffUL);
- test_addr("172.200.232.199", 0xacc8e8c7UL);
- test_addr( "1.2.3.4", 0x01020304UL);
+ test_addr( "127.0.0.0", 0x7f000000U);
+ test_addr("255.255.255.255", 0xffffffffU);
+ test_addr("172.200.232.199", 0xacc8e8c7U);
+ test_addr( "1.2.3.4", 0x01020304U);
return 0;
}
diff --git a/tests/portable/inet_ntop-t.c b/tests/portable/inet_ntop-t.c
index d4dcf89..a95f6ff 100644
--- a/tests/portable/inet_ntop-t.c
+++ b/tests/portable/inet_ntop-t.c
@@ -2,17 +2,19 @@
* inet_ntop test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2005, 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2009, 2011
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
@@ -32,14 +34,14 @@ const char *test_inet_ntop(int, const void *, char *, socklen_t);
static void
-test_addr(const char *expected, unsigned long addr)
+test_addr(const char *expected, uint32_t addr)
{
struct in_addr in;
char result[INET_ADDRSTRLEN];
in.s_addr = htonl(addr);
if (test_inet_ntop(AF_INET, &in, result, sizeof(result)) == NULL) {
- printf("# cannot convert %lu: %s", addr, strerror(errno));
+ printf("# cannot convert %u: %s", addr, strerror(errno));
ok(0, "converting %s", expected);
} else
ok(1, "converting %s", expected);
@@ -60,10 +62,10 @@ main(void)
is_int(ENOSPC, errno, "...with right errno");
test_addr( "0.0.0.0", 0x0);
- test_addr( "127.0.0.0", 0x7f000000UL);
- test_addr("255.255.255.255", 0xffffffffUL);
- test_addr("172.200.232.199", 0xacc8e8c7UL);
- test_addr( "1.2.3.4", 0x01020304UL);
+ test_addr( "127.0.0.0", 0x7f000000U);
+ test_addr("255.255.255.255", 0xffffffffU);
+ test_addr("172.200.232.199", 0xacc8e8c7U);
+ test_addr( "1.2.3.4", 0x01020304U);
return 0;
}
diff --git a/tests/portable/mkstemp-t.c b/tests/portable/mkstemp-t.c
index 20a83fc..dc26821 100644
--- a/tests/portable/mkstemp-t.c
+++ b/tests/portable/mkstemp-t.c
@@ -2,17 +2,18 @@
* mkstemp test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009, 2011
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
diff --git a/tests/portable/setenv-t.c b/tests/portable/setenv-t.c
index 15ed1fd..92a8c95 100644
--- a/tests/portable/setenv-t.c
+++ b/tests/portable/setenv-t.c
@@ -2,17 +2,19 @@
* setenv test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2000-2006, 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2009, 2011
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
diff --git a/tests/portable/snprintf-t.c b/tests/portable/snprintf-t.c
index cc8cf00..7e8a68f 100644
--- a/tests/portable/snprintf-t.c
+++ b/tests/portable/snprintf-t.c
@@ -2,12 +2,11 @@
* snprintf test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006
- * Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010
+ * Copyright 2000-2006, 2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2010
* The Board of Trustees of the Leland Stanford Junior University
* Copyright 1995 Patrick Powell
* Copyright 2001 Hrvoje Niksic
@@ -15,6 +14,8 @@
* This code is based on code written by Patrick Powell (papowell@astart.com)
* It may be used for any purpose as long as this notice remains intact
* on all source code distributions
+ *
+ * There is no SPDX-License-Identifier registered for this license.
*/
#include <config.h>
@@ -159,7 +160,7 @@ main(void)
&count, string, &lcount);
is_int(0, count, "correct output from two %%n");
is_int(31, lcount, "correct output from long %%ln");
- test_format(true, "(null)", 6, "%s", NULL);
+ test_format(true, "(null)", 6, "%s", (char *) NULL);
for (i = 0; fp_formats[i] != NULL; i++)
for (j = 0; j < ARRAY_SIZE(fp_nums); j++) {
diff --git a/tests/server/anonymous-t.c b/tests/server/anonymous-t.c
index 32d1115..3c16b5d 100644
--- a/tests/server/anonymous-t.c
+++ b/tests/server/anonymous-t.c
@@ -1,7 +1,7 @@
/*
* Test suite for anonymous authentication.
*
- * Copyright 2015, 2016 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2015-2016, 2018 Russ Allbery <eagle@eyrie.org>
*
* See LICENSE for licensing terms.
*/
@@ -68,7 +68,8 @@ cache_init_anonymous(krb5_context ctx, const char *principal)
diag_krb5(ctx, retval, "cannot find realm for anonymous PKINIT");
return NULL;
}
- retval = krb5_build_principal_ext(ctx, &princ, strlen(realm), realm,
+ retval = krb5_build_principal_ext(ctx, &princ,
+ (unsigned int) strlen(realm), realm,
strlen(KRB5_WELLKNOWN_NAME), KRB5_WELLKNOWN_NAME,
strlen(KRB5_ANON_NAME), KRB5_ANON_NAME, NULL);
if (retval != 0)
diff --git a/tests/server/user-t.c b/tests/server/user-t.c
index 8119628..2799c93 100644
--- a/tests/server/user-t.c
+++ b/tests/server/user-t.c
@@ -2,7 +2,8 @@
* Test suite for running commands as a designated user.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2012, 2013, 2014
+ * Copyright 2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2012-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* See LICENSE for licensing terms.
@@ -86,14 +87,14 @@ test_user(struct remctl *r, const char *subcommand, uid_t *uid, gid_t *gid)
free(data);
return false;
}
- *uid = value;
+ *uid = (uid_t) value;
value = strtol(end, NULL, 10);
if (value < 0) {
diag("invalid output: %s", data);
free(data);
return false;
}
- *gid = value;
+ *gid = (gid_t) value;
free(data);
return true;
}
diff --git a/tests/tap/basic.c b/tests/tap/basic.c
index 68b0d95..daa1955 100644
--- a/tests/tap/basic.c
+++ b/tests/tap/basic.c
@@ -10,11 +10,11 @@
* up the TAP output format, or finding things in the test environment.
*
* This file is part of C TAP Harness. The current version plus supporting
- * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
- * Russ Allbery <eagle@eyrie.org>
- * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2013, 2014
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2001-2002, 2004-2008, 2011-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -34,6 +34,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <errno.h>
@@ -128,8 +130,7 @@ static struct diag_file *diag_files = NULL;
do { \
if (format != NULL) { \
va_list args; \
- if (prefix != NULL) \
- printf("%s", prefix); \
+ printf("%s", prefix); \
va_start(args, format); \
vprintf(format, args); \
va_end(args); \
@@ -489,6 +490,32 @@ skip_block(unsigned long count, const char *reason, ...)
/*
+ * Takes an expected boolean value and a seen boolean value and assumes the
+ * test passes if the truth value of both match.
+ */
+int
+is_bool(int wanted, int seen, const char *format, ...)
+{
+ int success;
+
+ fflush(stderr);
+ check_diag_files();
+ success = (!!wanted == !!seen);
+ if (success)
+ printf("ok %lu", testnum++);
+ else {
+ diag("wanted: %s", !!wanted ? "true" : "false");
+ diag(" seen: %s", !!seen ? "true" : "false");
+ printf("not ok %lu", testnum++);
+ _failed++;
+ }
+ PRINT_DESC(" - ", format);
+ putchar('\n');
+ return success;
+}
+
+
+/*
* Takes an expected integer and a seen integer and assumes the test passes
* if those two numbers match.
*/
@@ -571,6 +598,41 @@ is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
/*
+ * Takes pointers to an expected region of memory and a seen region of memory
+ * and assumes the test passes if the len bytes onwards from them match.
+ * Otherwise reports any bytes which didn't match.
+ */
+int
+is_blob(const void *wanted, const void *seen, size_t len, const char *format,
+ ...)
+{
+ int success;
+ size_t i;
+
+ fflush(stderr);
+ check_diag_files();
+ success = (memcmp(wanted, seen, len) == 0);
+ if (success)
+ printf("ok %lu", testnum++);
+ else {
+ const unsigned char *wanted_c = wanted;
+ const unsigned char *seen_c = seen;
+
+ for (i = 0; i < len; i++) {
+ if (wanted_c[i] != seen_c[i])
+ diag("offset %lu: wanted %02x, seen %02x", (unsigned long) i,
+ wanted_c[i], seen_c[i]);
+ }
+ printf("not ok %lu", testnum++);
+ _failed++;
+ }
+ PRINT_DESC(" - ", format);
+ putchar('\n');
+ return success;
+}
+
+
+/*
* Bail out with an error.
*/
void
@@ -769,6 +831,8 @@ breallocarray(void *p, size_t n, size_t size)
{
if (n > 0 && UINT_MAX / n <= size)
bail("reallocarray too large");
+ if (n == 0)
+ n = 1;
p = realloc(p, n * size);
if (p == NULL)
sysbail("failed to realloc %lu bytes", (unsigned long) (n * size));
diff --git a/tests/tap/basic.h b/tests/tap/basic.h
index db3f848..678ac7e 100644
--- a/tests/tap/basic.h
+++ b/tests/tap/basic.h
@@ -2,9 +2,9 @@
* Basic utility routines for the TAP protocol.
*
* This file is part of C TAP Harness. The current version plus supporting
- * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
+ * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
* Russ Allbery <eagle@eyrie.org>
* Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2014
* The Board of Trustees of the Leland Stanford Junior University
@@ -26,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_BASIC_H
@@ -89,14 +91,21 @@ void skip_block(unsigned long count, const char *reason, ...)
/*
* Check an expected value against a seen value. Returns true if the test
- * passes and false if it fails.
+ * passes and false if it fails. is_bool takes an int since the bool type
+ * isn't fully portable yet, but interprets both arguments for their truth
+ * value, not for their numeric value.
*/
+int is_bool(int wanted, int seen, const char *format, ...)
+ __attribute__((__format__(printf, 3, 4)));
int is_int(long wanted, long seen, const char *format, ...)
__attribute__((__format__(printf, 3, 4)));
int is_string(const char *wanted, const char *seen, const char *format, ...)
__attribute__((__format__(printf, 3, 4)));
int is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
__attribute__((__format__(printf, 3, 4)));
+int is_blob(const void *wanted, const void *seen, size_t, const char *format,
+ ...)
+ __attribute__((__format__(printf, 4, 5)));
/* Bail out with an error. sysbail appends strerror(errno). */
void bail(const char *format, ...)
diff --git a/tests/tap/kerberos.c b/tests/tap/kerberos.c
index 6a5025a..89a36a3 100644
--- a/tests/tap/kerberos.c
+++ b/tests/tap/kerberos.c
@@ -12,10 +12,11 @@
* are available.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014
+ * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2007, 2009-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,6 +36,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -361,7 +364,7 @@ kerberos_setup(enum kerberos_needs needs)
path = test_file_path("config/pkinit-principal");
if (path != NULL)
file = fopen(path, "r");
- if (file != NULL) {
+ if (path != NULL && file != NULL) {
if (fgets(buffer, sizeof(buffer), file) == NULL)
bail("cannot read %s", path);
if (buffer[strlen(buffer) - 1] != '\n')
@@ -457,17 +460,19 @@ kerberos_generate_conf(const char *realm)
/*
- * Report a Kerberos error and bail out.
+ * Report a Kerberos error and bail out. Takes a long instead of a
+ * krb5_error_code because it can also handle a kadm5_ret_t (which may be a
+ * different size).
*/
void
-bail_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...)
+bail_krb5(krb5_context ctx, long code, const char *format, ...)
{
const char *k5_msg = NULL;
char *message;
va_list args;
if (ctx != NULL)
- k5_msg = krb5_get_error_message(ctx, code);
+ k5_msg = krb5_get_error_message(ctx, (krb5_error_code) code);
va_start(args, format);
bvasprintf(&message, format, args);
va_end(args);
@@ -479,17 +484,19 @@ bail_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...)
/*
- * Report a Kerberos error as a diagnostic to stderr.
+ * Report a Kerberos error as a diagnostic to stderr. Takes a long instead of
+ * a krb5_error_code because it can also handle a kadm5_ret_t (which may be a
+ * different size).
*/
void
-diag_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...)
+diag_krb5(krb5_context ctx, long code, const char *format, ...)
{
const char *k5_msg = NULL;
char *message;
va_list args;
if (ctx != NULL)
- k5_msg = krb5_get_error_message(ctx, code);
+ k5_msg = krb5_get_error_message(ctx, (krb5_error_code) code);
va_start(args, format);
bvasprintf(&message, format, args);
va_end(args);
@@ -524,14 +531,12 @@ kerberos_keytab_principal(krb5_context ctx, const char *path)
if (status != 0)
bail_krb5(ctx, status, "error reading %s", path);
status = krb5_kt_next_entry(ctx, keytab, &entry, &cursor);
- if (status == 0) {
- status = krb5_copy_principal(ctx, entry.principal, &princ);
- if (status != 0)
- bail_krb5(ctx, status, "error copying principal from %s", path);
- krb5_kt_free_entry(ctx, &entry);
- }
if (status != 0)
bail("no principal found in keytab file %s", path);
+ status = krb5_copy_principal(ctx, entry.principal, &princ);
+ if (status != 0)
+ bail_krb5(ctx, status, "error copying principal from %s", path);
+ krb5_kt_free_entry(ctx, &entry);
krb5_kt_end_seq_get(ctx, keytab, &cursor);
krb5_kt_close(ctx, keytab);
return princ;
diff --git a/tests/tap/kerberos.h b/tests/tap/kerberos.h
index 0938070..c256822 100644
--- a/tests/tap/kerberos.h
+++ b/tests/tap/kerberos.h
@@ -2,10 +2,11 @@
* Utility functions for tests that use Kerberos.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2011, 2012, 2013, 2014
+ * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2007, 2009, 2011-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_KERBEROS_H
@@ -107,11 +110,11 @@ void kerberos_cleanup_conf(void);
#ifdef HAVE_KRB5
/* Bail out with an error, appending the Kerberos error message. */
-void bail_krb5(krb5_context, krb5_error_code, const char *format, ...)
+void bail_krb5(krb5_context, long, const char *format, ...)
__attribute__((__noreturn__, __nonnull__(3), __format__(printf, 3, 4)));
/* Report a diagnostic with Kerberos error to stderr prefixed with #. */
-void diag_krb5(krb5_context, krb5_error_code, const char *format, ...)
+void diag_krb5(krb5_context, long, const char *format, ...)
__attribute__((__nonnull__(3), __format__(printf, 3, 4)));
/*
diff --git a/tests/tap/kerberos.sh b/tests/tap/kerberos.sh
index 7c9fc77..13b540d 100644
--- a/tests/tap/kerberos.sh
+++ b/tests/tap/kerberos.sh
@@ -6,11 +6,11 @@
# Bourne shell. Instead, all private variables are prefixed with "tap_".
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2009, 2010, 2011, 2012
+# Copyright 2009-2012
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -30,6 +30,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
. "${C_TAP_SOURCE}/tap/libtap.sh"
diff --git a/tests/tap/libtap.sh b/tests/tap/libtap.sh
index 1403505..38181d9 100644
--- a/tests/tap/libtap.sh
+++ b/tests/tap/libtap.sh
@@ -7,7 +7,7 @@
#
# This file provides a TAP-compatible shell function library useful for
# writing test cases. It is part of C TAP Harness, which can be found at
-# <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+# <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2009, 2010, 2011, 2012, 2016 Russ Allbery <eagle@eyrie.org>
@@ -31,6 +31,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
# Print out the number of test cases we expect to run.
plan () {
diff --git a/tests/tap/macros.h b/tests/tap/macros.h
index 139cff0..32ed815 100644
--- a/tests/tap/macros.h
+++ b/tests/tap/macros.h
@@ -6,7 +6,7 @@
* everyone can pull them in.
*
* This file is part of C TAP Harness. The current version plus supporting
- * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
* Copyright 2008, 2012, 2013, 2015 Russ Allbery <eagle@eyrie.org>
*
@@ -27,6 +27,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_MACROS_H
diff --git a/tests/tap/messages.c b/tests/tap/messages.c
index 9c28789..a720ec7 100644
--- a/tests/tap/messages.c
+++ b/tests/tap/messages.c
@@ -6,10 +6,11 @@
* handling.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2002, 2004, 2005, 2015 Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2012, 2014
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2002, 2004-2005, 2015 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2007, 2009, 2012, 2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,6 +30,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
diff --git a/tests/tap/messages.h b/tests/tap/messages.h
index 985b9cd..3076113 100644
--- a/tests/tap/messages.h
+++ b/tests/tap/messages.h
@@ -2,10 +2,11 @@
* Utility functions to test message handling.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
+ * Written by Russ Allbery <eagle@eyrie.org>
* Copyright 2002 Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009
+ * Copyright 2006-2007, 2009
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_MESSAGES_H
diff --git a/tests/tap/perl/Test/RRA.pm b/tests/tap/perl/Test/RRA.pm
index fe95cd2..cbfdc42 100644
--- a/tests/tap/perl/Test/RRA.pm
+++ b/tests/tap/perl/Test/RRA.pm
@@ -5,6 +5,8 @@
# by both C packages with Automake and by stand-alone Perl modules. See
# Test::RRA::Automake for additional functions specifically for C Automake
# distributions.
+#
+# SPDX-License-Identifier: MIT
package Test::RRA;
@@ -13,6 +15,7 @@ use strict;
use warnings;
use Exporter;
+use File::Temp;
use Test::More;
# For Perl 5.006 compatibility.
@@ -26,12 +29,56 @@ our (@EXPORT_OK, @ISA, $VERSION);
# consistency is good).
BEGIN {
@ISA = qw(Exporter);
- @EXPORT_OK = qw(skip_unless_author skip_unless_automated use_prereq);
+ @EXPORT_OK = qw(
+ is_file_contents skip_unless_author skip_unless_automated use_prereq
+ );
# This version should match the corresponding rra-c-util release, but with
# two digits for the minor version, including a leading zero if necessary,
# so that it will sort properly.
- $VERSION = '6.01';
+ $VERSION = '7.01';
+}
+
+# Compare a string to the contents of a file, similar to the standard is()
+# function, but to show the line-based unified diff between them if they
+# differ.
+#
+# $got - The output that we received
+# $expected - The path to the file containing the expected output
+# $message - The message to use when reporting the test results
+#
+# Returns: undef
+# Throws: Exception on failure to read or write files or run diff
+sub is_file_contents {
+ my ($got, $expected, $message) = @_;
+
+ # If they're equal, this is simple.
+ open(my $fh, '<', $expected) or BAIL_OUT("Cannot open $expected: $!\n");
+ my $data = do { local $/ = undef; <$fh> };
+ close($fh) or BAIL_OUT("Cannot close $expected: $!\n");
+ if ($got eq $data) {
+ is($got, $data, $message);
+ return;
+ }
+
+ # Otherwise, we show a diff, but only if we have IPC::System::Simple.
+ eval { require IPC::System::Simple };
+ if ($@) {
+ ok(0, $message);
+ return;
+ }
+
+ # They're not equal. Write out what we got so that we can run diff.
+ my $tmp = File::Temp->new();
+ my $tmpname = $tmp->filename;
+ print {$tmp} $got or BAIL_OUT("Cannot write to $tmpname: $!\n");
+ my @command = ('diff', '-u', $expected, $tmpname);
+ my $diff = IPC::System::Simple::capturex([0 .. 1], @command);
+ diag($diff);
+
+ # Remove the temporary file and report failure.
+ ok(0, $message);
+ return;
}
# Skip this test unless author tests are requested. Takes a short description
@@ -225,10 +272,14 @@ SOFTWARE.
Test::More(3), Test::RRA::Automake(3), Test::RRA::Config(3)
This module is maintained in the rra-c-util package. The current version is
-available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
The functions to control when tests are run use environment variables defined
by the L<Lancaster
Consensus|https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/tap/perl/Test/RRA/Automake.pm b/tests/tap/perl/Test/RRA/Automake.pm
index 3d842a1..73f4100 100644
--- a/tests/tap/perl/Test/RRA/Automake.pm
+++ b/tests/tap/perl/Test/RRA/Automake.pm
@@ -10,6 +10,8 @@
# All the functions here assume that C_TAP_BUILD and C_TAP_SOURCE are set in
# the environment. This is normally done via the C TAP Harness runtests
# wrapper.
+#
+# SPDX-License-Identifier: MIT
package Test::RRA::Automake;
@@ -21,6 +23,7 @@ use warnings;
## no critic (ClassHierarchies::ProhibitExplicitISA)
use Exporter;
+use File::Find qw(find);
use File::Spec;
use Test::More;
use Test::RRA::Config qw($LIBRARY_PATH);
@@ -58,24 +61,63 @@ our (@EXPORT_OK, @ISA, $VERSION);
# consistency is good).
BEGIN {
@ISA = qw(Exporter);
- @EXPORT_OK = qw(automake_setup perl_dirs test_file_path test_tmpdir);
+ @EXPORT_OK = qw(
+ all_files automake_setup perl_dirs test_file_path test_tmpdir
+ );
# This version should match the corresponding rra-c-util release, but with
# two digits for the minor version, including a leading zero if necessary,
# so that it will sort properly.
- $VERSION = '6.01';
+ $VERSION = '7.01';
}
-# Perl directories to skip globally for perl_dirs. We ignore the perl
-# directory if it exists since, in my packages, it is treated as a Perl module
-# distribution and has its own standalone test suite.
-my @GLOBAL_SKIP = qw(.git _build perl);
+# Directories to skip globally when looking for all files, or for directories
+# that could contain Perl files.
+my @GLOBAL_SKIP = qw(.git _build autom4te.cache build-aux);
+
+# Additional paths to skip when building a list of all files in the
+# distribution. This primarily skips build artifacts that aren't interesting
+# to any of the tests. These match any path component.
+my @FILES_SKIP = qw(
+ .deps .dirstamp .libs aclocal.m4 config.h config.h.in config.h.in~ config.log
+ config.status configure
+);
# The temporary directory created by test_tmpdir, if any. If this is set,
# attempt to remove the directory stored here on program exit (but ignore
# failure to do so).
my $TMPDIR;
+# Returns a list of all files in the distribution.
+#
+# Returns: List of files
+sub all_files {
+ my @files;
+
+ # Turn the skip lists into hashes for ease of querying.
+ my %skip = map { $_ => 1 } @GLOBAL_SKIP;
+ my %files_skip = map { $_ => 1 } @FILES_SKIP;
+
+ # Wanted function for find. Prune anything matching either of the skip
+ # lists, or *.lo files, and then add all regular files to the list.
+ my $wanted = sub {
+ my $file = $_;
+ my $path = $File::Find::name;
+ $path =~ s{ \A [.]/ }{}xms;
+ if ($skip{$path} or $files_skip{$file} or $file =~ m{ [.] lo \z }xms) {
+ $File::Find::prune = 1;
+ return;
+ }
+ if (-f $file) {
+ push(@files, $path);
+ }
+ };
+
+ # Do the recursive search and return the results.
+ find($wanted, q{.});
+ return @files;
+}
+
# Perform initial test setup for running a Perl test in an Automake package.
# This verifies that C_TAP_BUILD and C_TAP_SOURCE are set and then changes
# directory to the C_TAP_SOURCE directory by default. Sets LD_LIBRARY_PATH if
@@ -171,9 +213,11 @@ sub automake_setup {
sub perl_dirs {
my ($args_ref) = @_;
- # Add the global skip list.
+ # Add the global skip list. We also ignore the perl directory if it
+ # exists since, in my packages, it is treated as a Perl module
+ # distribution and has its own standalone test suite.
my @skip = $args_ref->{skip} ? @{ $args_ref->{skip} } : ();
- push(@skip, @GLOBAL_SKIP);
+ push(@skip, @GLOBAL_SKIP, 'perl');
# Separate directories to skip under tests from top-level directories.
my @skip_tests = grep { m{ \A tests/ }xms } @skip;
@@ -328,6 +372,14 @@ BAIL_OUT (from Test::More).
=over 4
+=item all_files()
+
+Returns a list of all "interesting" files in the distribution that a test
+suite may want to look at. This excludes various products of the build system,
+the build directory if it's under the source directory, and a few other
+uninteresting directories like F<.git>. The returned paths will be paths
+relative to the root of the package.
+
=item automake_setup([ARGS])
Verifies that the C_TAP_BUILD and C_TAP_SOURCE environment variables are set
@@ -397,7 +449,7 @@ Russ Allbery <eagle@eyrie.org>
=head1 COPYRIGHT AND LICENSE
-Copyright 2014, 2015 Russ Allbery <eagle@eyrie.org>
+Copyright 2014, 2015, 2018 Russ Allbery <eagle@eyrie.org>
Copyright 2013 The Board of Trustees of the Leland Stanford Junior University
@@ -424,9 +476,13 @@ SOFTWARE.
Test::More(3), Test::RRA(3), Test::RRA::Config(3)
This module is maintained in the rra-c-util package. The current version is
-available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
The C TAP Harness test driver and libraries for TAP-based C testing are
-available from L<http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+available from L<https://www.eyrie.org/~eagle/software/c-tap-harness/>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/tap/perl/Test/RRA/Config.pm b/tests/tap/perl/Test/RRA/Config.pm
index 727927d..b2f9446 100644
--- a/tests/tap/perl/Test/RRA/Config.pm
+++ b/tests/tap/perl/Test/RRA/Config.pm
@@ -4,6 +4,8 @@
# configuration file to store some package-specific data. This module loads
# that configuration and provides the namespace for the configuration
# settings.
+#
+# SPDX-License-Identifier: MIT
package Test::RRA::Config;
@@ -34,7 +36,7 @@ BEGIN {
# This version should match the corresponding rra-c-util release, but with
# two digits for the minor version, including a leading zero if necessary,
# so that it will sort properly.
- $VERSION = '6.01';
+ $VERSION = '7.01';
}
# If C_TAP_BUILD or C_TAP_SOURCE are set in the environment, look for
@@ -214,9 +216,13 @@ perlcritic(1), Test::MinimumVersion(3), Test::RRA(3), Test::RRA::Automake(3),
Test::Strict(3)
This module is maintained in the rra-c-util package. The current version is
-available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
The C TAP Harness test driver and libraries for TAP-based C testing are
-available from L<http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+available from L<https://www.eyrie.org/~eagle/software/c-tap-harness/>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/tap/perl/Test/RRA/ModuleVersion.pm b/tests/tap/perl/Test/RRA/ModuleVersion.pm
index 202d1b8..3b3d674 100644
--- a/tests/tap/perl/Test/RRA/ModuleVersion.pm
+++ b/tests/tap/perl/Test/RRA/ModuleVersion.pm
@@ -3,6 +3,8 @@
# This module contains the common code for testing and updating Perl module
# versions for consistency within a Perl module distribution and within a
# larger package that contains both Perl modules and other code.
+#
+# SPDX-License-Identifier: MIT
package Test::RRA::ModuleVersion;
@@ -31,7 +33,7 @@ BEGIN {
# This version should match the corresponding rra-c-util release, but with
# two digits for the minor version, including a leading zero if necessary,
# so that it will sort properly.
- $VERSION = '6.01';
+ $VERSION = '7.01';
}
# A regular expression matching the version string for a module using the
@@ -290,6 +292,10 @@ SOFTWARE.
Test::More(3), Test::RRA::Config(3)
This module is maintained in the rra-c-util package. The current version
-is available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+is available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/tap/process.c b/tests/tap/process.c
index 8c22324..d9e94d8 100644
--- a/tests/tap/process.c
+++ b/tests/tap/process.c
@@ -11,11 +11,11 @@
* mkstemp.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2002, 2004, 2005, 2013 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2013, 2014
+ * Copyright 2002, 2004-2005, 2013, 2016-2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2011, 2013-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,6 +35,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -134,6 +136,8 @@ run_child_function(test_function_type function, void *data, int *status,
count = 0;
do {
ret = read(fds[0], buf + count, buflen - count - 1);
+ if (SSIZE_MAX - count <= ret)
+ bail("maximum output size exceeded in run_child_function");
if (ret > 0)
count += ret;
if (count >= buflen - 1) {
@@ -141,7 +145,7 @@ run_child_function(test_function_type function, void *data, int *status,
buf = brealloc(buf, buflen);
}
} while (ret > 0);
- buf[count < 0 ? 0 : count] = '\0';
+ buf[count] = '\0';
if (waitpid(child, &rval, 0) == (pid_t) -1)
sysbail("waitpid failed");
close(fds[0]);
@@ -364,7 +368,7 @@ process_stop_all(int success UNUSED, int primary)
* Read the PID of a process from a file. This is necessary when running
* under fakeroot to get the actual PID of the remctld process.
*/
-static long
+static pid_t
read_pidfile(const char *path)
{
FILE *file;
@@ -380,7 +384,7 @@ read_pidfile(const char *path)
pid = strtol(buffer, NULL, 10);
if (pid <= 0)
bail("cannot read PID from %s", path);
- return pid;
+ return (pid_t) pid;
}
diff --git a/tests/tap/process.h b/tests/tap/process.h
index 8137d5d..da21ad3 100644
--- a/tests/tap/process.h
+++ b/tests/tap/process.h
@@ -2,10 +2,10 @@
* Utility functions for tests that use subprocesses.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2013
+ * Copyright 2009-2010, 2013
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_PROCESS_H
diff --git a/tests/tap/remctl.c b/tests/tap/remctl.c
index aef4847..c911dac 100644
--- a/tests/tap/remctl.c
+++ b/tests/tap/remctl.c
@@ -5,10 +5,10 @@
* Kerberos environment and runs on port 14373 instead of the default 4373.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2011, 2012, 2013, 2014
+ * Copyright 2006-2007, 2009, 2011-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,6 +28,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
diff --git a/tests/tap/remctl.h b/tests/tap/remctl.h
index 41b3324..452d62b 100644
--- a/tests/tap/remctl.h
+++ b/tests/tap/remctl.h
@@ -5,10 +5,10 @@
* Kerberos environment and runs on port 14373 instead of the default 4373.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2011, 2012, 2013
+ * Copyright 2006-2007, 2009, 2011-2013
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,6 +28,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_REMCTL_H
diff --git a/tests/tap/remctl.sh b/tests/tap/remctl.sh
index efbd234..e39b88f 100644
--- a/tests/tap/remctl.sh
+++ b/tests/tap/remctl.sh
@@ -6,7 +6,7 @@
# Bourne shell. Instead, all private variables are prefixed with "tap_".
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2016 Russ Allbery <eagle@eyrie.org>
@@ -30,6 +30,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
. "${C_TAP_SOURCE}/tap/libtap.sh"
diff --git a/tests/tap/string.c b/tests/tap/string.c
index 6ed7e68..71cf571 100644
--- a/tests/tap/string.c
+++ b/tests/tap/string.c
@@ -5,9 +5,9 @@
* because they rely on additional portability code from rra-c-util.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2011, 2012 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2012 Russ Allbery <eagle@eyrie.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
diff --git a/tests/tap/string.h b/tests/tap/string.h
index d58f75d..a520210 100644
--- a/tests/tap/string.h
+++ b/tests/tap/string.h
@@ -5,9 +5,9 @@
* because they rely on additional portability code from rra-c-util.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2011, 2012 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2012 Russ Allbery <eagle@eyrie.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_STRING_H
diff --git a/tests/util/buffer-t.c b/tests/util/buffer-t.c
index ad070ac..2edb7ae 100644
--- a/tests/util/buffer-t.c
+++ b/tests/util/buffer-t.c
@@ -2,17 +2,19 @@
* buffer test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2002-2004, 2006, 2014-2015 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2014
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
diff --git a/tests/util/fakewrite.c b/tests/util/fakewrite.c
index 93dfe97..ef512df 100644
--- a/tests/util/fakewrite.c
+++ b/tests/util/fakewrite.c
@@ -2,9 +2,9 @@
* Fake write and writev functions for testing xwrite and xwritev.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2000, 2001, 2002, 2004 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2000-2002, 2004, 2017 Russ Allbery <eagle@eyrie.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -32,10 +34,8 @@
#include <errno.h>
#include <util/macros.h>
+#include <tests/util/fakewrite.h>
-ssize_t fake_write(int, const void *, size_t);
-ssize_t fake_pwrite(int, const void *, size_t, off_t);
-ssize_t fake_writev(int, const struct iovec *, int);
/*
* All the data is actually written into this buffer. We use write_offset
@@ -48,13 +48,13 @@ size_t write_offset = 0;
* If write_interrupt is non-zero, then half of the calls to write or writev
* will fail, returning -1 with errno set to EINTR.
*/
-int write_interrupt = 0;
+int write_interrupt = false;
/*
- * If write_fail is non-zero, all writes or writevs will return 0, indicating
- * no progress in writing out the buffer.
+ * If write_fail is true, all writes or writevs will return 0, indicating no
+ * progress in writing out the buffer.
*/
-int write_fail = 0;
+bool write_fail = false;
/*
@@ -116,8 +116,8 @@ fake_pwrite(int fd UNUSED, const void *data, size_t n, off_t offset)
ssize_t
fake_writev(int fd UNUSED, const struct iovec *iov, int iovcnt)
{
- int total, i;
- size_t left, n;
+ int i;
+ size_t left, n, total;
if (write_fail)
return 0;
diff --git a/tests/util/fakewrite.h b/tests/util/fakewrite.h
new file mode 100644
index 0000000..d94eea9
--- /dev/null
+++ b/tests/util/fakewrite.h
@@ -0,0 +1,58 @@
+/*
+ * Testing interface to fake write functions.
+ *
+ * This header defines the interfaces to fake write functions used to test
+ * error handling wrappers around system write functions.
+ *
+ * Copyright 2000-2002, 2004, 2017 Russ Allbery <eagle@eyrie.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef TESTS_UTIL_FAKEWRITE_H
+#define TESTS_UTIL_FAKEWRITE_H 1
+
+#include <config.h>
+#include <portable/macros.h>
+#include <portable/stdbool.h>
+
+#include <sys/types.h>
+
+BEGIN_DECLS
+
+/* Replacement functions called instead of C library calls. */
+extern ssize_t fake_write(int, const void *, size_t);
+extern ssize_t fake_pwrite(int, const void *, size_t, off_t);
+extern ssize_t fake_writev(int, const struct iovec *, int);
+
+/* The data written and how many bytes have been written. */
+extern char write_buffer[256];
+extern size_t write_offset;
+
+/* If true, half the calls to write or writev will fail with EINTR. */
+extern int write_interrupt;
+
+/* If true, all write or writev calls will return 0. */
+extern bool write_fail;
+
+END_DECLS
+
+#endif /* !TESTS_UTIL_FAKEWRITE_H */
diff --git a/tests/util/fdflag-t.c b/tests/util/fdflag-t.c
index 503b87e..819807b 100644
--- a/tests/util/fdflag-t.c
+++ b/tests/util/fdflag-t.c
@@ -2,10 +2,10 @@
* fdflag test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2008, 2009
+ * Copyright 2008-2009
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
diff --git a/tests/util/messages-krb5-t.c b/tests/util/messages-krb5-t.c
index c6de5a5..b22c4cf 100644
--- a/tests/util/messages-krb5-t.c
+++ b/tests/util/messages-krb5-t.c
@@ -2,10 +2,10 @@
* Test suite for Kerberos error handling routines.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2010, 2011, 2013, 2014
+ * Copyright 2010-2011, 2013-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -56,7 +58,7 @@ main(void)
/*
* Test functions.
*/
-static void
+static void __attribute__((__noreturn__))
test_warn(void *data UNUSED)
{
krb5_context ctx;
@@ -74,7 +76,7 @@ test_warn(void *data UNUSED)
exit(0);
}
-static void
+static void __attribute__((__noreturn__))
test_die(void *data UNUSED)
{
krb5_context ctx;
diff --git a/tests/util/messages-t.c b/tests/util/messages-t.c
index 1098314..e8a7835 100644
--- a/tests/util/messages-t.c
+++ b/tests/util/messages-t.c
@@ -2,11 +2,11 @@
* Test suite for error handling routines.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2002, 2004, 2005, 2015 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2012
+ * Copyright 2002, 2004-2005, 2015, 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2012
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -46,45 +48,87 @@
/*
* Test functions.
*/
-static void test1(void *data UNUSED) { warn("warning"); }
-static void test2(void *data UNUSED) { die("fatal"); }
-static void test3(void *data UNUSED) { errno = EPERM; syswarn("permissions"); }
-static void test4(void *data UNUSED) {
+static void
+test1(void *data UNUSED)
+{
+ warn("warning");
+}
+
+static void __attribute__((__noreturn__))
+test2(void *data UNUSED)
+{
+ die("fatal");
+}
+
+static void
+test3(void *data UNUSED)
+{
+ errno = EPERM;
+ syswarn("permissions");
+}
+
+static void __attribute__((__noreturn__))
+test4(void *data UNUSED)
+{
errno = EACCES;
sysdie("fatal access");
}
-static void test5(void *data UNUSED) {
+
+static void
+test5(void *data UNUSED)
+{
message_program_name = "test5";
warn("warning");
}
-static void test6(void *data UNUSED) {
+
+static void __attribute__((__noreturn__))
+test6(void *data UNUSED)
+{
message_program_name = "test6";
die("fatal");
}
-static void test7(void *data UNUSED) {
+
+static void
+test7(void *data UNUSED)
+{
message_program_name = "test7";
errno = EPERM;
syswarn("perms %d", 7);
}
-static void test8(void *data UNUSED) {
+
+static void __attribute__((__noreturn__))
+test8(void *data UNUSED)
+{
message_program_name = "test8";
errno = EACCES;
sysdie("%st%s", "fa", "al");
}
-static int return10(void) { return 10; }
+static int
+return10(void)
+{
+ return 10;
+}
-static void test9(void *data UNUSED) {
+static void __attribute__((__noreturn__))
+test9(void *data UNUSED)
+{
message_fatal_cleanup = return10;
die("fatal");
}
-static void test10(void *data UNUSED) {
+
+static void __attribute__((__noreturn__))
+test10(void *data UNUSED)
+{
message_program_name = 0;
message_fatal_cleanup = return10;
errno = EPERM;
sysdie("fatal perm");
}
-static void test11(void *data UNUSED) {
+
+static void __attribute__((__noreturn__))
+test11(void *data UNUSED)
+{
message_program_name = "test11";
message_fatal_cleanup = return10;
errno = EPERM;
@@ -93,61 +137,104 @@ static void test11(void *data UNUSED) {
}
static void __attribute__((__format__(printf, 2, 0)))
-log_msg(size_t len, const char *format, va_list args, int error) {
+log_msg(size_t len, const char *format, va_list args, int error)
+{
fprintf(stderr, "%lu %d ", (unsigned long) len, error);
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
}
-static void test12(void *data UNUSED) {
+static void
+test12(void *data UNUSED)
+{
message_handlers_warn(1, log_msg);
warn("warning");
}
-static void test13(void *data UNUSED) {
+
+static void __attribute__((__noreturn__))
+test13(void *data UNUSED)
+{
message_handlers_die(1, log_msg);
die("fatal");
}
-static void test14(void *data UNUSED) {
+
+static void
+test14(void *data UNUSED)
+{
message_handlers_warn(2, log_msg, log_msg);
errno = EPERM;
syswarn("warning");
}
-static void test15(void *data UNUSED) {
+
+static void __attribute__((__noreturn__))
+test15(void *data UNUSED)
+{
message_handlers_die(2, log_msg, log_msg);
message_fatal_cleanup = return10;
errno = EPERM;
sysdie("fatal");
}
-static void test16(void *data UNUSED) {
+
+static void
+test16(void *data UNUSED)
+{
message_handlers_warn(2, message_log_stderr, log_msg);
message_program_name = "test16";
errno = EPERM;
syswarn("warning");
}
-static void test17(void *data UNUSED) { notice("notice"); }
-static void test18(void *data UNUSED) {
+
+static void
+test17(void *data UNUSED)
+{
+ notice("notice");
+}
+
+static void
+test18(void *data UNUSED)
+{
message_program_name = "test18";
notice("notice");
}
-static void test19(void *data UNUSED) { debug("debug"); }
-static void test20(void *data UNUSED) {
+
+static void
+test19(void *data UNUSED)
+{
+ debug("debug");
+}
+
+static void
+test20(void *data UNUSED)
+{
message_handlers_notice(1, log_msg);
notice("foo");
}
-static void test21(void *data UNUSED) {
+
+static void
+test21(void *data UNUSED)
+{
message_handlers_debug(1, message_log_stdout);
message_program_name = "test23";
debug("baz");
}
-static void test22(void *data UNUSED) {
+
+static void __attribute__((__noreturn__))
+test22(void *data UNUSED)
+{
message_handlers_die(0);
die("hi mom!");
}
-static void test23(void *data UNUSED) {
+
+static
+void test23(void *data UNUSED)
+{
message_handlers_warn(0);
warn("this is a test");
}
-static void test24(void *data UNUSED) {
+
+static
+void test24(void *data UNUSED)
+{
notice("first");
message_handlers_notice(0);
notice("second");
diff --git a/tests/util/network/addr-ipv4-t.c b/tests/util/network/addr-ipv4-t.c
index 1ca67dd..052e71e 100644
--- a/tests/util/network/addr-ipv4-t.c
+++ b/tests/util/network/addr-ipv4-t.c
@@ -2,11 +2,11 @@
* Test network address functions for IPv4.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
* Copyright 2005, 2013, 2016 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2012, 2013
+ * Copyright 2009-2013
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -55,8 +57,11 @@ is_addr_compare(bool expected, const char *a, const char *b, const char *mask)
int
main(void)
{
- int flag, status;
+#ifdef SO_REUSEADDR
+ int flag;
socklen_t flaglen;
+#endif
+ int status;
struct addrinfo *ai, *ai2;
struct addrinfo hints;
char addr[INET6_ADDRSTRLEN];
diff --git a/tests/util/network/addr-ipv6-t.c b/tests/util/network/addr-ipv6-t.c
index 1585467..932c11d 100644
--- a/tests/util/network/addr-ipv6-t.c
+++ b/tests/util/network/addr-ipv6-t.c
@@ -2,11 +2,11 @@
* Test network address functions for IPv6.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2005, 2013, 2016 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2012, 2013
+ * Copyright 2005, 2013, 2016-2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2013
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -57,8 +59,7 @@ is_addr_compare(bool expected, const char *a, const char *b, const char *mask)
int
main(void)
{
- int flag, status;
- socklen_t flaglen;
+ int status;
struct addrinfo *ai4, *ai6;
struct addrinfo hints;
char addr[INET6_ADDRSTRLEN];
@@ -66,6 +67,10 @@ main(void)
socket_type fd;
static const char *port = "119";
static const char *ipv6_addr = "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210";
+#if defined(SO_REUSEADDR) || defined(IPV6_V6ONLY) || defined(IP_FREEBIND)
+ int flag;
+ socklen_t flaglen;
+#endif
#ifndef HAVE_INET6
skip_all("IPv6 not supported");
@@ -90,7 +95,7 @@ main(void)
"sprint of IPv6 address");
for (p = addr; *p != '\0'; p++)
if (islower((unsigned char) *p))
- *p = toupper((unsigned char) *p);
+ *p = (char) toupper((unsigned char) *p);
is_string(ipv6_addr, addr, "...with right results");
/* Test network_sockaddr_port. */
diff --git a/tests/util/network/client-t.c b/tests/util/network/client-t.c
index 5d97802..f7fdefb 100644
--- a/tests/util/network/client-t.c
+++ b/tests/util/network/client-t.c
@@ -2,11 +2,11 @@
* Test suite for network client and read/write functions.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2005, 2013, 2014, 2016 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2012, 2013
+ * Copyright 2005, 2013-2014, 2016-2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2013
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -47,7 +49,7 @@
* and expects to always succeed on the connection, taking the source address
* to pass into network_client_create.
*/
-static void
+static void __attribute__((__noreturn__))
client_create_writer(const char *source)
{
socket_type fd;
@@ -77,7 +79,7 @@ client_create_writer(const char *source)
* sleeps for 10 seconds before sending another string so that timeouts can be
* tested. Meant to be run in a child process.
*/
-static void
+static void __attribute__((__noreturn__))
client_delay_writer(const char *host)
{
socket_type fd;
@@ -100,7 +102,7 @@ client_delay_writer(const char *host)
* Used to test network_write. Connects, reads 64KB from the network, then
* sleeps before reading another 64KB. Meant to be run in a child process.
*/
-static void
+static void __attribute__((__noreturn__))
client_delay_reader(const char *host)
{
char *buffer;
diff --git a/tests/util/network/server-t.c b/tests/util/network/server-t.c
index c82d725..944546c 100644
--- a/tests/util/network/server-t.c
+++ b/tests/util/network/server-t.c
@@ -2,11 +2,11 @@
* Test suite for network server functions.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2005, 2013, 2016 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2012, 2013
+ * Copyright 2005, 2013, 2016-2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2013
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,6 +26,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -145,7 +147,7 @@ client_writer(const char *host, const char *source, bool succeed)
* localhost, from the given source address, containing a constant string.
* This also verifies that network_client_create works properly.
*/
-static void
+static void __attribute__((__noreturn__))
client_udp_writer(const char *source)
{
socket_type fd;
@@ -234,8 +236,13 @@ test_server_accept(socket_type fd)
* A varient version of the server portion of the test. Takes an array of
* sockets and the size of the sockets and accepts a connection on any of
* those sockets. Ensures that the client address information is stored
- * correctly by checking that it is set to IPv4 localhost. For skipping
- * purposes, this produces four tests.
+ * correctly by checking that it is an IPv4 address. For skipping purposes,
+ * this produces three tests.
+ *
+ * Normally, the client address should be 127.0.0.1, but hosts with odd local
+ * networking setups may rewrite client IP addresses so that they appear to
+ * come from other addresses. Avoid checking if the client IP is 127.0.0.1
+ * for that reason. Hopefully this won't hide bugs.
*
* saddr is allocated from the heap instead of using a local struct
* sockaddr_storage to work around a misdiagnosis of strict aliasing
@@ -258,9 +265,6 @@ test_server_accept_any(socket_type fds[], unsigned int count)
client = network_accept_any(fds, count, saddr, &slen);
test_server_connection(client);
is_int(AF_INET, saddr->sa_family, "...address family is IPv4");
- is_int(htonl(0x7f000001UL),
- ((struct sockaddr_in *) (void *) saddr)->sin_addr.s_addr,
- "...and client address is 127.0.0.1");
free(saddr);
for (i = 0; i < count; i++)
socket_close(fds[i]);
@@ -523,9 +527,17 @@ test_any_udp(void)
is_int(13, length, "...of correct length");
sin.sin_family = AF_INET;
sin.sin_port = htons(11119);
- sin.sin_addr.s_addr = htonl(0x7f000001UL);
+
+ /*
+ * We'd prefer to check that the client IP address is 127.0.0.1 here,
+ * but hosts with odd local networking setups may rewrite the client
+ * IP address to something else. To avoid false positives, just
+ * blindly trust the client IP address is correct, since it seems
+ * unlikely we'll have a server code bug here.
+ */
+ sin.sin_addr = ((struct sockaddr_in *) &addr)->sin_addr;
ok(network_sockaddr_equal((struct sockaddr *) &sin, saddr),
- "...from correct address");
+ "...from correct family and port");
buffer[13] = '\0';
is_string("socket test\r\n", buffer, "...and correct contents");
}
@@ -545,7 +557,7 @@ int
main(void)
{
/* Set up the plan. */
- plan(43);
+ plan(42);
/* Test network_bind functions. */
test_ipv4(NULL);
diff --git a/tests/util/vector-t.c b/tests/util/vector-t.c
index dce5ead..5385020 100644
--- a/tests/util/vector-t.c
+++ b/tests/util/vector-t.c
@@ -2,17 +2,19 @@
* vector test suite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2001-2002, 2004-2006, 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006, 2008-2013
+ * The Board of Trustees of the Leland Stanford Junior University
*
- * The authors hereby relinquish any claim to any copyright that they may have
- * in this work, whether granted under contract or by operation of law or
- * international treaty, and hereby commit to the public, at large, that they
- * shall not, at any time in the future, seek to enforce any copyright in this
- * work against any person or entity, or prevent any person or entity from
- * copying, publishing, distributing or creating derivative works of this
- * work.
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved. This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
*/
#include <config.h>
diff --git a/tests/util/xmalloc-t b/tests/util/xmalloc-t
index 5c78c02..e73a7c6 100755
--- a/tests/util/xmalloc-t
+++ b/tests/util/xmalloc-t
@@ -3,11 +3,11 @@
# Test suite for xmalloc and friends.
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2000, 2001, 2006, 2014, 2016 Russ Allbery <eagle@eyrie.org>
-# Copyright 2008, 2009, 2010, 2012
+# Copyright 2000-2001, 2006, 2014, 2016 Russ Allbery <eagle@eyrie.org>
+# Copyright 2008-2010, 2012
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -27,6 +27,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
. "$C_TAP_SOURCE/tap/libtap.sh"
cd "$C_TAP_BUILD/util"
diff --git a/tests/util/xmalloc.c b/tests/util/xmalloc.c
index 84ba081..d157bbb 100644
--- a/tests/util/xmalloc.c
+++ b/tests/util/xmalloc.c
@@ -2,10 +2,10 @@
* Test suite for xmalloc and family.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2000, 2001, 2006 Russ Allbery <eagle@eyrie.org>
- * Copyright 2008, 2012, 2013, 2014
+ * Copyright 2000-2001, 2006, 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2008, 2012-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#line 1 "xmalloc.c"
@@ -50,7 +52,7 @@
* A customized error handler for checking xmalloc's support of them. Prints
* out the error message and exits with status 1.
*/
-static void
+static void __attribute__((__noreturn__))
test_handler(const char *function, size_t size, const char *file, int line)
{
die("%s %lu %s %d", function, (unsigned long) size, file, line);
@@ -327,7 +329,7 @@ main(int argc, char *argv[])
code = argv[1][0];
if (isupper(code)) {
xmalloc_error_handler = test_handler;
- code = tolower(code);
+ code = (unsigned char) tolower(code);
}
/*
@@ -390,9 +392,7 @@ main(int argc, char *argv[])
case 'n': exit(test_strndup(size) ? willfail : 1);
case 'a': exit(test_asprintf(size) ? willfail : 1);
case 'v': exit(test_vasprintf(size) ? willfail : 1);
- default:
- die("Unknown mode %c", argv[1][0]);
- break;
+ default: die("Unknown mode %c", argv[1][0]);
}
exit(1);
}
diff --git a/tests/util/xwrite-t.c b/tests/util/xwrite-t.c
index f5c9bd4..3d73d1c 100644
--- a/tests/util/xwrite-t.c
+++ b/tests/util/xwrite-t.c
@@ -2,9 +2,9 @@
* Test suite for xwrite, xwritev, and xpwrite.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2000, 2001, 2002, 2004 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2000-2002, 2004, 2017 Russ Allbery <eagle@eyrie.org>
* Copyright 2009, 2014
* The Board of Trustees of the Leland Stanford Junior University
*
@@ -25,6 +25,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -34,20 +36,15 @@
#include <errno.h>
#include <tests/tap/basic.h>
+#include <tests/util/fakewrite.h>
#include <util/xwrite.h>
/* The data array we'll use to do testing. */
-char data[256];
-
-/* These come from fakewrite. */
-extern char write_buffer[];
-extern size_t write_offset;
-extern int write_interrupt;
-extern int write_fail;
+static char data[256];
static void
-test_write(int status, int total, const char *name)
+test_write(ssize_t status, int total, const char *name)
{
is_int(total, status, "%s return status", name);
ok(memcmp(data, write_buffer, 256) == 0, "%s output", name);
@@ -64,7 +61,7 @@ main(void)
/* Test xwrite. */
for (i = 0; i < 256; i++)
- data[i] = i;
+ data[i] = (char) i;
test_write(xwrite(0, data, 256), 256, "xwrite");
write_offset = 0;
write_interrupt = 1;
@@ -72,10 +69,10 @@ main(void)
test_write(xwrite(0, data, 256), 256, "xwrite interrupted");
write_offset = 0;
for (i = 0; i < 32; i++)
- data[i] = i * 2;
+ data[i] = (char) (i * 2);
test_write(xwrite(0, data, 32), 32, "xwrite first block");
for (i = 32; i < 65; i++)
- data[i] = i * 2;
+ data[i] = (char) (i * 2);
test_write(xwrite(0, data + 32, 33), 33, "xwrite second block");
write_offset = 0;
write_interrupt = 0;
@@ -87,7 +84,7 @@ main(void)
test_write(xwritev(0, iov, 1), 256, "xwritev");
write_offset = 0;
for (i = 0; i < 256; i++)
- data[i] = i;
+ data[i] = (char) i;
iov[0].iov_len = 128;
iov[1].iov_base = &data[128];
iov[1].iov_len = 16;
@@ -102,11 +99,11 @@ main(void)
iov[1].iov_len = 224;
test_write(xwritev(0, iov, 2), 256, "xwritev interrupted");
for (i = 0; i < 32; i++)
- data[i] = i * 2;
+ data[i] = (char) (i * 2);
write_offset = 0;
test_write(xwritev(0, iov, 1), 32, "xwritev first block");
for (i = 32; i < 65; i++)
- data[i] = i * 2;
+ data[i] = (char) (i * 2);
iov[0].iov_base = &data[32];
iov[0].iov_len = 16;
iov[1].iov_base = &data[48];
@@ -131,21 +128,21 @@ main(void)
/* Test xpwrite. */
for (i = 0; i < 256; i++)
- data[i] = i;
+ data[i] = (char) i;
test_write(xpwrite(0, data, 256, 0), 256, "xpwrite");
write_interrupt = 1;
memset(data + 1, 0, 255);
test_write(xpwrite(0, data + 1, 255, 1), 255, "xpwrite interrupted");
for (i = 0; i < 32; i++)
- data[i + 32] = i * 2;
+ data[i + 32] = (char) (i * 2);
test_write(xpwrite(0, data + 32, 32, 32), 32, "xpwrite first block");
for (i = 32; i < 65; i++)
- data[i + 32] = i * 2;
+ data[i + 32] = (char) (i * 2);
test_write(xpwrite(0, data + 64, 33, 64), 33, "xpwrite second block");
write_interrupt = 0;
/* Test failures. */
- write_fail = 1;
+ write_fail = true;
test_write(xwrite(0, data + 1, 255), -1, "xwrite fail");
iov[0].iov_base = data + 1;
iov[0].iov_len = 255;