summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-05-29 07:30:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-05-29 07:30:32 +0000
commitce597d6a01fda649be99c7fae25a0604bdefa23c (patch)
treeb65380f6ae301ab9660d3d4728c48fec4eaef7be /t
parentef337715b4b8124322d5bb458dc9686da7d8fb8b (diff)
downloadurpmi-ce597d6a01fda649be99c7fae25a0604bdefa23c.tar
urpmi-ce597d6a01fda649be99c7fae25a0604bdefa23c.tar.gz
urpmi-ce597d6a01fda649be99c7fae25a0604bdefa23c.tar.bz2
urpmi-ce597d6a01fda649be99c7fae25a0604bdefa23c.tar.xz
urpmi-ce597d6a01fda649be99c7fae25a0604bdefa23c.zip
re-sync after the big svn loss
Diffstat (limited to 't')
-rw-r--r--t/01compile.t2
-rw-r--r--t/02create_pkgs.t71
-rw-r--r--t/README4
-rw-r--r--t/cfg.t43
-rw-r--r--t/data/SPECS/arch_to_noarch_1.spec (renamed from t/SPECS/arch_to_noarch_1.spec)0
-rw-r--r--t/data/SPECS/arch_to_noarch_2.spec (renamed from t/SPECS/arch_to_noarch_2.spec)0
-rw-r--r--t/data/SPECS/arch_to_noarch_3.spec (renamed from t/SPECS/arch_to_noarch_3.spec)0
-rw-r--r--t/data/SPECS/arch_to_noarch_4.spec (renamed from t/SPECS/arch_to_noarch_4.spec)0
-rw-r--r--t/data/SPECS/priority-upgrade-1/a-strict_1.spec14
-rw-r--r--t/data/SPECS/priority-upgrade-1/a_1.spec14
-rw-r--r--t/data/SPECS/priority-upgrade-1/b_1.spec13
-rw-r--r--t/data/SPECS/priority-upgrade-2/a-strict_2.spec14
-rw-r--r--t/data/SPECS/priority-upgrade-2/a_2.spec14
-rw-r--r--t/data/SPECS/priority-upgrade-2/b_2.spec14
-rw-r--r--t/data/SPECS/priority-upgrade-2/bb1_2.spec14
-rw-r--r--t/data/SPECS/priority-upgrade-2/bb2_2.spec14
-rw-r--r--t/data/SPECS/srpm-bootstrapping.spec14
-rw-r--r--t/data/SPECS/various.spec (renamed from t/SPECS/various.spec)0
-rw-r--r--t/data/SPECS/various2.spec38
-rw-r--r--t/data/SPECS/various3.spec38
-rw-r--r--t/data/media.cfg26
-rw-r--r--t/data/rpm-buggy/invalid-signature.rpmbin0 -> 3965 bytes
-rw-r--r--t/data/rpm-buggy/not-a-rpm.rpm1
-rw-r--r--t/data/rpm-buggy/weird-header.rpmbin0 -> 3965 bytes
-rw-r--r--t/data/rpm-v3/libtermcap-2.0.8-2.i386.rpm (renamed from t/rpm-v3/libtermcap-2.0.8-2.i386.rpm)bin7159 -> 7159 bytes
-rw-r--r--t/data/rpm-v3/nls-1.0-2.i386.rpm (renamed from t/rpm-v3/nls-1.0-2.i386.rpm)bin2688 -> 2688 bytes
-rw-r--r--t/data/rpm-v3/p2c-1.20-7.i386.rpm (renamed from t/rpm-v3/p2c-1.20-7.i386.rpm)bin8004 -> 8004 bytes
-rw-r--r--t/superuser--addmedia.t44
-rw-r--r--t/superuser--buggy-rpms.t24
-rw-r--r--t/superuser--media_info_dir.t6
-rw-r--r--t/superuser--priority-upgrade.t116
-rw-r--r--t/superuser--srpm-bootstrapping.t14
32 files changed, 525 insertions, 27 deletions
diff --git a/t/01compile.t b/t/01compile.t
index 753c5ff6..0f0d5143 100644
--- a/t/01compile.t
+++ b/t/01compile.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 20;
for my $module (glob("urpm/*.pm")) {
$module =~ s,/,::,g;
diff --git a/t/02create_pkgs.t b/t/02create_pkgs.t
index ff4fda0c..caf6aaa5 100644
--- a/t/02create_pkgs.t
+++ b/t/02create_pkgs.t
@@ -5,33 +5,80 @@ use warnings;
use Test::More 'no_plan';
chdir 't' if -d 't';
-system('rm -rf BUILD RPMS media');
-foreach (qw(media BUILD RPMS RPMS/noarch)) {
+system('rm -rf tmp media');
+foreach (qw(media tmp tmp/BUILD tmp/RPMS tmp/RPMS/noarch tmp/SRPMS)) {
mkdir $_;
}
-# locally build a test rpms
-foreach my $spec (glob("SPECS/*.spec")) {
- system_("rpmbuild --quiet --define '_topdir .' -bb --clean $spec");
- my ($name) = $spec =~ m!([^/]*)\.spec$!;
- mkdir "media/$name";
- system_("mv RPMS/*/*.rpm media/$name");
+
+# locally build test rpms
+
+foreach my $dir (grep { -d $_ } glob("data/SPECS/*")) {
+ my ($medium_name) = $dir =~ m!([^/]*)$!;
+ rpmbuild($_, $medium_name) foreach glob("$dir/*.spec");
+ genhdlist_std($medium_name);
+}
+
+foreach my $spec (glob("data/SPECS/*.spec")) {
+ my $name = rpmbuild($spec);
if ($name eq 'various') {
system_("cp -r media/$name media/${name}_nohdlist");
system_("cp -r media/$name media/${name}_no_subdir");
system_("genhdlist --dest media/${name}_no_subdir");
+ symlink "${name}_nohdlist", "media/${name} nohdlist";
+ symlink "${name}", "media/${name}_bis";
}
-
- system_("genhdlist --subdir media/$name/media_info media/$name");
+ genhdlist_std($name);
+}
+foreach my $spec (glob("data/SPECS/srpm*.spec")) {
+ my $name = rpmbuild_srpm($spec);
+ genhdlist_std($name);
}
{
my $name = 'rpm-v3';
- system_("cp -r $name media");
+ system_("cp -r data/$name media");
system_("cp -r media/$name media/${name}_nohdlist");
system_("cp -r media/$name media/${name}_no_subdir");
system_("genhdlist --dest media/${name}_no_subdir");
- system_("genhdlist --subdir media/$name/media_info media/$name");
+ genhdlist_std($name);
+}
+
+mkdir 'media/media_info';
+system_("cp -r data/media.cfg media/media_info");
+system_('gendistrib .');
+
+sub genhdlist_std {
+ my ($medium_name) = @_;
+ system_("genhdlist --subdir media/$medium_name/media_info media/$medium_name");
+}
+
+sub rpmbuild {
+ my ($spec, $o_medium_name) = @_;
+
+ system_("rpmbuild --quiet --define '_topdir tmp' -bb --clean --nodeps $spec");
+
+ my ($name) = $spec =~ m!([^/]*)\.spec$!;
+
+ my $medium_name = $o_medium_name || $name;
+ mkdir "media/$medium_name";
+ system_("mv tmp/RPMS/*/*.rpm media/$medium_name");
+
+ $medium_name;
+}
+
+sub rpmbuild_srpm {
+ my ($spec) = @_;
+
+ system_("rpmbuild --quiet --define '_topdir tmp' -bs --clean --nodeps $spec");
+
+ my ($name) = $spec =~ m!([^/]*)\.spec$!;
+
+ my $medium_name = "SRPMS-$name";
+ mkdir "media/$medium_name";
+ system_("mv tmp/SRPMS/*.rpm media/$medium_name");
+
+ $medium_name;
}
sub system_ {
diff --git a/t/README b/t/README
index 2784568d..ea8fc8f3 100644
--- a/t/README
+++ b/t/README
@@ -1,6 +1,4 @@
you need to be root to run superuser--*.t,
with a normal user those tests are simply skipped.
-so do:
-- make test
-- sudo make test TEST_FILES='t/superuser--*.t'
+use "make testall"
diff --git a/t/cfg.t b/t/cfg.t
index 91da6015..15e2f927 100644
--- a/t/cfg.t
+++ b/t/cfg.t
@@ -10,14 +10,14 @@ BEGIN { use_ok 'urpm::download' }
my $file = 'testurpmi.cfg';
my $proxyfile = $urpm::download::PROXY_CFG = 'testproxy.cfg';
open my $f, '>', $file or die $!;
-print $f (my $cfgtext = <<URPMICFG);
+print $f (my $cfgtext = <<'URPMICFG');
{
downloader: wget
fuzzy: no
verify-rpm: 0
}
-update\\ 1 http://foo/bar/ {
+update\ 1 http://foo/bar/$RELEASE {
compress: 1
fuzzy: 1
keep: yes
@@ -41,7 +41,20 @@ close $f;
my $config = urpm::cfg::load_config($file);
ok( ref $config, 'config loaded' );
-ok( urpm::cfg::dump_config($file.2, $config), 'config written' );
+is($config->{global}{downloader}, 'wget');
+ok(my ($update_2) = grep { $_->{name} eq 'update_2' } @{$config->{media}});
+is($update_2->{url}, 'ftp://foo/bar/');
+ok(my ($update_1) = grep { $_->{name} eq 'update 1' } @{$config->{media}});
+is($update_1->{url}, 'http://foo/bar/' . urpm::cfg::get_release());
+
+my $config_verbatim = urpm::cfg::load_config_raw($file, 1);
+ok( ref $config_verbatim, 'config loaded' );
+
+unlink "$file.verbatim", "$file.bad";
+urpm::util::copy($file, "$file.state"); #- dump_config has a state
+ok( urpm::cfg::dump_config_raw("$file.verbatim", $config_verbatim), 'config written' );
+ok( urpm::cfg::dump_config("$file.bad", $config), 'config written' );
+ok( urpm::cfg::dump_config("$file.state", $config), 'config written' );
# things that have been tidied up by dump_config
$cfgtext =~ s/\byes\b/1/g;
@@ -50,10 +63,26 @@ $cfgtext =~ s/\bkey_ids\b/key-ids/g;
$cfgtext =~ s/"123"/123/g;
$cfgtext =~ s/'kernel'/kernel/g;
-my $cfgtext2 = read_file($file.2);
+{
+my $cfgtext2 = read_file("$file.verbatim");
+$cfgtext2 =~ s/# generated.*\n//;
+is( $cfgtext, $cfgtext2, 'config is the same' )
+ or system qw( diff -u ), $file, "$file.verbatim";
+}
+{
+my $cfgtext2 = read_file("$file.bad");
+$cfgtext2 =~ s/# generated.*\n//;
+isnt( $cfgtext, $cfgtext2, 'config should differ' )
+ or system qw( diff -u ), $file, "$file.bad";
+}
+{
+my $cfgtext2 = read_file("$file.state");
$cfgtext2 =~ s/# generated.*\n//;
is( $cfgtext, $cfgtext2, 'config is the same' )
- or system qw( diff -u ), $file, $file.2;
+ or system qw( diff -u ), $file, "$file.state";
+}
+
+
open $f, '>', $proxyfile or die $!;
print $f ($cfgtext = <<PROXYCFG);
@@ -71,7 +100,7 @@ is( $p->{http_proxy}, 'http://yoyodyne:8080/', 'read media proxy' );
is( $p->{user}, 'rafael', 'proxy user' );
is( $p->{pwd}, 'richard', 'proxy password' );
ok( dump_proxy_config(), 'dump_proxy_config' );
-$cfgtext2 = read_file($proxyfile);
+my $cfgtext2 = read_file($proxyfile);
$cfgtext2 =~ s/# generated.*\n//;
is( $cfgtext, $cfgtext2, 'dumped correctly' );
set_proxy_config(http_proxy => '');
@@ -81,4 +110,4 @@ $cfgtext2 =~ s/# generated.*\n//;
$cfgtext =~ s/^http_proxy.*\n//;
is( $cfgtext, $cfgtext2, 'dumped correctly' );
-END { unlink $file, $file.2, $proxyfile }
+END { unlink $file, glob("$file.*"), $proxyfile }
diff --git a/t/SPECS/arch_to_noarch_1.spec b/t/data/SPECS/arch_to_noarch_1.spec
index 05cff446..05cff446 100644
--- a/t/SPECS/arch_to_noarch_1.spec
+++ b/t/data/SPECS/arch_to_noarch_1.spec
diff --git a/t/SPECS/arch_to_noarch_2.spec b/t/data/SPECS/arch_to_noarch_2.spec
index 7be6925b..7be6925b 100644
--- a/t/SPECS/arch_to_noarch_2.spec
+++ b/t/data/SPECS/arch_to_noarch_2.spec
diff --git a/t/SPECS/arch_to_noarch_3.spec b/t/data/SPECS/arch_to_noarch_3.spec
index be9cdb4d..be9cdb4d 100644
--- a/t/SPECS/arch_to_noarch_3.spec
+++ b/t/data/SPECS/arch_to_noarch_3.spec
diff --git a/t/SPECS/arch_to_noarch_4.spec b/t/data/SPECS/arch_to_noarch_4.spec
index 7eb32705..7eb32705 100644
--- a/t/SPECS/arch_to_noarch_4.spec
+++ b/t/data/SPECS/arch_to_noarch_4.spec
diff --git a/t/data/SPECS/priority-upgrade-1/a-strict_1.spec b/t/data/SPECS/priority-upgrade-1/a-strict_1.spec
new file mode 100644
index 00000000..7c81849d
--- /dev/null
+++ b/t/data/SPECS/priority-upgrade-1/a-strict_1.spec
@@ -0,0 +1,14 @@
+Summary: a-strict
+Name: a-strict
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+Requires: b
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/priority-upgrade-1/a_1.spec b/t/data/SPECS/priority-upgrade-1/a_1.spec
new file mode 100644
index 00000000..8a997f9e
--- /dev/null
+++ b/t/data/SPECS/priority-upgrade-1/a_1.spec
@@ -0,0 +1,14 @@
+Summary: a
+Name: a
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+Requires: b
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/priority-upgrade-1/b_1.spec b/t/data/SPECS/priority-upgrade-1/b_1.spec
new file mode 100644
index 00000000..fa346315
--- /dev/null
+++ b/t/data/SPECS/priority-upgrade-1/b_1.spec
@@ -0,0 +1,13 @@
+Summary: b
+Name: b
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/priority-upgrade-2/a-strict_2.spec b/t/data/SPECS/priority-upgrade-2/a-strict_2.spec
new file mode 100644
index 00000000..0a44113d
--- /dev/null
+++ b/t/data/SPECS/priority-upgrade-2/a-strict_2.spec
@@ -0,0 +1,14 @@
+Summary: a-strict
+Name: a-strict
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+Requires: b >= 2
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/priority-upgrade-2/a_2.spec b/t/data/SPECS/priority-upgrade-2/a_2.spec
new file mode 100644
index 00000000..5048eed1
--- /dev/null
+++ b/t/data/SPECS/priority-upgrade-2/a_2.spec
@@ -0,0 +1,14 @@
+Summary: a
+Name: a
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+Requires: b
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/priority-upgrade-2/b_2.spec b/t/data/SPECS/priority-upgrade-2/b_2.spec
new file mode 100644
index 00000000..929014ad
--- /dev/null
+++ b/t/data/SPECS/priority-upgrade-2/b_2.spec
@@ -0,0 +1,14 @@
+Summary: b
+Name: b
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+Requires: bb
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/priority-upgrade-2/bb1_2.spec b/t/data/SPECS/priority-upgrade-2/bb1_2.spec
new file mode 100644
index 00000000..2b10a21a
--- /dev/null
+++ b/t/data/SPECS/priority-upgrade-2/bb1_2.spec
@@ -0,0 +1,14 @@
+Summary: bb1
+Name: bb1
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+Provides: bb
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/priority-upgrade-2/bb2_2.spec b/t/data/SPECS/priority-upgrade-2/bb2_2.spec
new file mode 100644
index 00000000..1732f9cd
--- /dev/null
+++ b/t/data/SPECS/priority-upgrade-2/bb2_2.spec
@@ -0,0 +1,14 @@
+Summary: bb2
+Name: bb2
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+Provides: bb
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/srpm-bootstrapping.spec b/t/data/SPECS/srpm-bootstrapping.spec
new file mode 100644
index 00000000..771b6226
--- /dev/null
+++ b/t/data/SPECS/srpm-bootstrapping.spec
@@ -0,0 +1,14 @@
+Summary: x
+Name: srpm-bootstrapping
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRequires: %{name}
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/SPECS/various.spec b/t/data/SPECS/various.spec
index b7d62e8f..b7d62e8f 100644
--- a/t/SPECS/various.spec
+++ b/t/data/SPECS/various.spec
diff --git a/t/data/SPECS/various2.spec b/t/data/SPECS/various2.spec
new file mode 100644
index 00000000..bcc16c5b
--- /dev/null
+++ b/t/data/SPECS/various2.spec
@@ -0,0 +1,38 @@
+Summary: various2
+Name: various2
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%prep
+echo foo > foo
+
+%build
+
+%install
+rm -rf $RPM_BUILD_ROOT
+for i in /etc/test-%{name} \
+ /var/lib/test-%{name}/foo1 /var/lib/test-%{name}/foo2 /var/lib/test-%{name}/foo3 \
+ /usr/share/locale/fr/LC_MESSAGES/test-%{name}.mo \
+ /usr/test-%{name}/foo; do
+ install -d `dirname $RPM_BUILD_ROOT$i`
+ echo foo > $RPM_BUILD_ROOT$i
+done
+
+%find_lang test-%{name}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%description
+x
+
+%files -f test-%{name}.lang
+%defattr(-,root,root)
+%doc foo
+%config(noreplace) /etc/*
+/var/lib/*
+/usr/test-%{name}
diff --git a/t/data/SPECS/various3.spec b/t/data/SPECS/various3.spec
new file mode 100644
index 00000000..5d147f75
--- /dev/null
+++ b/t/data/SPECS/various3.spec
@@ -0,0 +1,38 @@
+Summary: various3
+Name: various3
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%prep
+echo foo > foo
+
+%build
+
+%install
+rm -rf $RPM_BUILD_ROOT
+for i in /etc/test-%{name} \
+ /var/lib/test-%{name}/foo1 /var/lib/test-%{name}/foo2 /var/lib/test-%{name}/foo3 \
+ /usr/share/locale/fr/LC_MESSAGES/test-%{name}.mo \
+ /usr/test-%{name}/foo; do
+ install -d `dirname $RPM_BUILD_ROOT$i`
+ echo foo > $RPM_BUILD_ROOT$i
+done
+
+%find_lang test-%{name}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%description
+x
+
+%files -f test-%{name}.lang
+%defattr(-,root,root)
+%doc foo
+%config(noreplace) /etc/*
+/var/lib/*
+/usr/test-%{name}
diff --git a/t/data/media.cfg b/t/data/media.cfg
new file mode 100644
index 00000000..49a0a1d7
--- /dev/null
+++ b/t/data/media.cfg
@@ -0,0 +1,26 @@
+[media_info]
+version=2007.0
+mediacfg_version=2
+
+[various]
+hdlist=hdlist_various.cz
+name=Various
+size=1m
+
+[various2]
+hdlist=hdlist_various2.cz
+name=Various II
+size=1m
+
+[various3]
+hdlist=hdlist_various3.cz
+name=Various III
+size=1m
+noauto=1
+
+[various_bis]
+hdlist=hdlist_bis.cz
+name=Various Bis
+size=1m
+debug_for=various
+noauto=1
diff --git a/t/data/rpm-buggy/invalid-signature.rpm b/t/data/rpm-buggy/invalid-signature.rpm
new file mode 100644
index 00000000..20944405
--- /dev/null
+++ b/t/data/rpm-buggy/invalid-signature.rpm
Binary files differ
diff --git a/t/data/rpm-buggy/not-a-rpm.rpm b/t/data/rpm-buggy/not-a-rpm.rpm
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/t/data/rpm-buggy/not-a-rpm.rpm
@@ -0,0 +1 @@
+1
diff --git a/t/data/rpm-buggy/weird-header.rpm b/t/data/rpm-buggy/weird-header.rpm
new file mode 100644
index 00000000..51561037
--- /dev/null
+++ b/t/data/rpm-buggy/weird-header.rpm
Binary files differ
diff --git a/t/rpm-v3/libtermcap-2.0.8-2.i386.rpm b/t/data/rpm-v3/libtermcap-2.0.8-2.i386.rpm
index 390524dc..390524dc 100644
--- a/t/rpm-v3/libtermcap-2.0.8-2.i386.rpm
+++ b/t/data/rpm-v3/libtermcap-2.0.8-2.i386.rpm
Binary files differ
diff --git a/t/rpm-v3/nls-1.0-2.i386.rpm b/t/data/rpm-v3/nls-1.0-2.i386.rpm
index c05d7f85..c05d7f85 100644
--- a/t/rpm-v3/nls-1.0-2.i386.rpm
+++ b/t/data/rpm-v3/nls-1.0-2.i386.rpm
Binary files differ
diff --git a/t/rpm-v3/p2c-1.20-7.i386.rpm b/t/data/rpm-v3/p2c-1.20-7.i386.rpm
index a0fd4e41..a0fd4e41 100644
--- a/t/rpm-v3/p2c-1.20-7.i386.rpm
+++ b/t/data/rpm-v3/p2c-1.20-7.i386.rpm
Binary files differ
diff --git a/t/superuser--addmedia.t b/t/superuser--addmedia.t
index 776da2d1..661dce19 100644
--- a/t/superuser--addmedia.t
+++ b/t/superuser--addmedia.t
@@ -10,12 +10,17 @@ need_root_and_prepare();
my $name = 'various';
my $name2 = 'various2';
+my $name3 = 'various3';
-my @fields = qw(hdlist synthesis with_hdlist media_info_dir virtual);
+my @fields = qw(hdlist synthesis with_hdlist media_info_dir list virtual ignore);
try_medium({ media_info_dir => 'media_info' }, '');
+try_medium_({ list => 'list.various' }, { list => 'list.various2' },
+ '--probe-rpms', '--probe-rpms');
+
+
try_medium({ hdlist => 1, media_info_dir => 'media_info' },
'--probe-hdlist');
try_medium({ hdlist => 1, media_info_dir => 'media_info' },
@@ -37,6 +42,23 @@ try_medium({ synthesis => 1,
"with ../media_info/synthesis.hdlist_$name.cz",
"with ../media_info/synthesis.hdlist_$name2.cz");
+try_distrib({ hdlist => 1,
+ with_hdlist => "../..//media/media_info/hdlist_$name.cz",
+ with_hdlist2 => "../..//media/media_info/hdlist_$name2.cz",
+ with_hdlist3 => "../..//media/media_info/hdlist_$name3.cz" },
+ '');
+try_distrib({ hdlist => 1,
+ with_hdlist => "../..//media/media_info/hdlist_$name.cz",
+ with_hdlist2 => "../..//media/media_info/hdlist_$name2.cz",
+ with_hdlist3 => "../..//media/media_info/hdlist_$name3.cz" },
+ '--probe-hdlist');
+try_distrib({ synthesis => 1,
+ with_hdlist => "../..//media/media_info/synthesis.hdlist_$name.cz",
+ with_hdlist2 => "../..//media/media_info/synthesis.hdlist_$name2.cz",
+ with_hdlist3 => "../..//media/media_info/synthesis.hdlist_$name3.cz" },
+ '--probe-synthesis');
+
+
sub try_medium {
my ($want, $options, $o_options2) = @_;
my $want2 = { %$want, with_hdlist => $want->{with_hdlist2} || $want->{with_hdlist} };
@@ -47,6 +69,17 @@ sub try_medium {
try_medium_($want, $want2, '--virtual ' . $options, '--virtual ' . ($o_options2 || $options));
}
+sub try_distrib {
+ my ($want, $options) = @_;
+ my $want2 = { %$want, with_hdlist => $want->{with_hdlist2} || $want->{with_hdlist} };
+ my $want3 = { %$want, with_hdlist => $want->{with_hdlist3} || $want->{with_hdlist}, ignore => 1 };
+
+ try_distrib_($want, $want2, $want3, $options);
+
+ $want3->{virtual} = $want2->{virtual} = $want->{virtual} = 1;
+ try_distrib_($want, $want2, $want3, '--virtual ' . $options);
+}
+
sub try_medium_ {
my ($want, $want2, $options, $options2) = @_;
@@ -62,6 +95,15 @@ sub try_medium_ {
urpmi_removemedia($name);
}
+sub try_distrib_ {
+ my ($want, $want2, $want3, $options) = @_;
+
+ urpmi_addmedia("--distrib $name $::pwd $options");
+ check_conf($want, $want2, $want3);
+ check_urpmi($name, $name2);
+ urpmi_removemedia('-a');
+}
+
sub check_conf {
my (@want) = @_;
my $config = urpm::cfg::load_config("root/etc/urpmi/urpmi.cfg");
diff --git a/t/superuser--buggy-rpms.t b/t/superuser--buggy-rpms.t
new file mode 100644
index 00000000..34bacbdd
--- /dev/null
+++ b/t/superuser--buggy-rpms.t
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use strict;
+use lib '.', 't';
+use helper;
+use Test::More 'no_plan';
+BEGIN { use_ok "URPM" }
+
+need_root_and_prepare();
+
+#- things are going to be noisy, and that's normal
+open STDERR, '>/dev/null';
+
+my @pkgs = map { "data/rpm-buggy/$_" } 'invalid-signature.rpm', 'not-a-rpm.rpm', 'weird-header.rpm';
+foreach (@pkgs) {
+ system("rpm -K $_");
+ is($?, 1 << 8, "rpm -K $_");
+
+ system(urpmi_cmd() . " $_");
+ is($?, 2 << 8, "urpmi $_");
+
+ my $verif = URPM::verify_signature($_);
+ ok($verif =~ /NOT OK/);
+}
diff --git a/t/superuser--media_info_dir.t b/t/superuser--media_info_dir.t
index 9cb623f0..cd43e9d8 100644
--- a/t/superuser--media_info_dir.t
+++ b/t/superuser--media_info_dir.t
@@ -12,12 +12,12 @@ rpm_v3();
sub various {
my $name = 'various';
- foreach my $medium_name ('various', 'various_nohdlist', 'various_no_subdir') {
- urpmi_addmedia("$medium_name $::pwd/media/$medium_name");
+ foreach my $medium_name ('various', 'various_nohdlist', 'various nohdlist', 'various_no_subdir') {
+ urpmi_addmedia("'$medium_name' '$::pwd/media/$medium_name'");
urpmi($name);
is(`rpm -qa --root $::pwd/root`, "$name-1-1\n");
urpme($name);
- urpmi_removemedia($medium_name);
+ urpmi_removemedia("'$medium_name'");
}
}
diff --git a/t/superuser--priority-upgrade.t b/t/superuser--priority-upgrade.t
new file mode 100644
index 00000000..2486177e
--- /dev/null
+++ b/t/superuser--priority-upgrade.t
@@ -0,0 +1,116 @@
+#!/usr/bin/perl
+
+use strict;
+use lib '.', 't';
+use helper;
+use Expect;
+use urpm::util;
+use Test::More 'no_plan';
+
+need_root_and_prepare();
+
+$ENV{TESTING_priority_upgrade} = 1;
+my $name = 'priority-upgrade';
+
+test('a b', 'a', 'a', 'b');
+
+test('a-strict b', 'a-strict', 'a-strict b bb1', 'b',
+ [ 'What is your choice', "\n" ],
+ [ 'Proceed with the installation of the 2 packages?', "\n" ],
+ [ 'restarting urpmi', '' ],
+ );
+
+test_ab_auto_select('',
+ [ 'What is your choice', "\n" ],
+ [ 'Proceed with the installation of the 3 packages?', "\n" ],
+ );
+test_ab_auto_select('a',
+ [ 'Proceed with the installation of one package?', "\n" ],
+ [ 'restarting urpmi', '' ],
+ [ 'What is your choice', "\n" ],
+ [ 'Proceed with the installation of the 2 packages?', "\n" ],
+ );
+test_ab_auto_select('b',
+ [ 'What is your choice', "\n" ],
+ [ 'Proceed with the installation of the 2 packages?', "\n" ],
+ [ 'restarting urpmi', '' ],
+ [ 'Proceed with the installation of one package?', "\n" ],
+ );
+test_ab_auto_select('a,b',
+ [ 'What is your choice', "\n" ],
+ [ 'Proceed with the installation of the 3 packages?', "\n" ],
+ );
+
+
+sub test_ab_auto_select {
+ my ($priority_upgrade, @expected) = @_;
+ test('a b', undef, 'a b bb1', $priority_upgrade, @expected);
+}
+
+sub test {
+ my ($pkgs_v1, $wanted_v2, $pkgs_v2, $priority_upgrade, @expected) = @_;
+
+ unlink "$::pwd/media/$name";
+ symlink "$name-1", "$::pwd/media/$name";
+
+ urpmi_addmedia("$name $::pwd/media/$name");
+
+ if ($priority_upgrade) {
+ set_urpmi_cfg_global_options({ 'priority-upgrade' => $priority_upgrade });
+ }
+
+ urpmi($pkgs_v1);
+ my @pkgs_v1 = split(' ', $pkgs_v1);
+ is(`rpm -qa --root $::pwd/root | sort`, join('', map { "$_-1-1\n" } @pkgs_v1));
+
+ unlink "$::pwd/media/$name";
+ symlink "$name-2", "$::pwd/media/$name";
+
+ if ($wanted_v2) {
+ urpmi_update('-a');
+ urpmi_expected($wanted_v2, \@expected);
+ } else {
+ urpmi_expected('--auto-update', \@expected);
+ }
+
+
+ my @pkgs_v2 = split(' ', $pkgs_v2);
+ my @l = (
+ (map { "$_-2-1\n" } @pkgs_v2),
+ (map { "$_-1-1\n" } difference2(\@pkgs_v1, \@pkgs_v2)),
+ );
+ is(`rpm -qa --root $::pwd/root | sort`, join('', sort @l));
+
+ system_('rm -rf root');
+}
+
+sub urpmi_expected {
+ my ($options, $expected) = @_;
+
+ if (0) {
+ #- try it interactively for debugging
+ system_(urpm_cmd('urpmi', '-d') . " $options");
+ return;
+ }
+
+ my $cmd = urpmi_cmd() . " $options";
+ print "# $cmd\n";
+ my $expect = Expect->spawn($cmd);
+
+ foreach (@$expected) {
+ my ($msg, $to_send) = @$_;
+
+ my $ok = $expect->expect(2, # timeout in seconds
+ [ $msg => sub { $expect->send($to_send); } ]);
+ print "$to_send";
+ ok($ok, qq(expecting "$msg"));
+ $ok or return;
+ }
+
+ $expect->expect(2,
+ [ qr/restarting urpmi/ => sub { fail('not restarting urpmi') } ],
+ [ 'eof' => sub {} ]);
+
+ $expect->soft_close;
+ is($expect->exitstatus, 0, $cmd);
+}
diff --git a/t/superuser--srpm-bootstrapping.t b/t/superuser--srpm-bootstrapping.t
new file mode 100644
index 00000000..e0182ec0
--- /dev/null
+++ b/t/superuser--srpm-bootstrapping.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+
+use strict;
+use lib '.', 't';
+use helper;
+use Test::More 'no_plan';
+
+need_root_and_prepare();
+
+my $name = 'srpm-bootstrapping';
+
+urpmi_addmedia("$name $::pwd/media/$name");
+urpmi("--auto media/SRPMS-$name/$name-*.src.rpm");
+is(`rpm -qa --root $::pwd/root`, "$name-1-1\n");