Skip to content

Commit

Permalink
common: unify testconfig generation scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Michalski <jan.michalski@intel.com>
  • Loading branch information
janekmi committed Jul 17, 2023
1 parent a21dac3 commit 463c8ea
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 109 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/pmem_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ jobs:
run: ./$WORKDIR/build-pmdk.sh

- name: Create testconfig files
run: ./$WORKDIR/create-testconfig.sh
env:
OUTPUT_DIR: src/test
PMEM_FS_DIR: /mnt/pmem0
PMEM_FS_DIR_FORCE_PMEM: 0
force_cacheline: 'True'
force_byte: 'False'
run: ./$WORKDIR/../create-testconfig.sh

- name: Run tests (Bash)
run: cd src/test/ && ./RUNTESTS.sh -b ${{ matrix.build }}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pmem_long.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ jobs:
run: ./$WORKDIR/build-pmdk.sh

- name: Create testconfig file
run: ./$WORKDIR/create-testconfig.sh
env:
OUTPUT_DIR: src/test
PMEM_FS_DIR: /mnt/pmem0
PMEM_FS_DIR_FORCE_PMEM: 0
force_cacheline: 'True'
force_byte: 'False'
run: ./$WORKDIR/../create-testconfig.sh

- name: Run tests
run: cd src/test/ && ./RUNTESTS.${{ matrix.script }} -t long -b ${{ matrix.build }}
8 changes: 7 additions & 1 deletion .github/workflows/pmem_valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ jobs:
run: ./$WORKDIR/build-pmdk.sh

- name: Create testconfig file
run: ./$WORKDIR/create-testconfig.sh
env:
OUTPUT_DIR: src/test
PMEM_FS_DIR: /mnt/pmem0
PMEM_FS_DIR_FORCE_PMEM: 0
force_cacheline: 'True'
force_byte: 'False'
run: ./$WORKDIR/../create-testconfig.sh

- name: Run tests
run: cd src/test/ && ./RUNTESTS.${{ matrix.script }} --force-enable ${{ matrix.config }} -b ${{ matrix.build }}
104 changes: 104 additions & 0 deletions utils/create-testconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/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
# - 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.

# input validation
if [ -z "$OUTPUT_DIR" ]; then
echo "OUTPUT_DIR is empty";
exit 1;
fi

if [ -z "$PMEM_FS_DIR" ]; then
echo "PMEM_FS_DIR is empty";
exit 1;
fi

if [ -z "$PMEM_FS_DIR_FORCE_PMEM" ]; then
echo "PMEM_FS_DIR_FORCE_PMEM is empty";
exit 1;
fi

if [ -z "$force_cacheline" ]; then
echo "force_cacheline is empty";
exit 1;
fi

if [ -z "$force_byte" ]; then
echo "force_byte is empty";
exit 1;
fi

# converts y/n value to True/False value
function ynToTrueFalse() {
[ "$1" = "y" ] && echo "True" || echo "False"
}

# static values for both Bash and Python
NON_PMEM_FS_DIR=/dev/shm
KEEP_GOING=y
keep_going=$(ynToTrueFalse $KEEP_GOING)
TEST_BUILD="debug nondebug"
build="['debug', 'nondebug']"
TEST_TIMEOUT=120m
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` ]; 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 << EOL > $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)
KEEP_GOING=$KEEP_GOING
TEST_BUILD="$TEST_BUILD"
TEST_TIMEOUT=$TEST_TIMEOUT
ENABLE_SUDO_TESTS=$ENABLE_SUDO_TESTS
TM=$TM
EOL

# generate Python's test configuration file
cat << EOL > $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],
'keep_going': $keep_going,
'build': $build,
'timeout': '$TEST_TIMEOUT',
'enable_admin_tests': $enable_admin_tests,
'tm': $tm,
}
EOL
47 changes: 0 additions & 47 deletions utils/docker/configure-tests.sh

This file was deleted.

7 changes: 6 additions & 1 deletion utils/docker/prepare-for-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ 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 \
PMEM_FS_DIR=/dev/shm \
PMEM_FS_DIR_FORCE_PMEM=1 \
force_cacheline=True \
force_byte=True \
../create-testconfig.sh
fi
7 changes: 2 additions & 5 deletions utils/docker/run-build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 0 additions & 53 deletions utils/gha-runners/create-testconfig.sh

This file was deleted.

0 comments on commit 463c8ea

Please sign in to comment.