NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/48537: [PATCH] add FreeBSD support to tests/bin/expr/t_expr.sh
The following reply was made to PR bin/48537; it has been noted by GNATS.
From: Garrett Cooper <yaneurabeya%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
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--
Home |
Main Index |
Thread Index |
Old Index