From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 2EA3D6DE1D53 for ; Thu, 9 Mar 2017 06:02:58 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tdq5__60xHoq for ; Thu, 9 Mar 2017 06:02:56 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 3F4FB6DE1C09 for ; Thu, 9 Mar 2017 06:02:56 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1clydy-0001sA-9W; Thu, 09 Mar 2017 09:02:14 -0500 Received: (nullmailer pid 18633 invoked by uid 1000); Thu, 09 Mar 2017 14:02:53 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: Mikhail Subject: [PATCH] tests: add compatibility layer Date: Thu, 9 Mar 2017 09:32:43 -0400 Message-Id: <20170309133243.1849-1-david@tethera.net> X-Mailer: git-send-email 2.11.0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Mar 2017 14:02:58 -0000 From: Mikhail 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. - amended by db following Tomi's suggestions --- I haven't tested this, except to verify it doesn't crash under GNU/Linux configure | 3 +++ test/README | 11 +++++++++++ test/test-lib-FREEBSD.sh | 9 +++++++++ test/test-lib-common.sh | 5 +++++ 4 files changed, 28 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..ae22d6e0 100644 --- a/test/README +++ b/test/README @@ -33,6 +33,17 @@ chosen directory to your PATH before running the tests. e.g. env PATH=/opt/gnu/bin:$PATH make test +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 00000000..d1840b56 --- /dev/null +++ b/test/test-lib-FREEBSD.sh @@ -0,0 +1,9 @@ +# If present, use GNU Coreutils instead of a native BSD utils +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 a96cfbeb..ef409171 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 || exit 1 +fi + if test -n "$valgrind" then make_symlink () { -- 2.11.0