summaryrefslogtreecommitdiffstats
path: root/t/superuser--ordering-scriptlets.t
blob: 6f29ce9d1b211e12ad0d85144a61ad81b942ffd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl

# /bin/a in package is a simple "cat"
use strict;
use lib '.', 't';
use helper;
use Test::More 'no_plan';

my $medium_name = 'ordering-scriptlets';

need_root_and_prepare();

my $a_1 = "media/$medium_name/a-1-*.rpm";
my $a_2 = "media/$medium_name/a-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 --split-length 1') foreach qw(pre post preun postun);
test_install_upgrade_urpmi("requires_$_", '--split-level 1 --split-length 1') foreach qw(preun postun);

sub test_install_remove_rpm {
    my ($name) = @_;

    system_("rpm --root $::pwd/root -i $a_1 media/$medium_name/$name-1-*.rpm");
    check_installed_and_remove('a', $name);

    system_("rpm --root $::pwd/root -i media/$medium_name/$name-1-*.rpm $a_1");
    check_installed_and_remove($name, 'a');
}

sub test_install_upgrade_rpm {
    my ($name) = @_;

    system_("rpm --root $::pwd/root -i $a_1 media/$medium_name/$name-1-*.rpm");
    system_("rpm --root $::pwd/root -U media/$medium_name/$name-2-*.rpm $a_2");
    check_installed_and_remove('a', $name);


    system_("rpm --root $::pwd/root -i media/$medium_name/$name-1-*.rpm $a_1");
    system_("rpm --root $::pwd/root -U $a_2 media/$medium_name/$name-2-*.rpm");
    check_installed_and_remove($name, 'a');
}

sub test_install_remove_urpmi {
    my ($name, $urpmi_option) = @_;
    my @names = ('a', $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 = ('a', $name);
    my @names_rev = reverse @names;

    urpmi_addmedia("$medium_name $::pwd/media/$medium_name");

    system_("rpm --root $::pwd/root -i $a_1 media/$medium_name/$name-1-*.rpm");
    urpmi(join(' ', $urpmi_option, @names));
    check_installed_and_urpme(@names);

    system_("rpm --root $::pwd/root -i $a_1 media/$medium_name/$name-1-*.rpm");
    urpmi(join(' ', $urpmi_option, @names_rev));
    check_installed_and_urpme(@names_rev);

    urpmi_removemedia('-a');
}