]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.sbin/pkg_install/version/test-pkg_version.sh
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / usr.sbin / pkg_install / version / test-pkg_version.sh
1 #!/bin/sh
2 #
3 # Copyright 2001 Bruce A. Mah
4 #
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 #    notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 #    notice, this list of conditions and the following disclaimer in the
14 #    documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 # IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #
27 # test-pkg_version.sh
28 #
29 # Regression testing for pkg_version
30 # Originally from an idea by "Akinori MUSHA" <knu@iDaemons.org>
31 #
32 # $FreeBSD$
33 #
34
35 ECHO=echo
36 PKG_VERSION=./pkg_version
37
38 test-pv ( ) { \
39     setvar v1 $1
40     setvar answer $2
41     setvar v2 $3
42     setvar type $4
43     res=`${PKG_VERSION} -t ${v1} ${v2}`
44     if [ ${res} != ${answer} ]; then \
45         ${ECHO} "${type} test failed (${v1} ${res} ${v2}, should have been ${answer})"; \
46     fi
47 }
48
49 # Test coercion of default PORTREVISION and PORTEPOCH
50 test-pv 0.10 "=" 0.10_0 coercion
51 test-pv 0.10 "=" 0.10,0 coercion
52 test-pv 0.10 "=" 0.10_0,0 coercion
53
54 # Test various comparisons
55 test-pv 1.0 "=" 1.0 equality
56 test-pv 2.15a "=" 2.15a equality
57
58 test-pv 0.10 ">" 0.9 inequality
59 test-pv 0.9 "<" 0.10 inequality
60
61 test-pv 2.3p10 ">" 2.3p9 number/letter
62 test-pv 1.6.0 ">" 1.6.0.p3 number/letter
63 test-pv 1.0.b ">" 1.0.a3 number/letter
64 test-pv 1.0a ">" 1.0 number/letter
65 test-pv 1.0a "<" 1.0b number/letter
66 test-pv 5.0a ">" 5.0.b number/letter
67
68 test-pv 1.5_1 ">" 1.5 portrevision
69 test-pv 1.5_2 ">" 1.5_1 portrevision
70 test-pv 1.5_1 "<" 1.5.0.1 portrevision
71 test-pv 1.5 "<" 1.5.0.1 portrevision
72
73 test-pv 00.01.01,1 ">" 99.12.31 portepoch
74 test-pv 0.0.1_1,2 ">" 0.0.1,2 portrevision/portepoch
75 test-pv 0.0.1_1,3 ">" 0.0.1_2,2 portrevision/portepoch
76
77 test-pv 2.0 ">" 2.a2 number/letter
78 test-pv 3 "=" 3.0 equality
79 test-pv 4a "<" 4a0 letter/zero
80 test-pv 10a1b2 "=" 10a1.b2 separator
81
82 test-pv 7pl "=" 7.pl patchevel
83 test-pv 8.0.a "=" 8.0alpha alpha
84 test-pv 9.b3.0 "=" 9beta3 beta
85 test-pv 10.pre7 "=" 10pre7.0 pre
86 test-pv 11.r "=" 11.rc rc
87
88 test-pv 12pl "<" 12alpha alpha/patchevel
89 test-pv 13.* "<" 13.pl star/patchevel
90
91 test-pv 1.0.0+2003.09.06 "=" 1.0+2003.09.06 plus/multiple
92 test-pv 1.0.1+2003.09.06 ">" 1.0+2003.09.06 plus/multiple
93 test-pv 1.0.0+2003.09.06 "<" 1.0+2003.09.06_1 plus/portrevision
94 test-pv 1.0.1+2003.09.06 ">" 1.0+2003.09.06_1 plus/portrevision