<commit_before>#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later

#
# This file is part of libgpiod.
#
# Copyright (C) 2019 <NAME> <<EMAIL>>
#

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<commit_msg>tools: tests: pass command-line arguments to the underlying bats script<commit_after>#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later

#
# This file is part of libgpiod.
#
# Copyright (C) 2019 <NAME> <<EMAIL>>
#

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+"$@"}
{'fraction_non_alphanumeric': 0.13942307692307693, 'fraction_numerical': 0.015297202797202798, 'mean_word_length': 4.226027397260274, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2726752', 'n_tokens_mistral': 943, 'n_tokens_neox': 873, 'n_words': 257}