aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2018-06-03 15:36:21 -0700
committerRuss Allbery <eagle@eyrie.org>2018-06-03 15:36:42 -0700
commit4a0b9e747c8abfca24f30b7ce1e9a725ce11474a (patch)
tree9ed741a1fcc25fe23a6231782769d975c76a81c1 /tests
parent85f851653191bb9f0fc8435ada239f00f182d34a (diff)
Add SPDX-License-Identifier headers
Add SPDX-License-Identifier headers to all substantial source files. Collapse copyright years. Add some Emacs configuration for files where the copyright notice is at the end. Add a test that every file has SPDX-License-Identifier.
Diffstat (limited to 'tests')
-rw-r--r--tests/TESTS1
-rw-r--r--tests/client/basic-t.in2
-rw-r--r--tests/client/full-t.in2
-rw-r--r--tests/client/prompt-t.in2
-rw-r--r--tests/client/rekey-t.in2
-rwxr-xr-xtests/data/cmd-fake4
-rwxr-xr-xtests/docs/spdx-license-t133
-rwxr-xr-xtests/server/admin-t2
-rwxr-xr-xtests/server/backend-t2
-rwxr-xr-xtests/server/keytab-t2
-rwxr-xr-xtests/server/report-t2
-rw-r--r--tests/tap/perl/Test/RRA/Automake.pm2
12 files changed, 145 insertions, 11 deletions
diff --git a/tests/TESTS b/tests/TESTS
index a2c672e..81fe051 100644
--- a/tests/TESTS
+++ b/tests/TESTS
@@ -4,6 +4,7 @@ client/prompt
client/rekey
docs/pod
docs/pod-spelling
+docs/spdx-license-t
perl/minimum-version
perl/module-version
perl/strict
diff --git a/tests/client/basic-t.in b/tests/client/basic-t.in
index f9dc6dd..7634d73 100644
--- a/tests/client/basic-t.in
+++ b/tests/client/basic-t.in
@@ -7,7 +7,7 @@
# Copyright 2006-2008, 2010
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
# Load the test library.
. "$C_TAP_SOURCE/tap/libtap.sh"
diff --git a/tests/client/full-t.in b/tests/client/full-t.in
index 1ad486c..5f7406a 100644
--- a/tests/client/full-t.in
+++ b/tests/client/full-t.in
@@ -8,7 +8,7 @@
# Copyright 2008, 2010, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
use strict;
use warnings;
diff --git a/tests/client/prompt-t.in b/tests/client/prompt-t.in
index d5e9f17..8c5ff9a 100644
--- a/tests/client/prompt-t.in
+++ b/tests/client/prompt-t.in
@@ -8,7 +8,7 @@
# Copyright 2008, 2010, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
use strict;
use warnings;
diff --git a/tests/client/rekey-t.in b/tests/client/rekey-t.in
index 2e95a4e..c2e507c 100644
--- a/tests/client/rekey-t.in
+++ b/tests/client/rekey-t.in
@@ -7,7 +7,7 @@
# Copyright 2006-2008, 2010
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
# Load the test library.
. "$C_TAP_SOURCE/tap/libtap.sh"
diff --git a/tests/data/cmd-fake b/tests/data/cmd-fake
index f889edd..4d2d8a1 100755
--- a/tests/data/cmd-fake
+++ b/tests/data/cmd-fake
@@ -4,10 +4,10 @@
# the client test suite. It doesn't test any of the wallet server code.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2007, 2008, 2010
+# Copyright 2007-2008, 2010
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
command="$1"
shift
diff --git a/tests/docs/spdx-license-t b/tests/docs/spdx-license-t
new file mode 100755
index 0000000..e05e13f
--- /dev/null
+++ b/tests/docs/spdx-license-t
@@ -0,0 +1,133 @@
+#!/usr/bin/perl
+#
+# Check source files for SPDX-License-Identifier fields.
+#
+# Examine all source files in a distribution to check that they contain an
+# SPDX-License-Identifier field. This does not check the syntax or whether
+# the identifiers are valid.
+#
+# The canonical version of this file is maintained in the rra-c-util package,
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
+#
+# Copyright 2018 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
+
+use 5.006;
+use strict;
+use warnings;
+
+use lib "$ENV{C_TAP_SOURCE}/tap/perl";
+
+use File::Basename qw(basename);
+use Test::More;
+use Test::RRA qw(skip_unless_automated);
+use Test::RRA::Automake qw(all_files automake_setup);
+
+# File name (the file without any directory component) and path patterns to
+# skip for this check.
+## no critic (RegularExpressions::ProhibitFixedStringMatches)
+my @IGNORE = (
+ qr{ \A LICENSE \z }xms, # Generated file with no license itself
+ qr{ \A (NEWS|THANKS|TODO) \z }xms, # Package license should be fine
+ qr{ \A README ( [.] .* )? \z }xms, # Package license should be fine
+ qr{ \A (Makefile|libtool) \z }xms, # Generated file
+ qr{ [.] output \z }xms, # Test data
+);
+my @IGNORE_PATHS = (
+ qr{ \A docs/metadata/ }xms, # Package license should be fine
+ qr{ \A docs/protocol[.](html|txt) \z }xms, # Generated by xml2rfc
+ qr{ \A m4/ (libtool|lt.*) [.] m4 \z }xms, # Files from Libtool
+ qr{ \A perl/Build \z }xms, # Perl build files
+ qr{ \A perl/MANIFEST \z }xms, # Perl build files
+ qr{ \A perl/MYMETA [.] }xms, # Perl build files
+ qr{ \A perl/blib/ }xms, # Perl build files
+ qr{ \A perl/cover_db/ }xms, # Perl test files
+ qr{ \A perl/_build }xms, # Perl build files
+ qr{ \A php/Makefile [.] global \z }xms, # Created by phpize
+ qr{ \A php/autom4te [.] cache/ }xms, # Created by phpize
+ qr{ \A php/acinclude [.] m4 \z }xms, # Created by phpize
+ qr{ \A php/build/ }xms, # Created by phpize
+ qr{ \A php/config [.] (guess|sub) \z }xms, # Created by phpize
+ qr{ \A php/configure [.] in \z }xms, # Created by phpize
+ qr{ \A php/ltmain [.] sh \z }xms, # Created by phpize
+ qr{ \A php/run-tests [.] php \z }xms, # Created by phpize
+ qr{ [.] l?a \z }xms, # Created by libtool
+);
+## use critic
+
+# Only run this test during automated testing, since failure doesn't indicate
+# any user-noticable flaw in the package itself.
+skip_unless_automated('SPDX identifier tests');
+
+# Set up Automake testing.
+automake_setup();
+
+# Check a single file for an occurrence of the string.
+#
+# $path - Path to the file
+#
+# Returns: undef
+sub check_file {
+ my ($path) = @_;
+ my $filename = basename($path);
+
+ # Ignore files in the whitelist, binary files, and files under 1KB. The
+ # latter can be rolled up into the overall project license and the license
+ # notice may be a substantial portion of the file size.
+ for my $pattern (@IGNORE) {
+ return if $filename =~ $pattern;
+ }
+ for my $pattern (@IGNORE_PATHS) {
+ return if $path =~ $pattern;
+ }
+ return if !-T $path;
+ return if -s $path < 1024;
+
+ # Scan the file.
+ my ($saw_spdx, $skip_spdx);
+ open(my $file, '<', $path) or BAIL_OUT("Cannot open $path: $!");
+ while (defined(my $line = <$file>)) {
+ if ($line =~ m{ Generated [ ] by [ ] libtool [ ] }xms) {
+ close($file) or BAIL_OUT("Cannot close $path: $!");
+ return;
+ }
+ if ($line =~ m{ \b SPDX-License-Identifier: \s+ \S+ }xms) {
+ $saw_spdx = 1;
+ last;
+ }
+ if ($line =~ m{ no \s SPDX-License-Identifier \s registered }xms) {
+ $skip_spdx = 1;
+ last;
+ }
+ }
+ close($file) or BAIL_OUT("Cannot close $path: $!");
+ ok($saw_spdx || $skip_spdx, $path);
+ return;
+}
+
+# Scan every file. We don't declare a plan since we skip a lot of files and
+# don't want to precalculate the file list.
+my @paths = all_files();
+for my $path (@paths) {
+ check_file($path);
+}
+done_testing();
diff --git a/tests/server/admin-t b/tests/server/admin-t
index 8fde012..4d6670b 100755
--- a/tests/server/admin-t
+++ b/tests/server/admin-t
@@ -7,7 +7,7 @@
# Copyright 2008-2011, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
use strict;
use Test::More tests => 42;
diff --git a/tests/server/backend-t b/tests/server/backend-t
index e8ea1ce..de59458 100755
--- a/tests/server/backend-t
+++ b/tests/server/backend-t
@@ -7,7 +7,7 @@
# Copyright 2006-2014
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
use strict;
use Test::More tests => 1311;
diff --git a/tests/server/keytab-t b/tests/server/keytab-t
index 00c6e92..5cf6788 100755
--- a/tests/server/keytab-t
+++ b/tests/server/keytab-t
@@ -7,7 +7,7 @@
# Copyright 2006-2007, 2010
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
use strict;
use vars qw($CONFIG $KADMIN $SYSLOG $TMP);
diff --git a/tests/server/report-t b/tests/server/report-t
index 2e0cef7..20382f0 100755
--- a/tests/server/report-t
+++ b/tests/server/report-t
@@ -7,7 +7,7 @@
# Copyright 2008-2010
# The Board of Trustees of the Leland Stanford Junior University
#
-# See LICENSE for licensing terms.
+# SPDX-License-Identifier: MIT
use strict;
use Test::More tests => 48;
diff --git a/tests/tap/perl/Test/RRA/Automake.pm b/tests/tap/perl/Test/RRA/Automake.pm
index 3ba5bcb..6c6e947 100644
--- a/tests/tap/perl/Test/RRA/Automake.pm
+++ b/tests/tap/perl/Test/RRA/Automake.pm
@@ -104,7 +104,7 @@ sub all_files {
my $file = $_;
my $path = $File::Find::name;
$path =~ s{ \A [.]/ }{}xms;
- if ($skip{$path} or $files_skip{$file} or $file =~ m{ [.] lo \z }xms) {
+ if ($skip{$path} || $files_skip{$file} || $file =~ m{ [.] lo \z }xms) {
$File::Find::prune = 1;
return;
}