Add basic shell tests script framework
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 18 Mar 2021 17:49:55 +0000 (13:49 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 22 Mar 2021 20:28:17 +0000 (16:28 -0400)
Import a stripped down shell tests script framework from babeltrace2.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I41ea4b186fe744fd6841d866daa87a802c96b692
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
.gitignore
configure.ac
tests/Makefile.am
tests/unit/ust-elf/Makefile.am
tests/unit/ust-elf/test_ust_elf [new file with mode: 0755]
tests/unit/ust-elf/test_ust_elf.in [deleted file]
tests/utils/Makefile.am
tests/utils/utils.sh [new file with mode: 0755]

index 26cb98ff57548ea9bf31421f56ed14c5720d3093..76aa21b7c4b81a7aa0390a703697f5aa4a542cb7 100644 (file)
@@ -84,7 +84,6 @@ tests/unit/libmsgpack/test_msgpack
 tests/unit/libringbuffer/test_shm
 tests/unit/pthread_name/test_pthread_name
 tests/unit/snprintf/test_snprintf
-tests/unit/ust-elf/test_ust_elf
 tests/unit/ust-elf/ust-elf
 
 # Java agent library
index 414daf6bfe621bd8179e805a1f5452b91b7454ff..bc119c38c4c44e5619b7eada4a734284b54c06bb 100644 (file)
@@ -554,8 +554,6 @@ AC_CONFIG_FILES([
        lttng-ust-ctl.pc
 ])
 
-AC_CONFIG_FILES([tests/unit/ust-elf/test_ust_elf],[chmod +x tests/unit/ust-elf/test_ust_elf])
-
 AC_OUTPUT
 
 
index 6ecd565fb867ca06472c016d70e1b120444f6262..7be533317b5568c043a9a880f0df0a8b271b337c 100644 (file)
@@ -2,9 +2,11 @@
 
 SUBDIRS = utils unit compile benchmark
 
-LOG_DRIVER_FLAGS='--merge'
-LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
-       $(srcdir)/utils/tap-driver.sh
+LOG_DRIVER_FLAGS = --merge --comments
+LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \
+       UST_TESTS_SRCDIR='$(abs_top_srcdir)/tests' \
+       UST_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \
+       $(SHELL) $(srcdir)/utils/tap-driver.sh
 
 TESTS = \
        unit/libringbuffer/test_shm \
index ff7fb7dfa37803f9e50ab318cbf0e6bacc052a80..339feaf1befc42323db1d3cd032cee6952e28723 100644 (file)
@@ -7,6 +7,8 @@ ust_elf_SOURCES = ust-elf.c
 ust_elf_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la \
        $(top_builddir)/tests/utils/libtap.a
 
+dist_check_SCRIPTS = test_ust_elf
+
 # Directories added to EXTRA_DIST will be recursively copied to the distribution.
 EXTRA_DIST = \
        $(srcdir)/data \
diff --git a/tests/unit/ust-elf/test_ust_elf b/tests/unit/ust-elf/test_ust_elf
new file mode 100755 (executable)
index 0000000..afc6eca
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+# SPDX-License-Identifier: LGPL-2.1-only
+
+if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then
+       UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh"
+else
+       UTILSSH="$(dirname "$0")/../../utils/utils.sh"
+fi
+
+# shellcheck source=../utils/utils.sh
+source "$UTILSSH"
+
+"${UST_TESTS_BUILDDIR}/unit/ust-elf/ust-elf" "${UST_TESTS_SRCDIR}/unit/ust-elf"
diff --git a/tests/unit/ust-elf/test_ust_elf.in b/tests/unit/ust-elf/test_ust_elf.in
deleted file mode 100644 (file)
index 99f345d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: LGPL-2.1-only
-
-TEST_DIR=$(dirname "$0")
-"${TEST_DIR}/ust-elf" "@abs_top_srcdir@/tests/unit/ust-elf"
index 402ba8627732c75f59d7863fe9b3c12281479726..bfe52070cac1664d9bffc34058934c28ec55d7a7 100644 (file)
@@ -4,4 +4,5 @@ noinst_LIBRARIES = libtap.a
 libtap_a_SOURCES = tap.c tap.h
 dist_check_SCRIPTS = \
        tap-driver.sh \
-       tap.sh
+       tap.sh \
+       utils.sh
diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
new file mode 100755 (executable)
index 0000000..cefb782
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (c) 2019 Michael Jeanson <mjeanson@efficios.com>
+# Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
+#
+
+# This file is meant to be sourced at the start of shell script-based tests.
+
+
+# Error out when encountering an undefined variable
+set -u
+
+# If "readlink -f" is available, get a resolved absolute path to the
+# tests source dir, otherwise make do with a relative path.
+scriptdir="$(dirname "${BASH_SOURCE[0]}")"
+if readlink -f "." >/dev/null 2>&1; then
+       testsdir=$(readlink -f "$scriptdir/..")
+else
+       testsdir="$scriptdir/.."
+fi
+
+# Allow overriding the source and build directories
+if [ "x${UST_TESTS_SRCDIR:-}" = "x" ]; then
+       UST_TESTS_SRCDIR="$testsdir"
+fi
+export UST_TESTS_SRCDIR
+
+if [ "x${UST_TESTS_BUILDDIR:-}" = "x" ]; then
+       UST_TESTS_BUILDDIR="$testsdir"
+fi
+export UST_TESTS_BUILDDIR
This page took 0.027797 seconds and 4 git commands to generate.