3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 use Test
::More tests
=> 11;
20 use Test
::Dpkg
qw(:paths);
22 use File
::Spec
::Functions
qw(rel2abs);
25 use Dpkg
::ErrorHandling
;
29 my $srcdir = rel2abs
($ENV{srcdir
} || '.');
30 my $datadir = test_get_data_path
();
32 # Turn these into absolute names so that we can safely switch to the test
33 # directory with «make -C».
34 $ENV{$_} = rel2abs
($ENV{$_}) foreach qw(srcdir DPKG_DATADIR DPKG_ORIGINS_DIR);
36 # Any parallelization from the parent should be ignored, we are testing
37 # the makefiles serially anyway.
38 delete $ENV{MAKEFLAGS
};
40 # Delete other variables that can affect the tests.
41 delete $ENV{$_} foreach grep { m/^DEB_/ } keys %ENV;
43 # Set architecture variables to not require dpkg nor gcc.
44 $ENV{PATH
} = "$srcdir/t/mock-bin:$ENV{PATH}";
46 $ENV{DEB_BUILD_PATH
} = rel2abs
($datadir);
49 my ($makefile, $desc) = @_;
53 spawn
(exec => [ $Dpkg::PROGMAKE
, '-C', $datadir, '-f', $makefile ],
54 wait_child
=> 1, nocheck
=> 1);
55 ok
($?
== 0, "makefile $makefile computes all values correctly ($desc)");
62 open my $cmd_fh, '-|', @cmd or subprocerr
($cmd[0]);
65 my ($key, $value) = split /=/, $_, 2;
68 close $cmd_fh or subprocerr
($cmd[0]);
75 my %arch = cmd_get_vars
($ENV{PERL
}, "$srcdir/dpkg-architecture.pl", '-f');
77 while (my ($k, $v) = each %arch) {
81 test_makefile
('architecture.mk', 'without envvars');
82 while (my ($k, $v) = each %arch) {
85 test_makefile
('architecture.mk', 'with envvars');
87 $ENV{DEB_BUILD_OPTIONS
} = 'parallel=16';
88 $ENV{TEST_DEB_BUILD_OPTION_PARALLEL
} = '16';
89 test_makefile
('buildopts.mk');
90 delete $ENV{DEB_BUILD_OPTIONS
};
91 delete $ENV{TEST_DEB_BUILD_OPTION_PARALLEL
};
93 my %buildflag = cmd_get_vars
($ENV{PERL
}, "$srcdir/dpkg-buildflags.pl");
95 while (my ($var, $flags) = each %buildflag) {
97 $ENV{"TEST_$var"} = $flags;
99 test_makefile
('buildflags.mk');
113 OBJCOPY
=> 'objcopy',
114 OBJDUMP
=> 'objdump',
118 PKG_CONFIG
=> 'pkgconf',
121 while (my ($var, $tool) = each %buildtools) {
123 $ENV{"TEST_$var"} = "$ENV{DEB_HOST_GNU_TYPE}-$tool";
124 delete $ENV{"${var}_FOR_BUILD"};
125 $ENV{"TEST_${var}_FOR_BUILD"} = "$ENV{DEB_BUILD_GNU_TYPE}-$tool";
127 test_makefile
('buildtools.mk', 'without envvars');
129 $ENV{DEB_BUILD_OPTIONS
} = 'nostrip';
130 $ENV{TEST_STRIP
} = ':';
131 $ENV{TEST_STRIP_FOR_BUILD
} = ':';
132 test_makefile
('buildtools.mk', 'with envvars');
133 delete $ENV{DEB_BUILD_OPTIONS
};
135 foreach my $tool (keys %buildtools) {
136 delete $ENV{${tool
}};
137 delete $ENV{"${tool}_FOR_BUILD"};
140 delete $ENV{SOURCE_DATE_EPOCH
};
141 # Timestamp in seconds since the epoch from date in test debian/changelog
142 # entry: «Tue, 04 Aug 2015 16:13:50 +0200».
143 $ENV{TEST_SOURCE_DATE_EPOCH
} = 1438697630;
144 test_makefile
('pkg-info.mk');
146 $ENV{SOURCE_DATE_EPOCH
} = 100;
147 $ENV{TEST_SOURCE_DATE_EPOCH
} = 100;
148 test_makefile
('pkg-info.mk');
150 test_makefile
('vendor.mk');
151 test_makefile
('vendor-v0.mk');
152 test_makefile
('vendor-v1.mk');