summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-04-24 19:34:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-04-24 19:34:32 +0000
commit4df7583caa71a35d6d68c373fc0c62d1be6d955b (patch)
treebddf36169b314d82ff20036dea7e47fa4fec5bcd /t
parent7a606ec3537b2f465f8e06e99b445c756bfcca8f (diff)
downloadurpmi-4df7583caa71a35d6d68c373fc0c62d1be6d955b.tar
urpmi-4df7583caa71a35d6d68c373fc0c62d1be6d955b.tar.gz
urpmi-4df7583caa71a35d6d68c373fc0c62d1be6d955b.tar.bz2
urpmi-4df7583caa71a35d6d68c373fc0c62d1be6d955b.tar.xz
urpmi-4df7583caa71a35d6d68c373fc0c62d1be6d955b.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/README-urpmi/a.spec22
-rw-r--r--t/data/SPECS/README-urpmi/b.spec23
-rw-r--r--t/data/SPECS/README-urpmi/b_2.spec23
-rw-r--r--t/data/SPECS/README-urpmi/c.spec24
-rw-r--r--t/data/SPECS/README-urpmi/d.spec22
-rw-r--r--t/data/SPECS/README-urpmi/d_.spec25
-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/handle-conflict-deps/a-sup.spec14
-rw-r--r--t/data/SPECS/handle-conflict-deps/a.spec14
-rw-r--r--t/data/SPECS/handle-conflict-deps/b-sub.spec13
-rw-r--r--t/data/SPECS/handle-conflict-deps/b.spec15
-rw-r--r--t/data/SPECS/obsolete-and-conflict/a.spec24
-rw-r--r--t/data/SPECS/obsolete-and-conflict/b.spec26
-rw-r--r--t/data/SPECS/obsolete-and-conflict/c.spec24
-rw-r--r--t/data/SPECS/ordering-scriptlets/ash_1.spec24
-rw-r--r--t/data/SPECS/ordering-scriptlets/ash_2.spec13
-rw-r--r--t/data/SPECS/ordering-scriptlets/requires_post_1.spec16
-rw-r--r--t/data/SPECS/ordering-scriptlets/requires_post_2.spec13
-rw-r--r--t/data/SPECS/ordering-scriptlets/requires_postun_1.spec16
-rw-r--r--t/data/SPECS/ordering-scriptlets/requires_postun_2.spec13
-rw-r--r--t/data/SPECS/ordering-scriptlets/requires_pre_1.spec16
-rw-r--r--t/data/SPECS/ordering-scriptlets/requires_pre_2.spec13
-rw-r--r--t/data/SPECS/ordering-scriptlets/requires_preun_1.spec16
-rw-r--r--t/data/SPECS/ordering-scriptlets/requires_preun_2.spec13
-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/helper.pm26
-rw-r--r--t/superuser--README-urpmi.t52
-rw-r--r--t/superuser--addmedia.t44
-rw-r--r--t/superuser--buggy-rpms.t24
-rw-r--r--t/superuser--handle-conflict-deps.t21
-rw-r--r--t/superuser--media_info_dir.t13
-rw-r--r--t/superuser--obsolete-and-conflict.t24
-rw-r--r--t/superuser--ordering-scriptlets.t79
-rw-r--r--t/superuser--priority-upgrade.t116
-rw-r--r--t/superuser--srpm-bootstrapping.t14
60 files changed, 1151 insertions, 32 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/data/SPECS/README-urpmi/a.spec b/t/data/SPECS/README-urpmi/a.spec
new file mode 100644
index 00000000..d15019af
--- /dev/null
+++ b/t/data/SPECS/README-urpmi/a.spec
@@ -0,0 +1,22 @@
+Summary: a
+Name: a
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%build
+rm -rf $RPM_BUILD_ROOT
+echo "installing/upgrading %name" > README.urpmi
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc README.urpmi
diff --git a/t/data/SPECS/README-urpmi/b.spec b/t/data/SPECS/README-urpmi/b.spec
new file mode 100644
index 00000000..5c7cb4f4
--- /dev/null
+++ b/t/data/SPECS/README-urpmi/b.spec
@@ -0,0 +1,23 @@
+Summary: b
+Name: b
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%build
+rm -rf $RPM_BUILD_ROOT
+echo "installing %name" > README.install.urpmi
+echo "upgrading %name" > README.upgrade.urpmi
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc README.install.urpmi README.upgrade.urpmi
diff --git a/t/data/SPECS/README-urpmi/b_2.spec b/t/data/SPECS/README-urpmi/b_2.spec
new file mode 100644
index 00000000..15a63678
--- /dev/null
+++ b/t/data/SPECS/README-urpmi/b_2.spec
@@ -0,0 +1,23 @@
+Summary: b
+Name: b
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%build
+rm -rf $RPM_BUILD_ROOT
+echo "installing %name" > README.install.urpmi
+echo "upgrading %name" > README.upgrade.urpmi
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc README.install.urpmi README.upgrade.urpmi
diff --git a/t/data/SPECS/README-urpmi/c.spec b/t/data/SPECS/README-urpmi/c.spec
new file mode 100644
index 00000000..25f4df37
--- /dev/null
+++ b/t/data/SPECS/README-urpmi/c.spec
@@ -0,0 +1,24 @@
+Summary: c
+Name: c
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+Conflicts: a
+
+%description
+x
+
+%build
+rm -rf $RPM_BUILD_ROOT
+echo "installing %name" > README.install.urpmi
+echo "upgrading %name" > README.upgrade.urpmi
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc README.install.urpmi README.upgrade.urpmi
diff --git a/t/data/SPECS/README-urpmi/d.spec b/t/data/SPECS/README-urpmi/d.spec
new file mode 100644
index 00000000..2f7d40de
--- /dev/null
+++ b/t/data/SPECS/README-urpmi/d.spec
@@ -0,0 +1,22 @@
+Summary: d
+Name: d
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%build
+rm -rf $RPM_BUILD_ROOT
+echo "installing/upgrading %name" > README.urpmi
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc README.urpmi
diff --git a/t/data/SPECS/README-urpmi/d_.spec b/t/data/SPECS/README-urpmi/d_.spec
new file mode 100644
index 00000000..c24aadcb
--- /dev/null
+++ b/t/data/SPECS/README-urpmi/d_.spec
@@ -0,0 +1,25 @@
+Summary: d_
+Name: d_
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+Obsoletes: d <= 1
+Provides: d > 1
+
+%description
+x
+
+%build
+rm -rf $RPM_BUILD_ROOT
+echo "installing %name" > README.install.urpmi
+echo "upgrading %name" > README.upgrade.urpmi
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc README.install.urpmi README.upgrade.urpmi
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/handle-conflict-deps/a-sup.spec b/t/data/SPECS/handle-conflict-deps/a-sup.spec
new file mode 100644
index 00000000..ce10bcdf
--- /dev/null
+++ b/t/data/SPECS/handle-conflict-deps/a-sup.spec
@@ -0,0 +1,14 @@
+Summary: a-sup
+Name: a-sup
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+Requires: a
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/handle-conflict-deps/a.spec b/t/data/SPECS/handle-conflict-deps/a.spec
new file mode 100644
index 00000000..96dd9e7a
--- /dev/null
+++ b/t/data/SPECS/handle-conflict-deps/a.spec
@@ -0,0 +1,14 @@
+Summary: a
+Name: a
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+Conflicts: b
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/handle-conflict-deps/b-sub.spec b/t/data/SPECS/handle-conflict-deps/b-sub.spec
new file mode 100644
index 00000000..908d2b8f
--- /dev/null
+++ b/t/data/SPECS/handle-conflict-deps/b-sub.spec
@@ -0,0 +1,13 @@
+Summary: b-sub
+Name: b-sub
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/handle-conflict-deps/b.spec b/t/data/SPECS/handle-conflict-deps/b.spec
new file mode 100644
index 00000000..c10a64ac
--- /dev/null
+++ b/t/data/SPECS/handle-conflict-deps/b.spec
@@ -0,0 +1,15 @@
+Summary: b
+Name: b
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+Conflicts: a
+Requires: b-sub
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/obsolete-and-conflict/a.spec b/t/data/SPECS/obsolete-and-conflict/a.spec
new file mode 100644
index 00000000..9be9bda4
--- /dev/null
+++ b/t/data/SPECS/obsolete-and-conflict/a.spec
@@ -0,0 +1,24 @@
+Summary: a
+Name: a
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT/etc
+echo foo > $RPM_BUILD_ROOT/etc/foo
+echo bar > $RPM_BUILD_ROOT/etc/bar
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+/etc/*
diff --git a/t/data/SPECS/obsolete-and-conflict/b.spec b/t/data/SPECS/obsolete-and-conflict/b.spec
new file mode 100644
index 00000000..30413107
--- /dev/null
+++ b/t/data/SPECS/obsolete-and-conflict/b.spec
@@ -0,0 +1,26 @@
+Summary: b
+Name: b
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+Provides: a > 1
+Obsoletes: a <= 1
+Requires: c
+
+%description
+x
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT/etc
+echo foo > $RPM_BUILD_ROOT/etc/foo
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+/etc/*
diff --git a/t/data/SPECS/obsolete-and-conflict/c.spec b/t/data/SPECS/obsolete-and-conflict/c.spec
new file mode 100644
index 00000000..c40bb3b6
--- /dev/null
+++ b/t/data/SPECS/obsolete-and-conflict/c.spec
@@ -0,0 +1,24 @@
+Summary: c
+Name: c
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+Conflicts: a <= 1
+
+%description
+x
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT/etc
+echo bar > $RPM_BUILD_ROOT/etc/bar
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+/etc/*
diff --git a/t/data/SPECS/ordering-scriptlets/ash_1.spec b/t/data/SPECS/ordering-scriptlets/ash_1.spec
new file mode 100644
index 00000000..343a6e66
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/ash_1.spec
@@ -0,0 +1,24 @@
+Summary: ordering_ash
+Name: ordering_ash
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+Provides: /bin/ash
+BuildRequires: ash
+BuildRoot: %{_tmppath}/%{name}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -D /bin/ash $RPM_BUILD_ROOT/bin/ash
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%description
+x
+
+%files
+%defattr(-,root,root)
+/bin/*
diff --git a/t/data/SPECS/ordering-scriptlets/ash_2.spec b/t/data/SPECS/ordering-scriptlets/ash_2.spec
new file mode 100644
index 00000000..a6dbebad
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/ash_2.spec
@@ -0,0 +1,13 @@
+Summary: ordering_ash
+Name: ordering_ash
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/ordering-scriptlets/requires_post_1.spec b/t/data/SPECS/ordering-scriptlets/requires_post_1.spec
new file mode 100644
index 00000000..3603f6a6
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/requires_post_1.spec
@@ -0,0 +1,16 @@
+Summary: requires_post
+Name: requires_post
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%post -p /bin/ash
+echo "%post is running ok"
+
+%files
diff --git a/t/data/SPECS/ordering-scriptlets/requires_post_2.spec b/t/data/SPECS/ordering-scriptlets/requires_post_2.spec
new file mode 100644
index 00000000..bf31cabd
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/requires_post_2.spec
@@ -0,0 +1,13 @@
+Summary: requires_post
+Name: requires_post
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/ordering-scriptlets/requires_postun_1.spec b/t/data/SPECS/ordering-scriptlets/requires_postun_1.spec
new file mode 100644
index 00000000..8a9dc0fb
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/requires_postun_1.spec
@@ -0,0 +1,16 @@
+Summary: requires_postun
+Name: requires_postun
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%postun -p /bin/ash
+echo "%postun is running ok"
+
+%files
diff --git a/t/data/SPECS/ordering-scriptlets/requires_postun_2.spec b/t/data/SPECS/ordering-scriptlets/requires_postun_2.spec
new file mode 100644
index 00000000..d3a14355
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/requires_postun_2.spec
@@ -0,0 +1,13 @@
+Summary: requires_postun
+Name: requires_postun
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/ordering-scriptlets/requires_pre_1.spec b/t/data/SPECS/ordering-scriptlets/requires_pre_1.spec
new file mode 100644
index 00000000..cc5e9430
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/requires_pre_1.spec
@@ -0,0 +1,16 @@
+Summary: requires_pre
+Name: requires_pre
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%pre -p /bin/ash
+echo "%pre is running ok"
+
+%files
diff --git a/t/data/SPECS/ordering-scriptlets/requires_pre_2.spec b/t/data/SPECS/ordering-scriptlets/requires_pre_2.spec
new file mode 100644
index 00000000..93ce9f0d
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/requires_pre_2.spec
@@ -0,0 +1,13 @@
+Summary: requires_pre
+Name: requires_pre
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/ordering-scriptlets/requires_preun_1.spec b/t/data/SPECS/ordering-scriptlets/requires_preun_1.spec
new file mode 100644
index 00000000..9b0d6d90
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/requires_preun_1.spec
@@ -0,0 +1,16 @@
+Summary: requires_preun
+Name: requires_preun
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%preun -p /bin/ash
+echo "%preun is running ok"
+
+%files
diff --git a/t/data/SPECS/ordering-scriptlets/requires_preun_2.spec b/t/data/SPECS/ordering-scriptlets/requires_preun_2.spec
new file mode 100644
index 00000000..619f3576
--- /dev/null
+++ b/t/data/SPECS/ordering-scriptlets/requires_preun_2.spec
@@ -0,0 +1,13 @@
+Summary: requires_preun
+Name: requires_preun
+Version: 2
+Release: 1
+License: x
+Group: x
+Url: x
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
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/helper.pm b/t/helper.pm
index 58499a7f..11614842 100644
--- a/t/helper.pm
+++ b/t/helper.pm
@@ -8,6 +8,7 @@ our @EXPORT = qw(need_root_and_prepare
urpm_cmd urpmi_cmd urpmi urpme
urpmi_cfg set_urpmi_cfg_global_options
system_
+ check_installed_names check_installed_and_remove check_installed_and_urpme
);
my $using_root;
@@ -89,6 +90,31 @@ sub system_ {
ok($? == 0, $cmd);
}
+
+sub check_installed_names {
+ my (@names) = @_;
+ is(`rpm -qa --qf '%{name}\\n' --root $::pwd/root | sort`, join('', map { "$_\n" } sort(@names)));
+}
+
+sub check_nothing_installed() {
+ is(`rpm -qa --root $::pwd/root`, '');
+}
+
+sub check_installed_and_remove {
+ my (@names) = @_;
+ check_installed_names(@names);
+ system_("rpm --root $::pwd/root -e " . join(' ', @names));
+ check_nothing_installed();
+}
+
+sub check_installed_and_urpme {
+ my (@names) = @_;
+ check_installed_names(@names);
+ urpme(join(' ', @names));
+ check_nothing_installed();
+}
+
+
END {
$using_root and system('rm -rf root');
$server_pid and kill(9, $server_pid);
diff --git a/t/superuser--README-urpmi.t b/t/superuser--README-urpmi.t
new file mode 100644
index 00000000..70633c9c
--- /dev/null
+++ b/t/superuser--README-urpmi.t
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+
+use strict;
+use lib '.', 't';
+use helper;
+use Expect;
+use urpm::util;
+use Test::More 'no_plan';
+
+need_root_and_prepare();
+
+my $medium_name = 'README-urpmi';
+
+urpmi_addmedia("$medium_name $::pwd/media/$medium_name");
+
+test_a();
+test_b();
+test_c();
+test_d();
+
+sub test_a {
+ test_urpmi('a', 'installing/upgrading a');
+ check_installed_and_remove('a');
+}
+
+sub test_b {
+ system_("rpm --root $::pwd/root -i media/$medium_name/b-1-*.rpm");
+ test_urpmi('b', 'upgrading b');
+ check_installed_and_remove('b');
+}
+
+sub test_c {
+ test_urpmi('c', 'installing c');
+ check_installed_and_remove('c');
+}
+
+sub test_d {
+ test_urpmi('d', 'installing/upgrading d');
+ test_urpmi('d_', 'installing d_'); # what is the valid answer?
+ check_installed_and_remove('d_');
+}
+
+sub test_urpmi {
+ my ($para, $wanted) = @_;
+ my $urpmi = urpmi_cmd();
+ print "# $urpmi $para\n";
+ my $s = `$urpmi $para`;
+ print $s;
+ my ($msg) = $s =~ /\nMore information on package[^\n]*\n(.*?)\n-{70}/ms;
+
+ ok($msg eq $wanted, "wanted:$wanted, got:$msg");
+}
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--handle-conflict-deps.t b/t/superuser--handle-conflict-deps.t
new file mode 100644
index 00000000..a8a2e4c7
--- /dev/null
+++ b/t/superuser--handle-conflict-deps.t
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+
+# test from bugs #12696, #11885
+
+use strict;
+use lib '.', 't';
+use helper;
+use Expect;
+use urpm::util;
+use Test::More 'no_plan';
+
+need_root_and_prepare();
+
+my $name = 'handle-conflict-deps';
+urpmi_addmedia("$name $::pwd/media/$name");
+
+urpmi('--auto a-sup');
+check_installed_names('a', 'a-sup');
+
+urpmi('--auto b');
+check_installed_names('b', 'b-sub');
diff --git a/t/superuser--media_info_dir.t b/t/superuser--media_info_dir.t
index 9cb623f0..70d620a8 100644
--- a/t/superuser--media_info_dir.t
+++ b/t/superuser--media_info_dir.t
@@ -12,30 +12,27 @@ 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'");
}
}
sub rpm_v3 {
my @names = qw(libtermcap nls p2c);
- my $check_installed = sub {
- is(`rpm -qa --qf '%{name}\\n' --root $::pwd/root | sort`, join('', map { "$_\n" } @names));
- };
system_("rpm --root $::pwd/root -i --noscripts media/rpm-v3/*.rpm");
- $check_installed->();
+ check_installed_names(@names);
system_("rpm --root $::pwd/root -e --noscripts " . join(' ', @names));
is(`rpm -qa --root $::pwd/root`, '');
foreach my $medium_name ('rpm-v3', 'rpm-v3_nohdlist', 'rpm-v3_no_subdir') {
urpmi_addmedia("$medium_name $::pwd/media/$medium_name");
urpmi('--no-verify-rpm --noscripts ' . join(' ', @names));
- $check_installed->();
+ check_installed_names(@names);
urpme('-a --auto --noscripts');
is(`rpm -qa --root $::pwd/root`, '');
urpmi_removemedia($medium_name);
diff --git a/t/superuser--obsolete-and-conflict.t b/t/superuser--obsolete-and-conflict.t
new file mode 100644
index 00000000..221f224e
--- /dev/null
+++ b/t/superuser--obsolete-and-conflict.t
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+# package "a" is split into "b" and "c",
+# where "b" obsoletes "a" and requires "c"
+# "c" conflicts with "a" (but can't obsolete it)
+
+use strict;
+use lib '.', 't';
+use helper;
+use Expect;
+use urpm::util;
+use Test::More 'no_plan';
+
+need_root_and_prepare();
+
+my $name = 'obsolete-and-conflict';
+urpmi_addmedia("$name $::pwd/media/$name");
+
+urpmi('a');
+check_installed_names('a');
+
+urpmi('b c');
+
+check_installed_names('b', 'c');
diff --git a/t/superuser--ordering-scriptlets.t b/t/superuser--ordering-scriptlets.t
new file mode 100644
index 00000000..53e3c7cc
--- /dev/null
+++ b/t/superuser--ordering-scriptlets.t
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+
+use strict;
+use lib '.', 't';
+use helper;
+use Test::More 'no_plan';
+
+my $medium_name = 'ordering-scriptlets';
+
+need_root_and_prepare();
+
+my $ash_1 = "media/$medium_name/ordering_ash-1-*.rpm";
+my $ash_2 = "media/$medium_name/ordering_ash-2-*.rpm";
+
+test_install_remove_rpm("requires_$_") foreach qw(pre post preun postun);
+test_install_upgrade_rpm("requires_$_") foreach qw(preun postun);
+
+test_install_remove_urpmi("requires_$_", '') foreach qw(pre post preun postun);
+test_install_upgrade_urpmi("requires_$_", '') foreach qw(preun postun);
+
+test_install_remove_urpmi("requires_$_", '--split-level 1') foreach qw(pre post preun postun);
+test_install_upgrade_urpmi("requires_$_", '--split-level 1') foreach qw(preun postun);
+
+sub test_install_remove_rpm {
+ my ($name) = @_;
+
+ system_("rpm --root $::pwd/root -i $ash_1 media/$medium_name/$name-1-*.rpm");
+ check_installed_and_remove('ordering_ash', $name);
+
+ system_("rpm --root $::pwd/root -i media/$medium_name/$name-1-*.rpm $ash_1");
+ check_installed_and_remove($name, 'ordering_ash');
+}
+
+sub test_install_upgrade_rpm {
+ my ($name) = @_;
+
+ system_("rpm --root $::pwd/root -i $ash_1 media/$medium_name/$name-1-*.rpm");
+ system_("rpm --root $::pwd/root -U media/$medium_name/$name-2-*.rpm $ash_2");
+ check_installed_and_remove('ordering_ash', $name);
+
+
+ system_("rpm --root $::pwd/root -i media/$medium_name/$name-1-*.rpm $ash_1");
+ system_("rpm --root $::pwd/root -U $ash_2 media/$medium_name/$name-2-*.rpm");
+ check_installed_and_remove($name, 'ordering_ash');
+}
+
+sub test_install_remove_urpmi {
+ my ($name, $urpmi_option) = @_;
+ my @names = ('ordering_ash', $name);
+ my @names_rev = reverse @names;
+
+ urpmi_addmedia("$medium_name $::pwd/media/$medium_name");
+
+ urpmi(join(' ', $urpmi_option, @names));
+ check_installed_and_urpme(@names);
+
+ urpmi(join(' ', $urpmi_option, @names_rev));
+ check_installed_and_urpme(@names_rev);
+
+ urpmi_removemedia('-a');
+}
+
+sub test_install_upgrade_urpmi {
+ my ($name, $urpmi_option) = @_;
+ my @names = ('ordering_ash', $name);
+ my @names_rev = reverse @names;
+
+ urpmi_addmedia("$medium_name $::pwd/media/$medium_name");
+
+ system_("rpm --root $::pwd/root -i $ash_1 media/$medium_name/$name-1-*.rpm");
+ urpmi(join(' ', $urpmi_option, @names));
+ check_installed_and_urpme(@names);
+
+ system_("rpm --root $::pwd/root -i $ash_1 media/$medium_name/$name-1-*.rpm");
+ urpmi(join(' ', $urpmi_option, @names_rev));
+ check_installed_and_urpme(@names_rev);
+
+ urpmi_removemedia('-a');
+}
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");