NetBSD Problem Report #48537

From www@NetBSD.org  Mon Jan 20 20:43:20 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7A421A6482
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 20 Jan 2014 20:43:20 +0000 (UTC)
Message-Id: <20140120204318.AC7D2A6487@mollari.NetBSD.org>
Date: Mon, 20 Jan 2014 20:43:18 +0000 (UTC)
From: yaneurabeya@gmail.com
Reply-To: yaneurabeya@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [PATCH] add FreeBSD support to tests/bin/expr/t_expr.sh
X-Send-Pr-Version: www-1.0

>Number:         48537
>Category:       bin
>Synopsis:       [PATCH] add FreeBSD support to tests/bin/expr/t_expr.sh
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 20 20:45:00 +0000 2014
>Closed-Date:    Thu Jan 08 06:33:31 +0000 2015
>Last-Modified:  Thu Jan 08 06:33:31 +0000 2015
>Originator:     Garrett Cooper
>Release:        n/a
>Organization:
n/a
>Environment:
n/a
>Description:
The attached patch adds FreeBSD support to bin/expr/t_expr.sh. I had to do some minor refactoring to support the fact that expr on FreeBSD...
- Does option parsing
- Has different error messages when dealing with integer overflows
- Always fails with syntax errors when dealing with dangling arithmetic operators (and thus I had to split off the arithmetic_ops testcase into 6 separate testcases in order to properly use atf_expect_fail).

The results can be found below for FreeBSD 11-CURRENT:

