]>
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
22 # holds counts of tests
28 # pass ver1 ver2 ret expected
30 echo "ok $run - ver1: $1 ver2: $2 ret: $3"
34 # fail ver1 ver2 ret expected
36 echo "not ok $run - test: ver1: $1 ver2: $2 ret: $3 expected: $4"
41 # runtest ver1 ver2 expected
47 [[ -n $ret && $ret -eq $3 ]] || func
='fail'
49 # and run its mirror case just to be sure
52 [[ $3 -eq 1 ]] && reverse
=-1
53 [[ $3 -eq -1 ]] && reverse
=1
56 [[ -n $ret && $ret -eq $reverse ]] || func
='fail'
57 $func $2 $1 $ret $reverse
60 # use first arg as our binary if specified
61 [[ -n "$1" ]] && bin
="$1"
63 if ! type -p "$bin"; then
64 echo "Bail out! vercmp binary ($bin) could not be located"
68 echo "# Running vercmp tests..."
74 # all similar length, no pkgrel
82 runtest
1.5.0-1 1.5.0-1 0
83 runtest
1.5.0-1 1.5.0-2 -1
84 runtest
1.5.0-1 1.5.1-1 -1
85 runtest
1.5.0-2 1.5.1-1 -1
87 # with pkgrel, mixed lengths
88 runtest
1.5-1 1.5.1-1 -1
89 runtest
1.5-2 1.5.1-1 -1
90 runtest
1.5-2 1.5.1-2 -1
92 # mixed pkgrel inclusion
99 # alphanumeric versions
100 runtest
1.5b
-1 1.5-1 -1
102 runtest
1.5b
-1 1.5 -1
103 runtest
1.5b
1.5.1 -1
106 runtest
1.0a
1.0alpha
-1
107 runtest
1.0alpha
1.0b
-1
108 runtest
1.0b
1.0beta
-1
109 runtest
1.0beta
1.0rc
-1
112 # going crazy? alpha-dotted versions
114 runtest
1.5.b
1.5.a
1
115 runtest
1.5.1 1.5.b
1
117 # alpha dots and dashes
118 runtest
1.5.b
-1 1.5.b
0
119 runtest
1.5-1 1.5.b
-1
121 # same/similar content, differing separators
123 runtest
2.0_a
2_0.a
0
124 runtest
2.0a
2.0.a
-1
127 # epoch included version comparisons
128 runtest
0:1.0 0:1.0 0
129 runtest
0:1.0 0:1.1 -1
130 runtest
1:1.0 0:1.0 1
131 runtest
1:1.0 0:1.1 1
132 runtest
1:1.0 2:1.1 -1
134 # epoch + sometimes present pkgrel
135 runtest
1:1.0 0:1.0-1 1
136 runtest
1:1.0-1 0:1.1-1 1
138 # epoch included on one version
148 if [[ $failure -eq 0 ]]; then
149 echo "# All $run tests successful"
153 echo "# $failure of $run tests failed"