Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.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: src/usr.sbin/pkg_install/version/test-pkg_version.sh,v 1.1.2.5 2002/06/03 15:34:59 bmah Exp $
33 # $DragonFly: src/usr.sbin/pkg_install/version/Attic/test-pkg_version.sh,v 1.2 2003/06/17 04:30:00 dillon Exp $
34 #
35
36 ECHO=echo
37 PKG_VERSION=./pkg_version.pl
38
39 test-pv ( ) { \
40     setvar v1 $1
41     setvar answer $2
42     setvar v2 $3
43     setvar type $4
44     res=`${PKG_VERSION} -t ${v1} ${v2}`
45     if [ ${res} != ${answer} ]; then \
46         ${ECHO} "${type} test failed (${v1} ${res} ${v2}, should have been ${answer})"; \
47     fi
48 }
49
50 # Test coercion of default PORTREVISION and PORTEPOCH
51 test-pv 0.10 "=" 0.10_0 coercion
52 test-pv 0.10 "=" 0.10,0 coercion
53 test-pv 0.10 "=" 0.10_0,0 coercion
54   
55 # Test various comparisons
56 test-pv 1.0 "=" 1.0 equality
57 test-pv 2.15a "=" 2.15a equality
58
59 test-pv 0.10 ">" 0.9 inequality
60 test-pv 0.9 "<" 0.10 inequality
61
62 test-pv 2.3p10 ">" 2.3p9 number/letter
63 test-pv 1.6.0 ">" 1.6.0.p3 number/letter
64 test-pv 1.0.b ">" 1.0.a3 number/letter
65 test-pv 1.0a ">" 1.0 number/letter
66 test-pv 1.0a "<" 1.0b number/letter
67 test-pv 5.0a ">" 5.0.b number/letter
68
69 test-pv 1.5_1 ">" 1.5 portrevision
70 test-pv 1.5_2 ">" 1.5_1 portrevision
71 test-pv 1.5_1 "<" 1.5.0.1 portrevision
72 test-pv 1.5 "<" 1.5.0.1 portrevision
73
74 test-pv 00.01.01,1 ">" 99.12.31 portepoch
75 test-pv 0.0.1_1,2 ">" 0.0.1,2 portrevision/portepoch
76 test-pv 0.0.1_1,3 ">" 0.0.1_2,2 portrevision/portepoch