From: Bartosz Golaszewski Date: Tue, 6 Aug 2019 16:06:26 +0000 (+0200) Subject: tools: tests: drop the .sh extension from the testing script's name X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1cb08c0b23d2b220ceaa104683568d07eade4140;p=qemu-gpiodev%2Flibgpiod.git tools: tests: drop the .sh extension from the testing script's name This script requires bash, so .sh extension is not accurate. Also: it's executable, so there's no need to indicate the interpreter in the extension. Signed-off-by: Bartosz Golaszewski --- diff --git a/tools/Makefile.am b/tools/Makefile.am index da25283..897ff32 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -28,10 +28,10 @@ gpiomon_SOURCES = gpiomon.c gpiofind_SOURCES = gpiofind.c -EXTRA_DIST = gpio-tools-test.bats gpio-tools-test.sh +EXTRA_DIST = gpio-tools-test gpio-tools-test.bats if WITH_TESTS -bin_SCRIPTS = gpio-tools-test.sh gpio-tools-test.bats +bin_SCRIPTS = gpio-tools-test gpio-tools-test.bats endif diff --git a/tools/gpio-tools-test b/tools/gpio-tools-test new file mode 100755 index 0000000..f12f9ec --- /dev/null +++ b/tools/gpio-tools-test @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later + +# +# This file is part of libgpiod. +# +# Copyright (C) 2019 Bartosz Golaszewski +# + +MIN_KERNEL_VERSION="5.1.0" +BATS_SCRIPT="gpio-tools-test.bats" +SOURCE_DIR="$(dirname ${BASH_SOURCE[0]})" + +die() { + echo "$@" 1>&2 + exit 1 +} + +check_kernel() { + local REQUIRED=$1 + local CURRENT=$(uname -r) + + SORTED=$(printf "$REQUIRED\n$CURRENT" | sort -V | head -n 1) + + if [ "$SORTED" != "$REQUIRED" ] + then + die "linux kernel version must be at least: v$REQUIRED - got: v$CURRENT" + fi +} + +check_prog() { + local PROG=$1 + + which "$PROG" > /dev/null + if [ "$?" -ne "0" ] + then + die "$PROG not found - needed to run the tests" + fi +} + +# Check all required non-coreutils tools +check_prog bats +check_prog modprobe +check_prog rmmod +check_prog udevadm + +# Check if we're running a kernel at the required version or later +check_kernel $MIN_KERNEL_VERSION + +# The bats script must be in the same directory. +if [ ! -e "$SOURCE_DIR/$BATS_SCRIPT" ] +then + die "testing script not found" +fi + +BATS_PATH=$(which bats) + +exec $BATS_PATH $SOURCE_DIR/$BATS_SCRIPT ${1+"$@"} diff --git a/tools/gpio-tools-test.sh b/tools/gpio-tools-test.sh deleted file mode 100755 index f12f9ec..0000000 --- a/tools/gpio-tools-test.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: LGPL-2.1-or-later - -# -# This file is part of libgpiod. -# -# Copyright (C) 2019 Bartosz Golaszewski -# - -MIN_KERNEL_VERSION="5.1.0" -BATS_SCRIPT="gpio-tools-test.bats" -SOURCE_DIR="$(dirname ${BASH_SOURCE[0]})" - -die() { - echo "$@" 1>&2 - exit 1 -} - -check_kernel() { - local REQUIRED=$1 - local CURRENT=$(uname -r) - - SORTED=$(printf "$REQUIRED\n$CURRENT" | sort -V | head -n 1) - - if [ "$SORTED" != "$REQUIRED" ] - then - die "linux kernel version must be at least: v$REQUIRED - got: v$CURRENT" - fi -} - -check_prog() { - local PROG=$1 - - which "$PROG" > /dev/null - if [ "$?" -ne "0" ] - then - die "$PROG not found - needed to run the tests" - fi -} - -# Check all required non-coreutils tools -check_prog bats -check_prog modprobe -check_prog rmmod -check_prog udevadm - -# Check if we're running a kernel at the required version or later -check_kernel $MIN_KERNEL_VERSION - -# The bats script must be in the same directory. -if [ ! -e "$SOURCE_DIR/$BATS_SCRIPT" ] -then - die "testing script not found" -fi - -BATS_PATH=$(which bats) - -exec $BATS_PATH $SOURCE_DIR/$BATS_SCRIPT ${1+"$@"}