summaryrefslogtreecommitdiffstats
path: root/t/superuser--file-conflicts.t
blob: 195f5006a66caaa8502a5f3e8bc0a0034b51a839 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl

# a and b contains the same file name, with different content => should fail
# a and c contents the same file name, with same content => should work
# a and d contents the same directory name => should work
# a and e contents the same path for a directory vs a symlink => should fail

use strict;
use lib '.', 't';
use helper;
use Expect;
use urpm::util;
use Test::More 'no_plan';

need_root_and_prepare();

my $medium_name = 'file-conflicts';

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


test_rpm_same_transaction();
test_rpm_different_transactions();

test_urpmi_same_transaction();
test_urpmi_different_transactions();

sub test_rpm_same_transaction {
    # disabled, fail (#32528)
    #test_rpm_i_fail('a', 'b');
    #check_nothing_installed();

    test_rpm_i_succeeds('a', 'c');
    check_installed_and_remove('a', 'c');

    test_rpm_i_succeeds('a', 'd');
    check_installed_and_remove('a', 'd');

    # disabled, fail (#32528)
    #test_rpm_i_fail('a', 'e');
    #check_nothing_installed();
}

sub test_rpm_different_transactions {
    test_rpm_i_succeeds('a');
    test_rpm_i_fail('b');
    check_installed_names('a');

    test_rpm_i_fail('e');
    check_installed_names('a');

    test_rpm_i_succeeds('c');
    check_installed_and_remove('a', 'c');

    test_rpm_i_succeeds('a');
    test_rpm_i_succeeds('d');
    check_installed_and_remove('a', 'd');
}

sub test_urpmi_same_transaction {
    # disabled, fail (#32528)
    #test_urpmi_fail('a', 'b');
    #check_nothing_installed();

    urpmi('a c');
    check_installed_and_remove('a', 'c');

    urpmi('a d');
    check_installed_and_remove('a', 'd');

    # disabled, fail (#32528)
    #urpmi('a e');
    #check_installed_and_remove('a', 'e');
}

sub test_urpmi_different_transactions {
    urpmi('a');
    test_urpmi_fail('b');
    check_installed_names('a');

    test_urpmi_fail('e');
    check_installed_names('a');

    # disabled, fail when dropping RPMTAG_FILEDIGESTS
    #urpmi('c');
    #check_installed_and_remove('a', 'c');

    #urpmi('a');
    urpmi('d');
    check_installed_and_remove('a', 'd');
}

sub test_rpm_i_succeeds {
    my (@rpms) = @_;
    my $rpms = join(' ', map { "media/$medium_name/$_-*.rpm" } @rpms);
    system_("rpm --root $::pwd/root -i $rpms");
}
sub test_rpm_i_fail {
    my (@rpms) = @_;
    my $rpms = join(' ', map { "media/$medium_name/$_-*.rpm" } @rpms);
    system_should_fail("rpm --root $::pwd/root -i $rpms");
}
sub test_urpmi_fail {
    my ($rpms) = @_;
    system_should_fail(urpmi_cmd() . " $rpms");
}