summaryrefslogtreecommitdiffstats
path: root/scripts/t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:42:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:42:28 +0000
commit33a2bb70562ae87235c9be95722a963129a13a38 (patch)
tree15839c3590b802065af623ef71fce4f75f561eed /scripts/t
parentAdding upstream version 1.22.5. (diff)
downloaddpkg-33a2bb70562ae87235c9be95722a963129a13a38.tar.xz
dpkg-33a2bb70562ae87235c9be95722a963129a13a38.zip
Adding upstream version 1.22.6.upstream/1.22.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/t')
-rw-r--r--scripts/t/Dpkg_BuildFlags.t51
-rw-r--r--scripts/t/Dpkg_OpenPGP.t84
2 files changed, 82 insertions, 53 deletions
diff --git a/scripts/t/Dpkg_BuildFlags.t b/scripts/t/Dpkg_BuildFlags.t
index 515ed15..23c3deb 100644
--- a/scripts/t/Dpkg_BuildFlags.t
+++ b/scripts/t/Dpkg_BuildFlags.t
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 100;
+use Test::More tests => 118;
BEGIN {
$ENV{DEB_BUILD_ARCH} = 'amd64';
@@ -150,6 +150,37 @@ foreach my $area (sort keys %known_features) {
"supported features for area $area");
}
+# Test qa bug and bug-implicit-func defaults.
+undef $ENV{DEB_BUILD_MAINT_OPTIONS};
+$bf = Dpkg::BuildFlags->new();
+test_has_noflag($bf, 'CFLAGS', '-Werror=array-bounds');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'qa=+bug';
+$bf = Dpkg::BuildFlags->new();
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=array-bounds');
+test_has_flag($bf, 'CFLAGS', '-Werror=clobbered');
+test_has_flag($bf, 'CFLAGS', '-Werror=volatile-register-var');
+test_has_flag($bf, 'CXXFLAGS', '-Werror=array-bounds');
+test_has_flag($bf, 'CXXFLAGS', '-Werror=clobbered');
+test_has_flag($bf, 'CXXFLAGS', '-Werror=volatile-register-var');
+
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'qa=-bug-implicit-func';
+$bf = Dpkg::BuildFlags->new();
+test_has_noflag($bf, 'CFLAGS', '-Werror=array-bounds');
+test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'qa=+bug,-bug-implicit-func';
+$bf = Dpkg::BuildFlags->new();
+test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=array-bounds');
+test_has_flag($bf, 'CFLAGS', '-Werror=clobbered');
+test_has_flag($bf, 'CFLAGS', '-Werror=volatile-register-var');
+test_has_flag($bf, 'CXXFLAGS', '-Werror=array-bounds');
+test_has_flag($bf, 'CXXFLAGS', '-Werror=clobbered');
+test_has_flag($bf, 'CXXFLAGS', '-Werror=volatile-register-var');
+
# Test lfs alias from abi to future, we need a 32-bit arch that does does
# not currently have this flag built-in.
$ENV{DEB_BUILD_ARCH} = 'i386';
@@ -184,7 +215,7 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
$ENV{DEB_BUILD_MAINT_OPTIONS} = 'abi=+time64';
$bf = Dpkg::BuildFlags->new();
@@ -200,7 +231,7 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
# 32-bit system with time32 and no time64.
$ENV{DEB_BUILD_ARCH} = 'hurd-i386';
@@ -212,7 +243,7 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
$ENV{DEB_BUILD_MAINT_OPTIONS} = 'abi=+time64';
$bf = Dpkg::BuildFlags->new();
@@ -220,7 +251,7 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
$ENV{DEB_BUILD_MAINT_OPTIONS} = 'abi=-time64';
$bf = Dpkg::BuildFlags->new();
@@ -228,7 +259,7 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
# 32-bit system with time32, time64 enabled by default.
$ENV{DEB_BUILD_ARCH} = 'armhf';
@@ -256,7 +287,7 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_flag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_flag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
# 64-bit system with built-in time64.
$ENV{DEB_BUILD_ARCH} = 'amd64';
@@ -268,7 +299,7 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
$ENV{DEB_BUILD_MAINT_OPTIONS} = 'abi=+time64';
$bf = Dpkg::BuildFlags->new();
@@ -276,7 +307,7 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
$ENV{DEB_BUILD_MAINT_OPTIONS} = 'abi=-time64';
$bf = Dpkg::BuildFlags->new();
@@ -284,6 +315,6 @@ test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS');
test_has_noflag($bf, 'CPPFLAGS', '-D_TIME_BITS=64');
test_has_noflag($bf, 'CPPFLAGS', '-U_TIME_BITS');
-test_has_noflag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
+test_has_flag($bf, 'CFLAGS', '-Werror=implicit-function-declaration');
# TODO: Add more test cases.
diff --git a/scripts/t/Dpkg_OpenPGP.t b/scripts/t/Dpkg_OpenPGP.t
index d409082..2902cf6 100644
--- a/scripts/t/Dpkg_OpenPGP.t
+++ b/scripts/t/Dpkg_OpenPGP.t
@@ -17,7 +17,7 @@ use strict;
use warnings;
use Test::More;
-use Test::Dpkg qw(:paths :needs);
+use Test::Dpkg qw(:paths :needs test_get_openpgp_backend);
use File::Compare;
@@ -25,14 +25,6 @@ use Dpkg::ErrorHandling;
use Dpkg::Path qw(find_command);
use Dpkg::OpenPGP::KeyHandle;
-my %backend_cmd = (
- auto => 'auto',
- 'gpg-sq' => 'gpg',
- gpg => 'gpg',
- sq => 'sq',
- sqop => 'sop',
- 'pgpainless-cli' => 'sop',
-);
my @cmds = test_needs_openpgp_backend();
unshift @cmds, 'auto';
@@ -58,48 +50,54 @@ foreach my $cmd (@cmds) {
my $datadir = test_get_data_path();
my $tempdir = test_get_temp_path();
- my $backend = $backend_cmd{$cmd};
+ my $backend = test_get_openpgp_backend($cmd);
my $openpgp = Dpkg::OpenPGP->new(
backend => $backend,
cmd => $cmd,
);
- ok($openpgp->dearmor('PUBLIC KEY BLOCK', "$datadir/dpkg-test-pub.asc", "$tempdir/dpkg-test-pub.pgp") == OPENPGP_OK(),
- "($backend:$cmd) dearmoring OpenPGP ASCII Armored certificate");
- ok($openpgp->armor('PUBLIC KEY BLOCK', "$tempdir/dpkg-test-pub.pgp", "$tempdir/dpkg-test-pub.asc") == OPENPGP_OK(),
- "($backend:$cmd) armoring OpenPGP binary certificate");
- test_diff("$datadir/dpkg-test-pub.asc", "$tempdir/dpkg-test-pub.asc",
- "($backend:$cmd) OpenPGP certificate dearmor/armor round-trip correctly");
-
- ok($openpgp->armor('SIGNATURE', "$datadir/sign-file.sig", "$tempdir/sign-file.asc") == OPENPGP_OK(),
- "($backend:$cmd) armoring OpenPGP binary signature succeeded");
- ok(compare("$datadir/sign-file.sig", "$tempdir/sign-file.asc") != 0,
- "($backend:$cmd) armoring OpenPGP ASCII Armor changed the file");
- ok($openpgp->armor('SIGNATURE', "$datadir/sign-file.asc", "$tempdir/sign-file-rearmor.asc") == OPENPGP_OK(),
- "($backend:$cmd) armoring OpenPGP armored signature succeeded");
- test_diff("$datadir/sign-file.asc", "$tempdir/sign-file-rearmor.asc",
- "($backend:$cmd) rearmoring OpenPGP ASCII Armor changed the file");
-
- ok($openpgp->dearmor('SIGNATURE', "$tempdir/sign-file.asc", "$tempdir/sign-file.sig") == OPENPGP_OK(),
- "($backend:$cmd) dearmoring OpenPGP armored signature succeeded");
- test_diff("$datadir/sign-file.sig", "$tempdir/sign-file.sig",
- "($backend:$cmd) dearmored OpenPGP ASCII Armor signature matches");
-
- my $cert = "$datadir/dpkg-test-pub.asc";
-
- ok($openpgp->inline_verify("$datadir/sign-file-inline.asc", undef, $cert) == OPENPGP_OK(),
- "($backend:$cmd) verify OpenPGP ASCII Armor inline signature");
- ok($openpgp->inline_verify("$datadir/sign-file-inline.sig", undef, $cert) == OPENPGP_OK(),
- "($backend:$cmd) verify OpenPGP binary inline signature");
-
- ok($openpgp->verify("$datadir/sign-file", "$datadir/sign-file.asc", $cert) == OPENPGP_OK(),
+ my $certfile = "$datadir/dpkg-test-pub.asc";
+ my $keyfile = "$datadir/dpkg-test-sec.asc";
+
+ SKIP: {
+ skip 'missing backend command', 13
+ unless $openpgp->{backend}->has_verify_cmd();
+
+ ok($openpgp->dearmor('PUBLIC KEY BLOCK', $certfile, "$tempdir/dpkg-test-pub.pgp") == OPENPGP_OK(),
+ "($backend:$cmd) dearmoring OpenPGP ASCII Armored certificate");
+ ok($openpgp->armor('PUBLIC KEY BLOCK', "$tempdir/dpkg-test-pub.pgp", "$tempdir/dpkg-test-pub.asc") == OPENPGP_OK(),
+ "($backend:$cmd) armoring OpenPGP binary certificate");
+ test_diff($certfile, "$tempdir/dpkg-test-pub.asc",
+ "($backend:$cmd) OpenPGP certificate dearmor/armor round-trip correctly");
+
+ ok($openpgp->armor('SIGNATURE', "$datadir/sign-file.sig", "$tempdir/sign-file.asc") == OPENPGP_OK(),
+ "($backend:$cmd) armoring OpenPGP binary signature succeeded");
+ ok(compare("$datadir/sign-file.sig", "$tempdir/sign-file.asc") != 0,
+ "($backend:$cmd) armoring OpenPGP ASCII Armor changed the file");
+ ok($openpgp->armor('SIGNATURE', "$datadir/sign-file.asc", "$tempdir/sign-file-rearmor.asc") == OPENPGP_OK(),
+ "($backend:$cmd) armoring OpenPGP armored signature succeeded");
+ test_diff("$datadir/sign-file.asc", "$tempdir/sign-file-rearmor.asc",
+ "($backend:$cmd) rearmoring OpenPGP ASCII Armor changed the file");
+
+ ok($openpgp->dearmor('SIGNATURE', "$tempdir/sign-file.asc", "$tempdir/sign-file.sig") == OPENPGP_OK(),
+ "($backend:$cmd) dearmoring OpenPGP armored signature succeeded");
+ test_diff("$datadir/sign-file.sig", "$tempdir/sign-file.sig",
+ "($backend:$cmd) dearmored OpenPGP ASCII Armor signature matches");
+
+ ok($openpgp->inline_verify("$datadir/sign-file-inline.asc", undef, $certfile) == OPENPGP_OK(),
+ "($backend:$cmd) verify OpenPGP ASCII Armor inline signature");
+ ok($openpgp->inline_verify("$datadir/sign-file-inline.sig", undef, $certfile) == OPENPGP_OK(),
+ "($backend:$cmd) verify OpenPGP binary inline signature");
+
+ ok($openpgp->verify("$datadir/sign-file", "$datadir/sign-file.asc", $certfile) == OPENPGP_OK(),
"($backend:$cmd) verify OpenPGP ASCII Armor detached signature");
- ok($openpgp->verify("$datadir/sign-file", "$datadir/sign-file.sig", $cert) == OPENPGP_OK(),
- "($backend:$cmd) verify OpenPGP binary detached signature");
+ ok($openpgp->verify("$datadir/sign-file", "$datadir/sign-file.sig", $certfile) == OPENPGP_OK(),
+ "($backend:$cmd) verify OpenPGP binary detached signature");
+ };
my $key = Dpkg::OpenPGP::KeyHandle->new(
type => 'keyfile',
- handle => "$datadir/dpkg-test-sec.asc",
+ handle => $keyfile,
);
SKIP: {
@@ -107,7 +105,7 @@ foreach my $cmd (@cmds) {
ok($openpgp->inline_sign("$datadir/sign-file", "$tempdir/sign-file-inline.asc", $key) == OPENPGP_OK(),
"($backend:$cmd) inline OpenPGP sign");
- ok($openpgp->inline_verify("$tempdir/sign-file-inline.asc", undef, $cert) == OPENPGP_OK(),
+ ok($openpgp->inline_verify("$tempdir/sign-file-inline.asc", undef, $certfile) == OPENPGP_OK(),
"($backend:$cmd) verify generated inline OpenPGP signature");
};