Skip to content

Commit

Permalink
fix common.sh weirdness
Browse files Browse the repository at this point in the history
tests/CMakeLists.txt was calling configure_file without a copy method, and it was copying common.sh weirdly
updated test_xdd_reopen.sh to grep for the words, not just the strings
also fixed a few other issues missed in the previous shellcheck commit
  • Loading branch information
calccrypto committed Sep 13, 2023
1 parent 68b1f22 commit 89a05b8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configure_file(common.sh common.sh)
configure_file(common.sh common.sh COPYONLY)

# original tests depended on xdd being installed
option(TEST_INSTALLED "Use installed xdd for tests" ON)
Expand All @@ -15,7 +15,7 @@ if (NOT Time_EXECUTABLE)
message(CHECK_FAIL "not found: ctest will skip tests test_xdd_{passdelay/startdelay}")
else()
message(CHECK_PASS "found")
endif()
endif()

# configurable output directory
set(TESTDIR "${CMAKE_BINARY_DIR}/test-dir" CACHE PATH "Where to place test files")
Expand Down
21 changes: 9 additions & 12 deletions tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
# - generates correct test data files
# - generates correct test file names
#
#
# curly braces with global variables
# break in this file for some reason

TESTNAME=$(basename "$0" | cut -f 1 -d .)
common_next_file=""
Expand All @@ -23,19 +20,19 @@ common_next_file=""
#
initialize_test() {
# Ensure that the test config has been sourced
if [[ -z "$XDDTEST_LOG_DIR" ]]; then
if [[ -z "${XDDTEST_LOG_DIR}" ]]; then
echo "No properly sourced test_config during initialization. Missing log file path."
finalize_test 2
fi

# Create directories associated with local tests
if ! mkdir -p "$XDDTEST_LOCAL_MOUNT/$TESTNAME" ; then
echo "Unable to create $XDDTEST_LOCAL_MOUNT/$TESTNAME"
if ! mkdir -p "${XDDTEST_LOCAL_MOUNT}/${TESTNAME}" ; then
echo "Unable to create ${XDDTEST_LOCAL_MOUNT}/${TESTNAME}"
finalize_test 2
fi

# Create the log directory
mkdir -p "$XDDTEST_LOG_DIR"
mkdir -p "${XDDTEST_LOG_DIR}"

# Initialize the uid for data files
common_next_file="0"
Expand Down Expand Up @@ -70,15 +67,15 @@ finalize_test() {
# Get logfile for this test to store additional test output in if desired
#
get_log_file() {
echo "$XDDTEST_LOG_DIR/$TESTNAME.log"
echo "${XDDTEST_LOG_DIR}/${TESTNAME}.log"
}

#
# Generate a local filename
#
generate_local_filename() {
local varname="$1"
local name="$XDDTEST_LOCAL_MOUNT/$TESTNAME/file${common_next_file}.tdt"
local name="${XDDTEST_LOCAL_MOUNT}/${TESTNAME}/file${common_next_file}.tdt"
eval "${varname}=${name}"
common_next_file="$((common_next_file + 1))"
return 0
Expand Down Expand Up @@ -126,15 +123,15 @@ generate_local_file() {
cleanup_test_data() {
# Remove files associated with local tests
# shellcheck disable=SC2115
rm -r "$XDDTEST_LOCAL_MOUNT/$TESTNAME"
rm -r "${XDDTEST_LOCAL_MOUNT}/${TESTNAME}"
}

#
# Indicate a test has failed
#
fail() {
local message="$1"
printf "%-20s\t%10s: %s\n" "$TESTNAME" "FAIL" "$message"
printf "%-20s\t%10s: %s\n" "${TESTNAME}" "FAIL" "${message}"
}

#
Expand All @@ -149,5 +146,5 @@ pass() {
#
skip() {
local message="$1"
printf "%-20s\t%10s: %s\n" "$TESTNAME" "SKIPPED" "$message"
printf "%-20s\t%10s: %s\n" "${TESTNAME}" "SKIPPED" "${message}"
}
2 changes: 1 addition & 1 deletion tests/debug/test_xdd_debug_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ initialize_test

("${XDDTEST_XDD_EXE}" -op write -reqsize 128 -numreqs 1 -targets 1 /dev/null -verbose -debug INIT 2>&1 | grep "bound to NUMA node") || finalize_test 1 "XDD output is missing NUMA node pinning info"

("${XDDTEST_XDD_EXE}" -op write -reqsize 128 -numreqs 1 -targets 1 /dev/null -verbose 2>&1 | grep "bound to NUMA node") || finalize_test 1 "XDD output should not have NUMA node pinning info because -debug INIT was not used"
("${XDDTEST_XDD_EXE}" -op write -reqsize 128 -numreqs 1 -targets 1 /dev/null -verbose 2>&1 | grep "bound to NUMA node") && finalize_test 1 "XDD output should not have NUMA node pinning info because -debug INIT was not used"

# test passed
finalize_test 0
9 changes: 3 additions & 6 deletions tests/functional/test_xdd_reopen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ max_passes=4
for ((num_passes=min_passes; num_passes<=max_passes; num_passes++)); do
xdd_cmd="${XDDTEST_XDD_EXE} -op write -target ${test_file} -numreqs 10 -passes ${num_passes} -passdelay 1 -reopen ${test_file}"

#sys_call_open=$(2>&1 strace -cfq -e trace=open $xdd_cmd |grep open| tail -1 | cut -b 32-40)
# shellcheck disable=SC2086
sys_call_open=$(2>&1 strace -cfq -e trace=openat ${xdd_cmd} | grep openat| cut -b 32-40)
sys_call_open=$(2>&1 1>/dev/null strace -cfq -e trace=openat ${xdd_cmd} | grep -w openat | awk '{ print $4 }')
# shellcheck disable=SC2086
sys_call_close=$(2>&1 strace -cfq -e trace=close ${xdd_cmd} | grep close | cut -b 32-40)
#sys_call_close=$(2>&1 strace -cfq -e trace=close ${xdd_cmd} |grep close |cut -b 32-40)
sys_call_close=$(2>&1 1> /dev/null strace -cfq -e trace=close ${xdd_cmd} | grep -w close | awk '{ print $4 }')

sys_open["${num_passes}"]="${sys_call_open}"
sys_close["${num_passes}"]="${sys_call_close}"
Expand All @@ -49,7 +47,6 @@ pass_count=0

# Check if the first element is 1 less than the next and so on for n-1 elements
for ((i=min_passes; i<max_passes; i++)); do

if [[ $((${sys_open[${i}]}+1)) -eq ${sys_open[$((i+1))]} ]]; then
pass_count="$((pass_count+1))"
fi
Expand All @@ -67,5 +64,5 @@ if [[ "${pass_count}" -eq "${correct_count}" ]]; then
finalize_test 0
else
# test failed
finalize_test 1 "$pass_count != $correct_count so the number of open/close calls is incorrect when using flag -reopen"
finalize_test 1 "${pass_count} != ${correct_count} so the number of open/close calls is incorrect when using flag -reopen"
fi
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_syncwrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ num_passes=10
xdd_cmd="${XDDTEST_XDD_EXE} -target ${test_file} -op write -numreqs 10 -passes $num_passes -syncwrite"
# shellcheck disable=SC2086
sys_call=$(2>&1 strace -cfq -e trace=fdatasync ${xdd_cmd} | grep "fdatasync")
sync_num=$(echo "${sys_call}" | cut -f 4 -d ' ')
sync_num=$(echo "${sys_call}" | awk '{ print $4 }')

# Verify output
if [[ "${sync_num}" -eq "${num_passes}" ]]; then
# test passed
finalize_test 0
else
# test failed
finalize_test 1 "fdatasync calls $sync_num != $num_passes when using -passes $num_passes -syncwrite"
finalize_test 1 "fdatasync calls ${sync_num} != ${num_passes} when using -passes ${num_passes} -syncwrite"
fi

0 comments on commit 89a05b8

Please sign in to comment.