[Reproducible-commits] [dpkg] 67/90: scripts/t: Add test cases for the makefile snippets

Jérémy Bobbio lunar at moszumanska.debian.org
Sat Aug 29 18:26:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit f9d80776cbb11fe6f07366ce0836df1d5f911456
Author: Guillem Jover <guillem at debian.org>
Date:   Tue Aug 4 19:20:27 2015 +0200

    scripts/t: Add test cases for the makefile snippets
---
 debian/changelog              |  1 +
 scripts/Makefile.am           |  9 ++++-
 scripts/t/mk.t                | 76 +++++++++++++++++++++++++++++++++++++++++++
 scripts/t/mk/architecture.mk  | 30 +++++++++++++++++
 scripts/t/mk/buildflags.mk    | 14 ++++++++
 scripts/t/mk/debian/changelog |  5 +++
 scripts/t/mk/pkg-info.mk      |  9 +++++
 scripts/t/mk/vendor.mk        |  5 +++
 8 files changed, 148 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 6104c4e..17ce831 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -71,6 +71,7 @@ dpkg (1.18.2) UNRELEASED; urgency=low
   * Test suite:
     - Set SIGINT, SIGTERM and SIGPIPE to their default actions to get
       deterministic behavior.
+    - Add test cases for the makefile snippets.
   * Packaging:
     - Make the libdpkg-dev package Multi-Arch:same.
     - Mark libio-string-perl as <!nocheck>.
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index a55ffad..54cfad9 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -231,7 +231,9 @@ test_scripts = \
 	t/Dpkg_Source_Archive.t \
 	t/Dpkg_Source_Package.t \
 	t/Dpkg_Dist_Files.t \
-	t/merge_changelogs.t
+	t/merge_changelogs.t \
+	t/mk.t \
+	$(nil)
 
 test_data = \
 	t/Dpkg_Shlibs/symbols.blacklisted \
@@ -309,6 +311,11 @@ test_data = \
 	t/merge_changelogs/ch-merged-basic \
 	t/merge_changelogs/ch-merged-pr \
 	t/merge_changelogs/ch-merged-pr-basic \
+	t/mk/debian/changelog \
+	t/mk/architecture.mk \
+	t/mk/buildflags.mk \
+	t/mk/pkg-info.mk \
+	t/mk/vendor.mk \
 	t/origins/debian \
 	t/origins/default \
 	t/origins/gnewsense \
