175142Sbmah#!/bin/sh
275142Sbmah#
375142Sbmah# Copyright 2001 Bruce A. Mah
475142Sbmah#
575142Sbmah# All rights reserved.
675142Sbmah#
775142Sbmah# Redistribution and use in source and binary forms, with or without
875142Sbmah# modification, are permitted provided that the following conditions
975142Sbmah# are met:
1075142Sbmah# 1. Redistributions of source code must retain the above copyright
1175142Sbmah#    notice, this list of conditions and the following disclaimer.
1275142Sbmah# 2. Redistributions in binary form must reproduce the above copyright
1375142Sbmah#    notice, this list of conditions and the following disclaimer in the
1475142Sbmah#    documentation and/or other materials provided with the distribution.
1575142Sbmah#
1675142Sbmah# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
1775142Sbmah# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1875142Sbmah# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1975142Sbmah# IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
2075142Sbmah# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2175142Sbmah# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2275142Sbmah# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2375142Sbmah# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2475142Sbmah# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2575142Sbmah# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2675142Sbmah#
2775142Sbmah# test-pkg_version.sh
2875142Sbmah#
2975142Sbmah# Regression testing for pkg_version
3075142Sbmah# Originally from an idea by "Akinori MUSHA" <knu@iDaemons.org>
3175142Sbmah#
3275142Sbmah# $FreeBSD$
3375142Sbmah#
3475142Sbmah
3575142SbmahECHO=echo
3698766SmarkmPKG_VERSION=./pkg_version
3775142Sbmah
3875142Sbmahtest-pv ( ) { \
3975142Sbmah    setvar v1 $1
4075142Sbmah    setvar answer $2
4175142Sbmah    setvar v2 $3
4275142Sbmah    setvar type $4
4375142Sbmah    res=`${PKG_VERSION} -t ${v1} ${v2}`
4475142Sbmah    if [ ${res} != ${answer} ]; then \
4575142Sbmah	${ECHO} "${type} test failed (${v1} ${res} ${v2}, should have been ${answer})"; \
4675142Sbmah    fi
4775142Sbmah}
4875142Sbmah
4975142Sbmah# Test coercion of default PORTREVISION and PORTEPOCH
5075142Sbmahtest-pv 0.10 "=" 0.10_0 coercion
5175142Sbmahtest-pv 0.10 "=" 0.10,0 coercion
5275142Sbmahtest-pv 0.10 "=" 0.10_0,0 coercion
53151200Skrion
5475142Sbmah# Test various comparisons
5575142Sbmahtest-pv 1.0 "=" 1.0 equality
5675142Sbmahtest-pv 2.15a "=" 2.15a equality
5775142Sbmah
5875142Sbmahtest-pv 0.10 ">" 0.9 inequality
5975142Sbmahtest-pv 0.9 "<" 0.10 inequality
6075142Sbmah
6175142Sbmahtest-pv 2.3p10 ">" 2.3p9 number/letter
6275142Sbmahtest-pv 1.6.0 ">" 1.6.0.p3 number/letter
6375142Sbmahtest-pv 1.0.b ">" 1.0.a3 number/letter
6475715Sbmahtest-pv 1.0a ">" 1.0 number/letter
6575715Sbmahtest-pv 1.0a "<" 1.0b number/letter
6675715Sbmahtest-pv 5.0a ">" 5.0.b number/letter
6775142Sbmah
6875142Sbmahtest-pv 1.5_1 ">" 1.5 portrevision
6975142Sbmahtest-pv 1.5_2 ">" 1.5_1 portrevision
7097411Ssobomaxtest-pv 1.5_1 "<" 1.5.0.1 portrevision
7197411Ssobomaxtest-pv 1.5 "<" 1.5.0.1 portrevision
7275142Sbmah
7375142Sbmahtest-pv 00.01.01,1 ">" 99.12.31 portepoch
7475142Sbmahtest-pv 0.0.1_1,2 ">" 0.0.1,2 portrevision/portepoch
7575142Sbmahtest-pv 0.0.1_1,3 ">" 0.0.1_2,2 portrevision/portepoch
76131274Seik
77131274Seiktest-pv 2.0 ">" 2.a2 number/letter
78131274Seiktest-pv 3 "=" 3.0 equality
79131274Seiktest-pv 4a "<" 4a0 letter/zero
80131274Seiktest-pv 10a1b2 "=" 10a1.b2 separator
81131274Seik
82131274Seiktest-pv 7pl "=" 7.pl patchevel
83131274Seiktest-pv 8.0.a "=" 8.0alpha alpha
84131274Seiktest-pv 9.b3.0 "=" 9beta3 beta
85131274Seiktest-pv 10.pre7 "=" 10pre7.0 pre
86131274Seiktest-pv 11.r "=" 11.rc rc
87131274Seik
88131274Seiktest-pv 12pl "<" 12alpha alpha/patchevel
89131274Seiktest-pv 13.* "<" 13.pl star/patchevel
90131274Seik
91131274Seiktest-pv 1.0.0+2003.09.06 "=" 1.0+2003.09.06 plus/multiple
92131274Seiktest-pv 1.0.1+2003.09.06 ">" 1.0+2003.09.06 plus/multiple
93131274Seiktest-pv 1.0.0+2003.09.06 "<" 1.0+2003.09.06_1 plus/portrevision
94131274Seiktest-pv 1.0.1+2003.09.06 ">" 1.0+2003.09.06_1 plus/portrevision
95