Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Mar 2001 20:43:02 -0800
From:      bmah@freebsd.org (Bruce A. Mah)
To:        "Akinori MUSHA" <knu@iDaemons.org>
Cc:        "Bruce A. Mah" <bmah@freebsd.org>, freebsd-ports@freebsd.org, knu@freebsd.org
Subject:   Re: pkg_version comparison routine 
Message-ID:  <200104010443.f314h2J82423@bmah-freebsd-0.cisco.com>
In-Reply-To: <86y9tqc4tj.wl@archon.local.idaemons.org> 
References:  <200103280237.f2S2bUP02277@bmah-freebsd-0.cisco.com> <86y9tqc4tj.wl@archon.local.idaemons.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--==_Exmh_2070676098P
Content-Type: text/plain; charset=us-ascii

If memory serves me right, "Akinori MUSHA" wrote:

> I think something similar to this can be written in Bourne shell using
> the `pkg_version -t' feature, so that we can always ensure the
> correctness of its behavior.

OK, I've got a little script (below) that we can run to test 
pkg_version.  Maybe I can put it in the same directory as 
pkg_version.pl; we won't install it but at least if it is in CVS, we 
can use it when hacking on pkg_version.

Thanks for the idea, with so many weird cases that these routines need 
to handle, it's good to have a program like this.

Bruce.

PS.  I haven't committed the diffs I posted earlier because I'm still 
waiting for some feedback as to whether or not they work.  I'm pretty 
happy with the new code, and in fact I've been using it on my 
workstations while testing some port-upgrading stuff.

#!/bin/sh
#
# Copyright 2001 Bruce A. Mah
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# test-pkg_version.sh
#
# Regression testing for pkg_version
# Originally from an idea by "Akinori MUSHA" <knu@iDaemons.org>
#
# $FreeBSD$
#

ECHO=echo
PKG_VERSION=./pkg_version.pl

test-pv ( ) { \
    setvar v1 $1
    setvar answer $2
    setvar v2 $3
    setvar type $4
    res=`${PKG_VERSION} -t ${v1} ${v2}`
    if [ ${res} != ${answer} ]; then \
	${ECHO} "${type} test failed (${v1} ${res} ${v2}, should have been ${answer})"; \
    fi
}

# Test coercion of default PORTREVISION and PORTEPOCH
test-pv 0.10 "=" 0.10_0 coercion
test-pv 0.10 "=" 0.10,0 coercion
test-pv 0.10 "=" 0.10_0,0 coercion
  
# Test various comparisons
test-pv 1.0 "=" 1.0 equality
test-pv 2.15a "=" 2.15a equality

test-pv 0.10 ">" 0.9 inequality
test-pv 0.9 "<" 0.10 inequality

test-pv 2.3p10 ">" 2.3p9 number/letter
test-pv 1.6.0 ">" 1.6.0.p3 number/letter
test-pv 1.0.b ">" 1.0.a3 number/letter
test-pv 1.0a "<" 1.0 number/letter
test-pv 5.0a "<" 5.0.b number/letter

test-pv 1.5_1 ">" 1.5 portrevision
test-pv 1.5_2 ">" 1.5_1 portrevision

test-pv 00.01.01,1 ">" 99.12.31 portepoch
test-pv 0.0.1_1,2 ">" 0.0.1,2 portrevision/portepoch
test-pv 0.0.1_1,3 ">" 0.0.1_2,2 portrevision/portepoch



--==_Exmh_2070676098P
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (FreeBSD)
Comment: Exmh version 2.2 06/23/2000

iD8DBQE6xrHW2MoxcVugUsMRAuDbAKDhIs6rkM7DTALzKds7U1VWvfoC7wCgup0E
XWE6iyHY2A7/c/ewzAPUizA=
=jKze
-----END PGP SIGNATURE-----

--==_Exmh_2070676098P--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200104010443.f314h2J82423>