Re: [PATCH] test: allow user to choose which gdb to run tests with

2017-02-05 Thread Tomi Ollila
On Wed, Jan 11 2017, Mikhail  wrote:

> On 17:56 08-Jan 2017 David Bremner wrote:
>> Tomi Ollila  writes:
>> 
>> > The variable used for selecting gdb is TEST_GDB, consistent with
>> > TEST_CC and TEST_EMACS{,CLIENT}.
>> 
>> pushed this patch to master.
>> 
>
> Hello, updated FreeBSD tests patch in the attachment.

Suggested changes inline.


> From 6fb51f79192f0d1ad443aff276b7c2b9295d9c55 Mon Sep 17 00:00:00 2001
> From: Mikhail 
> Date: Thu, 22 Dec 2016 12:19:39 +0300
> Subject: [PATCH] tests: add compatibility layer
>
> Make test-lib-common.sh load test-lib-<$PLATFORM>.sh to create
> additional shim for platform specifics.
>
> Use test-lib-FREEBSD.sh to call GNU utilities instead of native ones.
> ---
>  configure| 3 +++
>  test/README  | 6 ++
>  test/test-lib-FREEBSD.sh | 7 +++
>  test/test-lib-common.sh  | 5 +
>  4 files changed, 21 insertions(+)
>  create mode 100644 test/test-lib-FREEBSD.sh
>
> diff --git a/configure b/configure
> index fa77eb8f..eb452a12 100755
> --- a/configure
> +++ b/configure
> @@ -1186,6 +1186,9 @@ NOTMUCH_PYTHON=${python}
>  # Are the ruby development files (and ruby) available? If not skip
>  # building/testing ruby bindings.
>  NOTMUCH_HAVE_RUBY_DEV=${have_ruby_dev}
> +
> +# Platform we are run on
> +PLATFORM=${platform}
>  EOF
>  
>  # Finally, after everything configured, inform the user how to continue.
> diff --git a/test/README b/test/README
> index 104a120e..354a32f9 100644
> --- a/test/README
> +++ b/test/README
> @@ -33,6 +33,12 @@ chosen directory to your PATH before running the tests.
>  
>  e.g. env PATH=/opt/gnu/bin:$PATH make test
>  
> +For FreeBSD you will need to install coreutils, which provides GNU
> +versions of basic utils like 'date' or 'wc'. Also you will need to
> +install latest gdb from ports or packages and provide path to it in
> +TEST_GDB variable before executing the tests, native FreeBSD gdb will
> +not work.
> +

For FreeBSD you need to install latest gdb from ports or packages and
provide path to it in TEST_GDB environment variable before executing the
tests, native FreeBSD gdb does not not work.
If you install coreutils, which provides GNU versions of basic utils like
'date' and 'base64' on FreeBSD, the test suite will use these instead of
the native ones. This provides robustness against portability issues with
these system tools. Most often the tests are written, reviewed and tested
on Linux system so such portability issues arise from time to time.

