Debian Codegraph @

debian/tests/smoke

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Cwd qw(getcwd realpath);
7 use File::Temp qw();
8 use Test::More;
9
10 my $srcdir = getcwd;
11
12 ok(-x '/bin/sh', '/bin/sh must be executable');
13 ok(-x '/bin/dash', '/bin/dash must be executable');
14 ok(-x '/bin/bash', '/bin/bash must be executable');
15 ok(! -f '/bin/sh.distrib', '/bin/sh.distrib must not be present');
16 diag(qx(ls -l /bin/sh));
17 diag(qx(ls -l /bin/dash));
18 diag(qx(ls -l /bin/bash));
19
20 like(qx(dpkg -L dash),
21 qr{^/usr/bin/sh$}m,
22 'dash must contain a /usr/bin/sh symlink, for debootstrap');
23
24 is(qx(echo hello), "hello\n");
25
26 my $diverter = qx(dpkg-divert --listpackage /bin/sh);
27
28 ok($diverter eq "" or $diverter eq "LOCAL\n", '/bin/sh not diverted or local diversion');
29 ok($diverter ne "dash\n", '/bin/sh not diverted by dash');
30 ok($diverter ne "bash\n", '/bin/sh not diverted by bash');
31 ok(like(realpath('/bin/sh'), qr{^(?:/usr)?/bin/dash}));
32
33 my $diverter = qx(dpkg-divert --listpackage /usr/bin/sh);
34
35 ok($diverter eq "" or $diverter eq "LOCAL\n", '/usr/bin/sh not diverted or local diversion');
36 ok($diverter ne "dash\n", '/usr/bin/sh not diverted by dash');
37 ok($diverter ne "bash\n", '/usr/bin/sh not diverted by bash');
38 ok(like(realpath('/usr/bin/sh'), qr{^(?:/usr)?/bin/dash}));
39
40 my $tmpdir = File::Temp->newdir();
41 chdir $tmpdir;
42 is(system("apt-get download dash"), 0);
43 is(system("dpkg-deb -X *.deb ."), 0);
44 diag(qx(find . -ls));
45 chdir $srcdir;
46 like(readlink("$tmpdir/usr/bin/sh"), qr{^(?:/bin/)?[bd]ash$},
47 'dash_*.deb must contain a /usr/bin/sh symlink for debootstrap');
48
49 done_testing;