summaryrefslogtreecommitdiff
path: root/tests/rpmvercmp.at
blob: 4d1252dd7fe588560d5c205883bdbf248f2d29a9 (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
107
#    rpmvercmp.at: rpm version comparison tests

AT_BANNER([RPM version comparison])

# ------------------------------
# Test normal upgrade
AT_SETUP([rpm -U upgrade to newer])
AT_CHECK([
RPMDB_CLEAR
rm -rf "${TOPDIR}"

for v in "1.0" "2.0"; do
    run rpmbuild --quiet -bb \
        --define "ver $v" \
          ${RPMDATA}/SPECS/versiontest.spec
done

runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
runroot rpm -q versiontest
],
[0],
[versiontest-2.0-1.noarch
],
[])
AT_CLEANUP

# Test upgrading to older package (should fail)
AT_SETUP([rpm -U upgrade to older])
AT_CHECK([
RPMDB_CLEAR

runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
],
[2],
[],
[	package versiontest-2.0-1.noarch (which is newer than versiontest-1.0-1.noarch) is already installed
])
AT_CLEANUP

# Test downgrading to older package with --oldpackage
AT_SETUP([rpm -U --oldpackage downgrade])
AT_CHECK([
RPMDB_CLEAR

runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
runroot rpm -U --oldpackage "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
runroot rpm -q versiontest
],
[0],
[versiontest-1.0-1.noarch
],
[ignore])
AT_CLEANUP

# Test upgrade of different versions in same transaction
AT_SETUP([rpm -U two versions of same package])
AT_CHECK([
RPMDB_CLEAR

runroot rpm -U \
  "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
  "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
runroot rpm -q versiontest
],
[0],
[versiontest-2.0-1.noarch
],
[])
AT_CLEANUP

# Test install of two different versions in same transaction
AT_SETUP([rpm -i two versions of same package])
AT_CHECK([
RPMDB_CLEAR

runroot rpm -i \
  "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
  "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
runroot rpm -q versiontest
],
[0],
[versiontest-2.0-1.noarch
versiontest-1.0-1.noarch
],
[])
AT_CLEANUP

# Test install of two different versions in same transaction
# TODO: test only one was installed
AT_SETUP([rpm -i identical versions of same package])
AT_CHECK([
RPMDB_CLEAR

runroot rpm -i \
  "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
  "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
runroot rpm -q versiontest
],
[0],
[versiontest-1.0-1.noarch
],
[])
AT_CLEANUP

# TODO: the same with epoch vs no epoch