~ubuntu-branches/ubuntu/vivid/dpkg/vivid

« back to all changes in this revision

Viewing changes to scripts/t/700_Dpkg_Control.t

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2014-04-21 18:14:10 UTC
  • mfrom: (1.6.8 sid)
  • Revision ID: package-import@ubuntu.com-20140421181410-94kvb2zodjd2og32
Tags: 1.17.7ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Allow -fstack-protector on arm64 now that GCC and glibc support it.
  - Change native source version/format mismatch errors into warnings
    until the dust settles on Debian bug 737634 about override options.
  - Add DPKG_UNTRANSLATED_MESSAGES environment check so that higher-level
    tools can get untranslated dpkg terminal log messages while at the
    same time having translated debconf prompts.
  - Special-case arm{el,hf} ELF objects in Shlibs/Objdump.pm for multilib.
  - Map unqualified package names of multiarch-same packages to the native
    arch instead of throwing an error, so that we don't break on upgrade
    when there are unqualified names stored in the dpkg trigger database.
  - Add logic to the postinst to `dpkg --add-architecture i386' on new
    installs on amd64, mimicking our previous behaviour with the conffile.
  - Apply a workaround from mvo to consider RC packages as multiarch,
    during the dpkg consistency checks. (see LP: 1015567 and 1057367).
* Drop obsolete migration code and guards from pre-trusty dpkg versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
#
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.
7
 
#
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.
12
 
#
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/>.
15
 
 
16
 
use strict;
17
 
use warnings;
18
 
 
19
 
use Test::More tests => 22;
20
 
use IO::String;
21
 
 
22
 
BEGIN {
23
 
    use_ok('Dpkg::Control');
24
 
    use_ok('Dpkg::Control::Info');
25
 
}
26
 
 
27
 
my $srcdir = $ENV{srcdir} || '.';
28
 
my $datadir = $srcdir . '/t/700_Dpkg_Control';
29
 
 
30
 
sub parse_dsc {
31
 
    my ($path) = @_;
32
 
 
33
 
    my $dsc = Dpkg::Control->new(type => CTRL_PKG_SRC);
34
 
    eval {
35
 
        $dsc->load($path);
36
 
        1;
37
 
    } or return;
38
 
 
39
 
    return $dsc;
40
 
}
41
 
 
42
 
my $c = Dpkg::Control::Info->new("$datadir/control-1");
43
 
 
44
 
my $io = IO::String->new();
45
 
$c->output($io);
46
 
my $value = ${$io->string_ref()};
47
 
my $expected = 'Source: mysource
48
 
My-Field-One: myvalue1
49
 
My-Field-Two: myvalue2
50
 
Long-Field: line1
51
 
 line 2 line 2 line 2
52
 
 .
53
 
   line 3 line 3 line 3
54
 
 ..
55
 
 line 4
56
 
Empty-Field: 
57
 
 
58
 
Package: mypackage1
59
 
Architecture: any
60
 
Depends: libc6
61
 
 
62
 
Package: mypackage2
63
 
Architecture: all
64
 
Depends: hello
65
 
 
66
 
Package: mypackage3
67
 
Architecture: all
68
 
Depends: hello
69
 
Description: short one
70
 
 long one
71
 
 very long one
72
 
';
73
 
is($value, $expected, "Dump of $datadir/control-1");
74
 
 
75
 
my $src = $c->get_source();
76
 
is($src, $c->[0], 'array representation of Dpkg::Control::Info 1/2');
77
 
is($src->{'my-field-one'}, 'myvalue1', 'Access field through badly capitalized field name');
78
 
is($src->{'long-field'},
79
 
'line1
80
 
line 2 line 2 line 2
81
 
 
82
 
  line 3 line 3 line 3
83
 
.
84
 
line 4', 'Get multi-line field');
85
 
is($src->{'Empty-field'}, '', 'Get empty field');
86
 
 
87
 
my $pkg = $c->get_pkg_by_idx(1);
88
 
is($pkg, $c->[1], 'array representation of Dpkg::Control::Info 2/2');
89
 
is($pkg->{package}, 'mypackage1', 'Name of first package');
90
 
 
91
 
$pkg = $c->get_pkg_by_name('mypackage3');
92
 
is($pkg->{package}, 'mypackage3', 'Name of third package');
93
 
is($pkg->{Depends}, 'hello', 'Name of third package');
94
 
 
95
 
$pkg = $c->get_pkg_by_idx(2);
96
 
$io = IO::String->new();
97
 
$pkg->output($io);
98
 
 
99
 
is(${$io->string_ref()},
100
 
'Package: mypackage2
101
 
Architecture: all
102
 
Depends: hello
103
 
', "Dump of second binary package of $datadir/control-1");
104
 
 
105
 
# Check OpenPGP armored signatures in source control files
106
 
 
107
 
my $dsc;
108
 
 
109
 
$dsc = parse_dsc("$datadir/bogus-unsigned.dsc");
110
 
is($dsc, undef, 'Unsigned .dsc w/ OpenPGP armor');
111
 
 
112
 
$dsc = parse_dsc("$datadir/bogus-armor-no-sig.dsc");
113
 
is($dsc, undef, 'Signed .dsc w/ OpenPGP armor missing signature');
114
 
 
115
 
$dsc = parse_dsc("$datadir/bogus-armor-trail.dsc");
116
 
is($dsc, undef, 'Signed .dsc w/ bogus OpenPGP armor trailer');
117
 
 
118
 
$dsc = parse_dsc("$datadir/bogus-armor-inline.dsc");
119
 
is($dsc, undef, 'Signed .dsc w/ bogus OpenPGP inline armor');
120
 
 
121
 
$dsc = parse_dsc("$datadir/bogus-armor-double.dsc");
122
 
ok(defined $dsc, 'Signed .dsc w/ two OpenPGP armor signatures');
123
 
is($dsc->{Source}, 'pass', 'Signed spaced .dsc package name');
124
 
 
125
 
$dsc = parse_dsc("$datadir/bogus-armor-spaces.dsc");
126
 
ok(defined $dsc, 'Signed .dsc w/ spaced OpenPGP armor');
127
 
is($dsc->{Source}, 'pass', 'Signed spaced .dsc package name');
128
 
 
129
 
$dsc = parse_dsc("$datadir/bogus-armor-nested.dsc");
130
 
ok(defined $dsc, 'Signed .dsc w/ nested OpenPGP armor');
131
 
is($dsc->{Source}, 'pass', 'Signed nested .dsc package name');