# kyua report
===> Expected failures
t_expr:arithmetic_ops01  ->  expected_failure: Results in a syntax errors on FreeBSD: Expected '0', got 'expr: syntax error' from expression:  -- .java_wrapper : /  [0.025s]
t_expr:arithmetic_ops02  ->  expected_failure: Results in a syntax errors on FreeBSD: Expected '0', got 'expr: syntax error' from expression:  -- 4 : *  [0.029s]
t_expr:arithmetic_ops03  ->  expected_failure: Results in a syntax errors on FreeBSD: Expected '0', got 'expr: syntax error' from expression:  -- 4 : +  [0.045s]
t_expr:arithmetic_ops04  ->  expected_failure: Results in a syntax errors on FreeBSD: Expected '0', got 'expr: syntax error' from expression:  -- 4 : -  [0.030s]
t_expr:arithmetic_ops05  ->  expected_failure: Results in a syntax errors on FreeBSD: Expected '0', got 'expr: syntax error' from expression:  -- 4 : /  [0.027s]
t_expr:arithmetic_ops06  ->  expected_failure: Results in a syntax errors on FreeBSD: Expected '0', got 'expr: syntax error' from expression:  -- 4 : %  [0.032s]
===> Summary
Action: 59
Test cases: 19 total, 0 skipped, 6 expected failures, 0 broken, 0 failed
Total time: 0.623s
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Garrett Cooper <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48537: [PATCH] add FreeBSD support to tests/bin/expr/t_expr.sh
Date: Mon, 20 Jan 2014 12:47:04 -0800

 --Apple-Mail=_C5ED1E86-0AAA-448D-B923-6EF1FFCE9DDC
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=windows-1252

 	And now the patch=85
 Thanks!
 -Garrett

 --Apple-Mail=_C5ED1E86-0AAA-448D-B923-6EF1FFCE9DDC
 Content-Disposition: attachment;
 	filename=add-freebsd-bin-expr-support-to-t_expr.patch
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="add-freebsd-bin-expr-support-to-t_expr.patch"
 Content-Transfer-Encoding: 7bit

 Index: tests/bin/expr/t_expr.sh
 ===================================================================
 RCS file: /cvsroot/src/tests/bin/expr/t_expr.sh,v
 retrieving revision 1.3
 diff -u -r1.3 t_expr.sh
 --- tests/bin/expr/t_expr.sh	27 Mar 2012 07:23:06 -0000	1.3
 +++ tests/bin/expr/t_expr.sh	20 Jan 2014 20:27:56 -0000
 @@ -25,14 +25,29 @@
  # POSSIBILITY OF SUCH DAMAGE.
  #

 +OS=$(uname -o)
 +export OS
 +
  # The first arg will get eval'd so escape any meta characters
  # The 2nd arg is an expected string/response from expr for that op.
  test_expr() {
 +	local stop_opts
 +
  	echo "Expression '${1}', expecting '${2}'"
 -	res=`eval expr $1 2>&1`
 +
 +	# Terminate option handling on FreeBSD
 +	case "$OS" in
 +	*FreeBSD*)
 +		stop_opts='--'
 +		;;
 +	*)
 +		stop_opts=
 +	esac
 +
 +	res=`eval expr $stop_opts $1 2>&1`
  	if [ "$res" != "$2" ]; then
 -		atf_fail "Expected $2, got $res from expression: " \
 -		         "`eval echo $1`"
 +		atf_fail "Expected '$2', got '$res' from expression: " \
 +		         "`eval echo $stop_opts $1`"
  	fi
  }

 @@ -54,28 +69,40 @@
  	atf_set "descr" "Test overflow cases"
  }
  overflow_body() {
 +	case "$OS" in
 +	*FreeBSD*)
 +		overflow_msg() {
 +			echo "expr: overflow"
 +		}
 +		;;
 +	*NetBSD*)
 +		overflow_msg() {
 +			echo "expr: integer overflow or underflow occurred for operation $*"
 +		}
 +		;;
 +	esac
  	test_expr '4611686018427387904 + 4611686018427387903' \
  	          '9223372036854775807'
  	test_expr '4611686018427387904 + 4611686018427387904' \
 -	          "expr: integer overflow or underflow occurred for operation '4611686018427387904 + 4611686018427387904'"
 +		  "$(overflow_msg '4611686018427387904 + 4611686018427387904')"
  	test_expr '4611686018427387904 - -4611686018427387904' \
 -	          "expr: integer overflow or underflow occurred for operation '4611686018427387904 - -4611686018427387904'"
 +		  "$(overflow_msg '4611686018427387904 - -4611686018427387904')"
  	test_expr '-4611686018427387904 - 4611686018427387903' \
 -	          '-9223372036854775807'
 +		  '-9223372036854775807'
  	test_expr '-4611686018427387904 - 4611686018427387905' \
 -	          "expr: integer overflow or underflow occurred for operation '-4611686018427387904 - 4611686018427387905'"
 +		  "$(overflow_msg '-4611686018427387904 - 4611686018427387905')"
  	test_expr '-4611686018427387904 \* 1' '-4611686018427387904'
  	test_expr '-4611686018427387904 \* -1' '4611686018427387904'
  	test_expr '-4611686018427387904 \* 2' '-9223372036854775808'
  	test_expr '-4611686018427387904 \* 3' \
 -	          "expr: integer overflow or underflow occurred for operation '-4611686018427387904 * 3'"
 +		  "$(overflow_msg '-4611686018427387904 * 3')"
  	test_expr '-4611686018427387904 \* -2' \
 -	          "expr: integer overflow or underflow occurred for operation '-4611686018427387904 * -2'"
 +		  "$(overflow_msg '-4611686018427387904 * -2')"
  	test_expr '4611686018427387904 \* 1' '4611686018427387904'
  	test_expr '4611686018427387904 \* 2' \
 -	          "expr: integer overflow or underflow occurred for operation '4611686018427387904 * 2'"
 +		  "$(overflow_msg '4611686018427387904 * 2')"
  	test_expr '4611686018427387904 \* 3' \
 -	          "expr: integer overflow or underflow occurred for operation '4611686018427387904 * 3'"
 +		  "$(overflow_msg '4611686018427387904 * 3')"
  }

  atf_test_case gtkmm
 @@ -100,16 +127,69 @@
  	test_expr '4 : 4 % 3' '1'
  }

 -atf_test_case arithmetic_ops
 -arithmetic_ops_head() {
 -	atf_set "descr" "Dangling arithemtic operator"
 -}
 -arithmetic_ops_body() {
 +atf_test_case arithmetic_ops01
 +arithmetic_ops01_head() {
 +	atf_set "descr" "Dangling arithmetic operator (01)"
 +}
 +arithmetic_ops01_body() {
 +	if [ "${OS}" = FreeBSD ]; then
 +		atf_expect_fail 'Results in a syntax errors on FreeBSD'
 +	fi
  	test_expr '.java_wrapper : /' '0'
 +}
 +
 +atf_test_case arithmetic_ops02
 +arithmetic_ops02_head() {
 +	atf_set "descr" "Dangling arithmetic operator (02)"
 +}
 +arithmetic_ops02_body() {
 +	if [ "${OS}" = FreeBSD ]; then
 +		atf_expect_fail 'Results in a syntax errors on FreeBSD'
 +	fi
  	test_expr '4 : \*' '0'
 +}
 +
 +atf_test_case arithmetic_ops03
 +arithmetic_ops03_head() {
 +	atf_set "descr" "Dangling arithmetic operator (03)"
 +}
 +arithmetic_ops03_body() {
 +	if [ "${OS}" = FreeBSD ]; then
 +		atf_expect_fail 'Results in a syntax errors on FreeBSD'
 +	fi
  	test_expr '4 : +' '0'
 +}
 +
 +atf_test_case arithmetic_ops04
 +arithmetic_ops04_head() {
 +	atf_set "descr" "Dangling arithmetic operator (04)"
 +}
 +arithmetic_ops04_body() {
 +	if [ "${OS}" = FreeBSD ]; then
 +		atf_expect_fail 'Results in a syntax errors on FreeBSD'
 +	fi
  	test_expr '4 : -' '0'
 +}
 +
 +atf_test_case arithmetic_ops05
 +arithmetic_ops05_head() {
 +	atf_set "descr" "Dangling arithmetic operator (05)"
 +}
 +arithmetic_ops05_body() {
 +	if [ "${OS}" = FreeBSD ]; then
 +		atf_expect_fail 'Results in a syntax errors on FreeBSD'
 +	fi
  	test_expr '4 : /' '0'
 +}
 +
 +atf_test_case arithmetic_ops06
 +arithmetic_ops06_head() {
 +	atf_set "descr" "Dangling arithmetic operator (06)"
 +}
 +arithmetic_ops06_body() {
 +	if [ "${OS}" = FreeBSD ]; then
 +		atf_expect_fail 'Results in a syntax errors on FreeBSD'
 +	fi
  	test_expr '4 : %' '0'
  }

 @@ -215,7 +295,12 @@
  	atf_add_test_case overflow
  	atf_add_test_case gtkmm
  	atf_add_test_case colon_vs_math
 -	atf_add_test_case arithmetic_ops
 +	atf_add_test_case arithmetic_ops01
 +	atf_add_test_case arithmetic_ops02
 +	atf_add_test_case arithmetic_ops03
 +	atf_add_test_case arithmetic_ops04
 +	atf_add_test_case arithmetic_ops05
 +	atf_add_test_case arithmetic_ops06
  	atf_add_test_case basic_math
  	atf_add_test_case basic_functional
  	atf_add_test_case compare_ops_precedence

 --Apple-Mail=_C5ED1E86-0AAA-448D-B923-6EF1FFCE9DDC--

From: Garrett Cooper <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/48537: [PATCH] add FreeBSD support to tests/bin/expr/t_expr.sh
Date: Sun, 4 Jan 2015 15:22:03 -0800

 --Apple-Mail=_AAA758D4-7C8B-4758-8DED-D78D6AF0FA42
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=windows-1252

 On Jan 20, 2014, at 12:50, Garrett Cooper <yaneurabeya@gmail.com> wrote:

 > The following reply was made to PR bin/48537; it has been noted by =
 GNATS.
 >=20
 > From: Garrett Cooper <yaneurabeya@gmail.com>
 > To: gnats-bugs@NetBSD.org
 > Cc:=20
 > Subject: Re: bin/48537: [PATCH] add FreeBSD support to =
 tests/bin/expr/t_expr.sh
 > Date: Mon, 20 Jan 2014 12:47:04 -0800
 >=20
 > --Apple-Mail=3D_C5ED1E86-0AAA-448D-B923-6EF1FFCE9DDC
 > Content-Transfer-Encoding: quoted-printable
 > Content-Type: text/plain;
 > 	charset=3Dwindows-1252
 >=20
 > 	And now the patch=3D85
 > Thanks!
 > -Garrett

 Hi!
 	Please close this PR. I figured out a much simpler way to do =
 this in FreeBSD=92s repo that I=92ll be committing soon to FreeBSD.
 Thanks!

 --Apple-Mail=_AAA758D4-7C8B-4758-8DED-D78D6AF0FA42
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP using GPGMail

 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - https://gpgtools.org

 iQEcBAEBCgAGBQJUqcsbAAoJEMZr5QU6S73eAKYIAI6uUmrAi6Mzbi40WUqLeVoQ
 Hh9AbQhSeV3Tkq0HOQwatt0Tc27IzMm3gfKEbI8rkm4ClWKlaGk29/jWh0l/6gh4
 tWR418t+W2zT+BtmBupjv+gCob2YOIJc/WeWG6TTW7cJs/bhfBeI3PnFs+rInlym
 tdX8dZHX1gns08ZW0E4Jr1lPQ41WT8OguixL16Vwz3cQV9YGu7wnW73nq6Q5UUWi
 X3sYQ+oikWjbNeWHujqKkEsc98OVZduRiVpwSuJYiwKl6cjEgo8zTMud+EcXPDci
 wrWbmRhWCGUG90iQggf8mcQoQUTk49iT9s0vkdKVAYhqzwuqYy3DgJCJPNpH7AA=
 =v7qQ
 -----END PGP SIGNATURE-----

 --Apple-Mail=_AAA758D4-7C8B-4758-8DED-D78D6AF0FA42--

State-Changed-From-To: open->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Thu, 08 Jan 2015 06:33:31 +0000
State-Changed-Why:
Submitter said it's ok to close.
Thanks.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.