diff --git a/scripts/t/mk.t b/scripts/t/mk.t
new file mode 100644
index 0000000..5476683
--- /dev/null
+++ b/scripts/t/mk.t
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+use File::Spec::Functions qw(rel2abs);
+
+use Dpkg::ErrorHandling;
+use Dpkg::IPC;
+use Dpkg::Vendor;
+
+my $srcdir = $ENV{srcdir} || '.';
+my $datadir = "$srcdir/t/mk";
+
+# Turn these into absolute names so that we can safely switch to the test
+# directory with «make -C».
+$ENV{$_} = rel2abs($ENV{$_}) foreach qw(srcdir DPKG_DATADIR DPKG_ORIGINS_DIR);
+
+# Delete variables that can affect the tests.
+delete $ENV{DEB_VENDOR};
+
+sub test_makefile {
+    my $makefile = shift;
+
+    spawn(exec => [ 'make', '-C', $datadir, '-f', $makefile ],
+          wait_child => 1, nocheck => 1);
+    ok($? == 0, "makefile $makefile computes all values correctly");
+}
+
+sub get_arch_vars {
+    my $prefix = shift // '';
+    my %arch;
+
+    open my $arch_env, '-|', "$srcdir/dpkg-architecture.pl", '-f'
+        or subprocerr('dpkg-architecture');
+    while (<$arch_env>) {
+        chomp;
+        my ($key, $value) = split /=/, $_, 2;
+        $arch{$key} = $value;
+    }
+    close $arch_env or subprocerr('dpkg-architecture');
+
+    return %arch;
+}
+
+# Test makefiles.
+
+my %arch = get_arch_vars();
+
+delete $ENV{$_} foreach keys %arch;
+$ENV{"TEST_$_"} = $arch{$_} foreach keys %arch;
+test_makefile('architecture.mk');
+$ENV{$_} = $arch{$_} foreach keys %arch;
+test_makefile('architecture.mk');
+
+test_makefile('buildflags.mk');
+
+test_makefile('pkg-info.mk');
+
+test_makefile('vendor.mk');
+
+1;
diff --git a/scripts/t/mk/architecture.mk b/scripts/t/mk/architecture.mk
new file mode 100644
index 0000000..35baa19
--- /dev/null
+++ b/scripts/t/mk/architecture.mk
@@ -0,0 +1,30 @@
+include $(srcdir)/mk/architecture.mk
+
+test:
+	test "$(DEB_BUILD_ARCH)" = "$(TEST_DEB_BUILD_ARCH)"
+	test "$(DEB_BUILD_ARCH_BITS)" = "$(TEST_DEB_BUILD_ARCH_BITS)"
+	test "$(DEB_BUILD_ARCH_CPU)" = "$(TEST_DEB_BUILD_ARCH_CPU)"
+	test "$(DEB_BUILD_ARCH_ENDIAN)" = "$(TEST_DEB_BUILD_ARCH_ENDIAN)"
+	test "$(DEB_BUILD_ARCH_OS)" = "$(TEST_DEB_BUILD_ARCH_OS)"
+	test "$(DEB_BUILD_GNU_CPU)" = "$(TEST_DEB_BUILD_GNU_CPU)"
+	test "$(DEB_BUILD_GNU_SYSTEM)" = "$(TEST_DEB_BUILD_GNU_SYSTEM)"
+	test "$(DEB_BUILD_GNU_TYPE)" = "$(TEST_DEB_BUILD_GNU_TYPE)"
+	test "$(DEB_BUILD_MULTIARCH)" = "$(TEST_DEB_BUILD_MULTIARCH)"
+	test "$(DEB_HOST_ARCH)" = "$(TEST_DEB_HOST_ARCH)"
+	test "$(DEB_HOST_ARCH_BITS)" = "$(TEST_DEB_HOST_ARCH_BITS)"
+	test "$(DEB_HOST_ARCH_CPU)" = "$(TEST_DEB_HOST_ARCH_CPU)"
+	test "$(DEB_HOST_ARCH_ENDIAN)" = "$(TEST_DEB_HOST_ARCH_ENDIAN)"
+	test "$(DEB_HOST_ARCH_OS)" = "$(TEST_DEB_HOST_ARCH_OS)"
+	test "$(DEB_HOST_GNU_CPU)" = "$(TEST_DEB_HOST_GNU_CPU)"
+	test "$(DEB_HOST_GNU_SYSTEM)" = "$(TEST_DEB_HOST_GNU_SYSTEM)"
+	test "$(DEB_HOST_GNU_TYPE)" = "$(TEST_DEB_HOST_GNU_TYPE)"
+	test "$(DEB_HOST_MULTIARCH)" = "$(TEST_DEB_HOST_MULTIARCH)"
+	test "$(DEB_TARGET_ARCH)" = "$(TEST_DEB_TARGET_ARCH)"
+	test "$(DEB_TARGET_ARCH_BITS)" = "$(TEST_DEB_TARGET_ARCH_BITS)"
+	test "$(DEB_TARGET_ARCH_CPU)" = "$(TEST_DEB_TARGET_ARCH_CPU)"
+	test "$(DEB_TARGET_ARCH_ENDIAN)" = "$(TEST_DEB_TARGET_ARCH_ENDIAN)"
+	test "$(DEB_TARGET_ARCH_OS)" = "$(TEST_DEB_TARGET_ARCH_OS)"
+	test "$(DEB_TARGET_GNU_CPU)" = "$(TEST_DEB_TARGET_GNU_CPU)"
+	test "$(DEB_TARGET_GNU_SYSTEM)" = "$(TEST_DEB_TARGET_GNU_SYSTEM)"
+	test "$(DEB_TARGET_GNU_TYPE)" = "$(TEST_DEB_TARGET_GNU_TYPE)"
+	test "$(DEB_TARGET_MULTIARCH)" = "$(TEST_DEB_TARGET_MULTIARCH)"
diff --git a/scripts/t/mk/buildflags.mk b/scripts/t/mk/buildflags.mk
new file mode 100644
index 0000000..3035303
--- /dev/null
+++ b/scripts/t/mk/buildflags.mk
@@ -0,0 +1,14 @@
+DEB_CPPFLAGS_MAINT_APPEND = -DTEST_MK=test
+
+include $(srcdir)/mk/buildflags.mk
+
+test:
+	test "$(CFLAGS)" = "-g -O2 -fstack-protector-strong -Wformat -Werror=format-security"
+	test "$(CPPFLAGS)" = "-D_FORTIFY_SOURCE=2 -DTEST_MK=test"
+	test "$(CXXFLAGS)" = "-g -O2 -fstack-protector-strong -Wformat -Werror=format-security"
+	test "$(FCFLAGS)" = "-g -O2 -fstack-protector-strong"
+	test "$(FFLAGS)" = "-g -O2 -fstack-protector-strong"
+	test "$(GCJFLAGS)" = "-g -O2 -fstack-protector-strong"
+	test "$(LDFLAGS)" = "-Wl,-z,relro"
+	test "$(OBJCFLAGS)" = "-g -O2 -fstack-protector-strong -Wformat -Werror=format-security"
+	test "$(OBJCXXFLAGS)" = "-g -O2 -fstack-protector-strong -Wformat -Werror=format-security"
diff --git a/scripts/t/mk/debian/changelog b/scripts/t/mk/debian/changelog
new file mode 100644
index 0000000..728c8ec
--- /dev/null
+++ b/scripts/t/mk/debian/changelog
@@ -0,0 +1,5 @@
+source (1:2:3.4-5-6) suite; urgency=low
+
+  * Initial release.
+
+ -- Dpkg Developers <debian-dpkg at lists.debian.org>  Tue, 04 Aug 2015 16:13:50 +0200
diff --git a/scripts/t/mk/pkg-info.mk b/scripts/t/mk/pkg-info.mk
new file mode 100644
index 0000000..22a2bf4
--- /dev/null
+++ b/scripts/t/mk/pkg-info.mk
@@ -0,0 +1,9 @@
+include $(srcdir)/mk/pkg-info.mk
+
+test:
+	test "$(DEB_SOURCE)" = "source"
+	test "$(DEB_VERSION)" = "1:2:3.4-5-6"
+	test "$(DEB_VERSION_EPOCH_UPSTREAM)" = "1:2:3.4-5"
+	test "$(DEB_VERSION_UPSTREAM_REVISION)" = "2:3.4-5-6"
+	test "$(DEB_VERSION_UPSTREAM)" = "2:3.4-5"
+	test "$(DEB_DISTRIBUTION)" = "suite"
diff --git a/scripts/t/mk/vendor.mk b/scripts/t/mk/vendor.mk
new file mode 100644
index 0000000..371b39c
--- /dev/null
+++ b/scripts/t/mk/vendor.mk
@@ -0,0 +1,5 @@
+include $(srcdir)/mk/vendor.mk
+
+test:
+	test "$(DEB_VENDOR)" = "Debian"
+	test "$(DEB_PARENT_VENDOR)" = ""

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list