diff --git a/.github/workflows/pmem_check.yml b/.github/workflows/pmem_check.yml index 67627dc0c3f..dd32096f171 100644 --- a/.github/workflows/pmem_check.yml +++ b/.github/workflows/pmem_check.yml @@ -32,7 +32,7 @@ jobs: run: ./$WORKDIR/build-pmdk.sh - name: Create testconfig files - run: ./$WORKDIR/create-testconfig.sh + run: ./$WORKDIR/../create-testconfig.sh - name: Run tests (Bash) run: cd src/test/ && ./RUNTESTS.sh -b ${{ matrix.build }} diff --git a/.github/workflows/pmem_long.yml b/.github/workflows/pmem_long.yml index 6324501d182..c34fa3d2a72 100644 --- a/.github/workflows/pmem_long.yml +++ b/.github/workflows/pmem_long.yml @@ -35,7 +35,7 @@ jobs: run: ./$WORKDIR/build-pmdk.sh - name: Create testconfig file - run: ./$WORKDIR/create-testconfig.sh + run: ./$WORKDIR/../create-testconfig.sh - name: Run tests run: cd src/test/ && ./RUNTESTS.${{ matrix.script }} -t long -b ${{ matrix.build }} diff --git a/.github/workflows/pmem_valgrind.yml b/.github/workflows/pmem_valgrind.yml index 87ddb6d6183..9565022ff52 100644 --- a/.github/workflows/pmem_valgrind.yml +++ b/.github/workflows/pmem_valgrind.yml @@ -36,7 +36,7 @@ jobs: run: ./$WORKDIR/build-pmdk.sh - name: Create testconfig file - run: ./$WORKDIR/create-testconfig.sh + run: ./$WORKDIR/../create-testconfig.sh - name: Run tests run: cd src/test/ && ./RUNTESTS.${{ matrix.script }} --force-enable ${{ matrix.config }} -b ${{ matrix.build }} diff --git a/utils/create-testconfig.sh b/utils/create-testconfig.sh new file mode 100755 index 00000000000..ec91e5ed61b --- /dev/null +++ b/utils/create-testconfig.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2016-2023, Intel Corporation + +# +# create-testconfig.sh - creates testconfig files for test execution +# +# Note: It dedicates all Device DAX devices found in the system for testing +# purposes. +# + +# This script makes use of the following variables as they are available in +# the environment: +# - OUTPUT_DIR - the directory where the output testconfig.[sh|py] files are +# about to be written to +# - NON_PMEM_FS_DIR - a directory of a non-PMem-aware file system +# - PMEM_FS_DIR - a directory of a PMem-aware file system +# - PMEM_FS_DIR_FORCE_PMEM - set to 1, if MAP_SYNC in the PMEM_FS_DIR filesystem +# will cause an error. Set to 0 otherwise. +# - force_cacheline - set to True to act in accordance with cache line +# granularity. Set to False otherwise. +# - force_byte - set to True to act in accordance with byte granularity. Set to +# False otherwise. +# - UNITTEST_LOG_LEVEL - Set the logging level. Possible values are: +# 0 - silent (only error messages), +# 1 - normal (error messages + SETUP + START + DONE + PASS + important +# SKIP messages), +# 2 - verbose (all normal messages + all SKIP messages + stdout from test +# binaries). +# - TEST_TIMEOUT - Set timeout. A floating point number with an optional suffix: +# 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. + +# loading defaults if necessary +OUTPUT_DIR=${OUTPUT_DIR:-src/test} +NON_PMEM_FS_DIR=${NON_PMEM_FS_DIR:-/dev/shm} +PMEM_FS_DIR=${PMEM_FS_DIR:-/mnt/pmem0} +PMEM_FS_DIR_FORCE_PMEM=${PMEM_FS_DIR_FORCE_PMEM:-0} +force_cacheline=${force_cacheline:-False} +force_byte=${force_byte:-True} +UNITTEST_LOG_LEVEL=${UNITTEST_LOG_LEVEL:-1} +TEST_TIMEOUT=${TEST_TIMEOUT:-120m} + +# converts y/n value to True/False value +function ynToTrueFalse() { + [ "$1" = "y" ] && echo "True" || echo "False" +} + +# static values for both Bash and Python +KEEP_GOING=y +keep_going=$(ynToTrueFalse $KEEP_GOING) +TEST_TYPE=check +TEST_BUILD="debug nondebug" +build="['debug', 'nondebug']" +ENABLE_SUDO_TESTS=y +enable_admin_tests=$(ynToTrueFalse $ENABLE_SUDO_TESTS) +TM=1 +[ "$TM" = "1" ] && tm=True || tm=False + +# lookup all Device DAX devices in the system +DEVICE_DAX_PATH= +device_dax_path= +if [ `which ndctl` -a `which jq` ]; then + DEVICE_DAX_PATH="$(ndctl list -X | jq -r '.[].daxregion.devices[].chardev' | awk '$0="/dev/"$0' | paste -sd' ')" + device_dax_path="$(ndctl list -X | jq -r '.[].daxregion.devices[].chardev' | awk '$0="'\''/dev/"$0"'\''"' | paste -sd',')" +fi + +# generate Bash's test configuration file +cat << EOF > $OUTPUT_DIR/testconfig.sh +NON_PMEM_FS_DIR=$NON_PMEM_FS_DIR +PMEM_FS_DIR=$PMEM_FS_DIR +PMEM_FS_DIR_FORCE_PMEM=$PMEM_FS_DIR_FORCE_PMEM +DEVICE_DAX_PATH=($DEVICE_DAX_PATH) +UNITTEST_LOG_LEVEL=$UNITTEST_LOG_LEVEL +KEEP_GOING=$KEEP_GOING +TEST_TYPE=$TEST_TYPE +TEST_BUILD="$TEST_BUILD" +TEST_TIMEOUT=$TEST_TIMEOUT +ENABLE_SUDO_TESTS=$ENABLE_SUDO_TESTS +TM=$TM +EOF + +# generate Python's test configuration file +cat << EOF > $OUTPUT_DIR/testconfig.py +config = { + 'page_fs_dir': '${NON_PMEM_FS_DIR}', + 'force_page': False, + 'cacheline_fs_dir': '${PMEM_FS_DIR}', + 'force_cacheline': $force_cacheline, + 'byte_fs_dir': '${PMEM_FS_DIR}', + 'force_byte': $force_byte, + 'device_dax_path' : [$device_dax_path], + 'unittest_log_level': $UNITTEST_LOG_LEVEL, + 'keep_going': $keep_going, + 'test_type': '$TEST_TYPE', + 'build': $build, + 'granularity': 'all', + 'timeout': '$TEST_TIMEOUT', + 'enable_admin_tests': $enable_admin_tests, + 'tm': $tm, +} +EOF diff --git a/utils/docker/configure-tests.sh b/utils/docker/configure-tests.sh deleted file mode 100755 index bc061e0e53c..00000000000 --- a/utils/docker/configure-tests.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2023, Intel Corporation - -# -# configure-tests.sh - is called inside a Docker container; configures tests -# for use during build of PMDK project. -# - -set -e - -# Configure tests -cat << EOF > $WORKDIR/src/test/testconfig.sh -LONGDIR=LoremipsumdolorsitametconsecteturadipiscingelitVivamuslacinianibhattortordictumsollicitudinNullamvariusvestibulumligulaetegestaselitsemperidMaurisultriciesligulaeuipsumtinciduntluctusMorbimaximusvariusdolorid -# this path is ~3000 characters long -DIRSUFFIX="$LONGDIR/$LONGDIR/$LONGDIR/$LONGDIR/$LONGDIR" -NON_PMEM_FS_DIR=/tmp -PMEM_FS_DIR=/tmp -PMEM_FS_DIR_FORCE_PMEM=1 -TEST_BUILD="debug nondebug" -ENABLE_SUDO_TESTS=y -TM=1 -EOF - -# Configure python tests -cat << EOF > $WORKDIR/src/test/testconfig.py -config = { - 'unittest_log_level': 1, - 'cacheline_fs_dir': '/tmp', - 'force_cacheline': True, - 'page_fs_dir': '/tmp', - 'force_page': False, - 'byte_fs_dir': '/tmp', - 'force_byte': True, - 'tm': True, - 'test_type': 'check', - 'granularity': 'all', - 'fs_dir_force_pmem': 0, - 'keep_going': False, - 'timeout': '3m', - 'build': ['debug', 'nondebug'], - 'force_enable': None, - 'device_dax_path': [], - 'fail_on_skip': False, - 'enable_admin_tests': True - } -EOF diff --git a/utils/docker/prepare-for-build.sh b/utils/docker/prepare-for-build.sh index 94ecf95ed33..fceab993232 100755 --- a/utils/docker/prepare-for-build.sh +++ b/utils/docker/prepare-for-build.sh @@ -21,5 +21,12 @@ fi # should be preserved KEEP_TEST_CONFIG=${KEEP_TEST_CONFIG:-0} if [[ "$KEEP_TEST_CONFIG" == 0 ]]; then - ./configure-tests.sh + OUTPUT_DIR=$WORKDIR/src/test \ + NON_PMEM_FS_DIR=/tmp \ + PMEM_FS_DIR=/tmp \ + PMEM_FS_DIR_FORCE_PMEM=1 \ + force_cacheline=True \ + force_byte=True \ + TEST_TIMEOUT=3m \ + ../create-testconfig.sh fi diff --git a/utils/docker/run-build-package.sh b/utils/docker/run-build-package.sh index 5a52aa41f18..d477f0ec3af 100755 --- a/utils/docker/run-build-package.sh +++ b/utils/docker/run-build-package.sh @@ -63,11 +63,8 @@ pushd $WORKDIR/src/test make -j$(nproc) clobber make -j$(nproc) -# Prepare test config once more. Now, with path to PMDK set in the OS -# (rather than in the git tree) - for testing packages installed in the system. -$SCRIPTSDIR/configure-tests.sh - -# Append variables exclusively for PKG tests +# Append variables with path to PMDK set in the OS (rather than in the git tree) +# - for testing packages installed in the system. case "$OS" in "opensuse/leap" | "rockylinux/rockylinux") PMDK_LIB_PATH_NONDEBUG=/usr/lib64 diff --git a/utils/gha-runners/create-testconfig.sh b/utils/gha-runners/create-testconfig.sh deleted file mode 100755 index ed72a96951c..00000000000 --- a/utils/gha-runners/create-testconfig.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2022-2023, Intel Corporation - -# -# create-testconfig.sh - Script for creating testconfig files for test execution. -# - -# Default location for testconfig.sh -CONF_PATH="src/test" -MOUNT_POINT=${PMDK_MOUNT_POINT:-"/mnt/pmem0"} -NON_PMEM_DIR="/dev/shm" - -# Create config file for unittests. -# We are using ndctl command to gather information about devdaxes, in form known from namespace configuration. -cat >${CONF_PATH}/testconfig.sh <${CONF_PATH}/testconfig.py <