]>
wolfpit.net Git - tool/Arch-pacman/.git/blob - test/util/vercmptest.sh
3 # vercmptest - a test suite for the vercmp/libalpm program
5 # Copyright (c) 2008 by Dan McGee <dan@archlinux.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # default binary if one was not specified as $1
21 bin
=${1:-${PMTEST_UTIL_DIR}vercmp}
22 # holds counts of tests
27 # use first arg as our binary if specified
28 if ! type -p "$bin"; then
29 echo "Bail out! vercmp binary ($bin) could not be located"
34 # pass ver1 ver2 ret expected
36 echo "ok $run - ver1: $1 ver2: $2 ret: $3"
40 # fail ver1 ver2 ret expected
42 echo "not ok $run - test: ver1: $1 ver2: $2 ret: $3 expected: $4"
47 # runtest ver1 ver2 expected
53 [[ -n $ret && $ret -eq $3 ]] || func
='fail'
55 # and run its mirror case just to be sure
58 [[ $3 -eq 1 ]] && reverse
=-1
59 [[ $3 -eq -1 ]] && reverse
=1
62 [[ -n $ret && $ret -eq $reverse ]] || func
='fail'
63 $func $2 $1 $ret $reverse
66 echo "# Running vercmp tests..."
72 # all similar length, no pkgrel
80 runtest
1.5.0-1 1.5.0-1 0
81 runtest
1.5.0-1 1.5.0-2 -1
82 runtest
1.5.0-1 1.5.1-1 -1
83 runtest
1.5.0-2 1.5.1-1 -1
85 # with pkgrel, mixed lengths
86 runtest
1.5-1 1.5.1-1 -1
87 runtest
1.5-2 1.5.1-1 -1
88 runtest
1.5-2 1.5.1-2 -1
90 # mixed pkgrel inclusion
97 # alphanumeric versions
98 runtest
1.5b
-1 1.5-1 -1
100 runtest
1.5b
-1 1.5 -1
101 runtest
1.5b
1.5.1 -1
104 runtest
1.0a
1.0alpha
-1
105 runtest
1.0alpha
1.0b
-1
106 runtest
1.0b
1.0beta
-1
107 runtest
1.0beta
1.0rc
-1
110 # going crazy? alpha-dotted versions
112 runtest
1.5.b
1.5.a
1
113 runtest
1.5.1 1.5.b
1
115 # alpha dots and dashes
116 runtest
1.5.b
-1 1.5.b
0
117 runtest
1.5-1 1.5.b
-1
119 # same/similar content, differing separators
121 runtest
2.0_a
2_0.a
0
122 runtest
2.0a
2.0.a
-1
125 # epoch included version comparisons
126 runtest
0:1.0 0:1.0 0
127 runtest
0:1.0 0:1.1 -1
128 runtest
1:1.0 0:1.0 1
129 runtest
1:1.0 0:1.1 1
130 runtest
1:1.0 2:1.1 -1
132 # epoch + sometimes present pkgrel
133 runtest
1:1.0 0:1.0-1 1
134 runtest
1:1.0-1 0:1.1-1 1
136 # epoch included on one version
146 if [[ $failure -eq 0 ]]; then
147 echo "# All $run tests successful"
151 echo "# $failure of $run tests failed"