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
35ECHO=echo
36PKG_VERSION=./pkg_version
37
38test-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
50test-pv 0.10 "=" 0.10_0 coercion
51test-pv 0.10 "=" 0.10,0 coercion
52test-pv 0.10 "=" 0.10_0,0 coercion
53
54# Test various comparisons
55test-pv 1.0 "=" 1.0 equality
56test-pv 2.15a "=" 2.15a equality
57
58test-pv 0.10 ">" 0.9 inequality
59test-pv 0.9 "<" 0.10 inequality
60
61test-pv 2.3p10 ">" 2.3p9 number/letter
62test-pv 1.6.0 ">" 1.6.0.p3 number/letter
63test-pv 1.0.b ">" 1.0.a3 number/letter
64test-pv 1.0a ">" 1.0 number/letter
65test-pv 1.0a "<" 1.0b number/letter
66test-pv 5.0a ">" 5.0.b number/letter
67
68test-pv 1.5_1 ">" 1.5 portrevision
69test-pv 1.5_2 ">" 1.5_1 portrevision
70test-pv 1.5_1 "<" 1.5.0.1 portrevision
71test-pv 1.5 "<" 1.5.0.1 portrevision
72
73test-pv 00.01.01,1 ">" 99.12.31 portepoch
74test-pv 0.0.1_1,2 ">" 0.0.1,2 portrevision/portepoch
75test-pv 0.0.1_1,3 ">" 0.0.1_2,2 portrevision/portepoch
76
77test-pv 2.0 ">" 2.a2 number/letter
78test-pv 3 "=" 3.0 equality
79test-pv 4a "<" 4a0 letter/zero
80test-pv 10a1b2 "=" 10a1.b2 separator
81
82test-pv 7pl "=" 7.pl patchevel
83test-pv 8.0.a "=" 8.0alpha alpha
84test-pv 9.b3.0 "=" 9beta3 beta
85test-pv 10.pre7 "=" 10pre7.0 pre
86test-pv 11.r "=" 11.rc rc
87
88test-pv 12pl "<" 12alpha alpha/patchevel
89test-pv 13.* "<" 13.pl star/patchevel
90
91test-pv 1.0.0+2003.09.06 "=" 1.0+2003.09.06 plus/multiple
92test-pv 1.0.1+2003.09.06 ">" 1.0+2003.09.06 plus/multiple
93test-pv 1.0.0+2003.09.06 "<" 1.0+2003.09.06_1 plus/portrevision
94test-pv 1.0.1+2003.09.06 ">" 1.0+2003.09.06_1 plus/portrevision
95