>  Running Tests
>  -
>  The easiest way to run tests is to say "make test", (or simply run the
> diff --git a/test/test-lib-FREEBSD.sh b/test/test-lib-FREEBSD.sh
> new file mode 100644
> index ..09242362
> --- /dev/null
> +++ b/test/test-lib-FREEBSD.sh
> @@ -0,0 +1,7 @@
> +# Use GNU Coreutils instead of a native BSD utils
> +
> +date () { gdate "$@"; }
> +base64 () { gbase64 "$@"; }
> +wc () { gwc "$@"; }
> +sed () { gsed "$@"; }
> +sha256sum () { gsha256sum "$@"; }

if command -v gdate >/dev/null
then
date () { gdate "$@"; }
base64 () { gbase64 "$@"; }
wc () { gwc "$@"; }
sed () { gsed "$@"; }
sha256sum () { gsha256sum "$@"; }
fi

> diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
> index 03ef1d2d..1c8d7f6e 100644
> --- a/test/test-lib-common.sh
> +++ b/test/test-lib-common.sh
> @@ -66,6 +66,11 @@ export LD_LIBRARY_PATH
>  # configure output
>  . $notmuch_path/sh.config || exit 1
>  
> +# load OS specifics
> +if [ -e ./test-lib-$PLATFORM.sh ]; then
> + . ./test-lib-$PLATFORM.sh

. ./test-lib-$PLATFORM.sh || exit 1

> +fi
> +
>  if test -n "$valgrind"
>  then
>   make_symlink () {
> -- 
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test: allow user to choose which gdb to run tests with

2017-01-11 Thread Mikhail
On 17:56 08-Jan 2017 David Bremner wrote:
> Tomi Ollila  writes:
> 
> > The variable used for selecting gdb is TEST_GDB, consistent with
> > TEST_CC and TEST_EMACS{,CLIENT}.
> 
> pushed this patch to master.
> 

Hello, updated FreeBSD tests patch in the attachment.
>From 6fb51f79192f0d1ad443aff276b7c2b9295d9c55 Mon Sep 17 00:00:00 2001
From: Mikhail 
Date: Thu, 22 Dec 2016 12:19:39 +0300
Subject: [PATCH] tests: add compatibility layer

Make test-lib-common.sh load test-lib-<$PLATFORM>.sh to create
additional shim for platform specifics.

Use test-lib-FREEBSD.sh to call GNU utilities instead of native ones.
---
 configure| 3 +++
 test/README  | 6 ++
 test/test-lib-FREEBSD.sh | 7 +++
 test/test-lib-common.sh  | 5 +
 4 files changed, 21 insertions(+)
 create mode 100644 test/test-lib-FREEBSD.sh

diff --git a/configure b/configure
index fa77eb8f..eb452a12 100755
--- a/configure
+++ b/configure
@@ -1186,6 +1186,9 @@ NOTMUCH_PYTHON=${python}
 # Are the ruby development files (and ruby) available? If not skip
 # building/testing ruby bindings.
 NOTMUCH_HAVE_RUBY_DEV=${have_ruby_dev}
+
+# Platform we are run on
+PLATFORM=${platform}
 EOF
 
 # Finally, after everything configured, inform the user how to continue.
diff --git a/test/README b/test/README
index 104a120e..354a32f9 100644
--- a/test/README
+++ b/test/README
@@ -33,6 +33,12 @@ chosen directory to your PATH before running the tests.
 
 e.g. env PATH=/opt/gnu/bin:$PATH make test
 
+For FreeBSD you will need to install coreutils, which provides GNU
+versions of basic utils like 'date' or 'wc'. Also you will need to
+install latest gdb from ports or packages and provide path to it in
+TEST_GDB variable before executing the tests, native FreeBSD gdb will
+not work.
+
 Running Tests
 -
 The easiest way to run tests is to say "make test", (or simply run the
diff --git a/test/test-lib-FREEBSD.sh b/test/test-lib-FREEBSD.sh
new file mode 100644
index ..09242362
--- /dev/null
+++ b/test/test-lib-FREEBSD.sh
@@ -0,0 +1,7 @@
+# Use GNU Coreutils instead of a native BSD utils
+
+date () { gdate "$@"; }
+base64 () { gbase64 "$@"; }
+wc () { gwc "$@"; }
+sed () { gsed "$@"; }
+sha256sum () { gsha256sum "$@"; }
diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
index 03ef1d2d..1c8d7f6e 100644
--- a/test/test-lib-common.sh
+++ b/test/test-lib-common.sh
@@ -66,6 +66,11 @@ export LD_LIBRARY_PATH
 # configure output
 . $notmuch_path/sh.config || exit 1
 
+# load OS specifics
+if [ -e ./test-lib-$PLATFORM.sh ]; then
+   . ./test-lib-$PLATFORM.sh
+fi
+
 if test -n "$valgrind"
 then
make_symlink () {
-- 
2.11.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: allow user to choose which gdb to run tests with

2017-01-07 Thread Tomi Ollila
The variable used for selecting gdb is TEST_GDB, consistent with
TEST_CC and TEST_EMACS{,CLIENT}.
---

I tested this on FreeBSD kvm virtual machine, changed

env PATH=/usr/local/bin:$PATH CPATH=/usr/local/include 
LIBRARY_PATH=/usr/local/lib script typescript gmake test

to

env TEST_GDB=/usr/local/bin/gdb CPATH=/usr/local/include 
LIBRARY_PATH=/usr/local/lib script typescript gmake test

and got same results.

 test/T050-new.sh   | 2 +-
 test/T060-count.sh | 2 +-
 test/T070-insert.sh| 8 
 test/T380-atomicity.sh | 2 +-
 test/test-lib.sh   | 3 ++-
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index 2bc799d..9115de8 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -317,7 +317,7 @@ end
 run
 EOF
 
-gdb --batch-silent --return-child-result -x notmuch-new-vanish.gdb \
+${TEST_GDB} --batch-silent --return-child-result -x notmuch-new-vanish.gdb \
 --args notmuch new 2>OUTPUT 1>/dev/null
 echo "exit status: $?" >> OUTPUT
 
diff --git a/test/T060-count.sh b/test/T060-count.sh
index 69ab591..d27e1ba 100755
--- a/test/T060-count.sh
+++ b/test/T060-count.sh
@@ -115,7 +115,7 @@ EOF
 
 backup_database
 test_begin_subtest "error message from query_search_messages"
-gdb --batch-silent --return-child-result -x count-files.gdb \
+${TEST_GDB} --batch-silent --return-child-result -x count-files.gdb \
 --args notmuch count --output=files '*' 2>OUTPUT 1>/dev/null
 cat < EXPECTED
 notmuch count: A Xapian exception occurred
diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index 57472b9..7e04a23 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -206,22 +206,22 @@ gen_insert_msg
 
 for code in  FILE_NOT_EMAIL READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
 test_expect_code 1 "EXIT_FAILURE when add_message returns $code" \
- "gdb --batch-silent --return-child-result \
+ "${TEST_GDB} --batch-silent --return-child-result \
 -ex 'set args insert < $gen_msg_filename' \
 -x index-file-$code.gdb notmuch"
 test_expect_code 0 "success exit with --keep when add_message returns 
$code" \
- "gdb --batch-silent --return-child-result \
+ "${TEST_GDB} --batch-silent --return-child-result \
 -ex 'set args insert --keep < $gen_msg_filename' \
 -x index-file-$code.gdb notmuch"
 done
 
 for code in OUT_OF_MEMORY XAPIAN_EXCEPTION ; do
 test_expect_code 75 "EX_TEMPFAIL when add_message returns $code" \
- "gdb --batch-silent --return-child-result \
+ "${TEST_GDB} --batch-silent --return-child-result \
 -ex 'set args insert < $gen_msg_filename' \
 -x index-file-$code.gdb notmuch"
 test_expect_code 0 "success exit with --keep when add_message returns 
$code" \
- "gdb --batch-silent --return-child-result \
+ "${TEST_GDB} --batch-silent --return-child-result \
 -ex 'set args insert --keep < $gen_msg_filename' \
 -x index-file-$code.gdb notmuch"
 done
diff --git a/test/T380-atomicity.sh b/test/T380-atomicity.sh
index 845dfde..c6a9fb9 100755
--- a/test/T380-atomicity.sh
+++ b/test/T380-atomicity.sh
@@ -64,7 +64,7 @@ if test_require_external_prereq gdb; then
 # -tty /dev/null works around a conflict between the 'timeout' wrapper
 # and gdb's attempt to control the TTY.
 export MAIL_DIR
-gdb -tty /dev/null -batch -x $TEST_DIRECTORY/atomicity.py notmuch 
1>gdb.out 2>&1
+${TEST_GDB} -tty /dev/null -batch -x $TEST_DIRECTORY/atomicity.py notmuch 
1>gdb.out 2>&1
 
 # Get the final, golden output
 notmuch search '*' > expected
diff --git a/test/test-lib.sh b/test/test-lib.sh
index f55d2c6..6f9468a 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -80,6 +80,7 @@ if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \
 fi
 TEST_EMACS=${TEST_EMACS:-${EMACS:-emacs}}
 TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient}
+TEST_GDB=${TEST_GDB:-gdb}
 TEST_CC=${TEST_CC:-cc}
 TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}
 
@@ -1379,7 +1380,7 @@ esac
 test_declare_external_prereq dtach
 test_declare_external_prereq emacs
 test_declare_external_prereq ${TEST_EMACSCLIENT}
-test_declare_external_prereq gdb
+test_declare_external_prereq ${TEST_GDB}
 test_declare_external_prereq gpg
 test_declare_external_prereq openssl
 test_declare_external_prereq gpgsm
-- 
2.9.3

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch