From a522f674effd4720f064ae544bedd1c4328a74ce Mon Sep 17 00:00:00 2001 From: Robert Eustace Novak Date: Fri, 3 Jan 2020 13:11:28 -0800 Subject: [PATCH 1/5] Created test cases for Issue #311 Only two test cases so far: - The first test case shows the difference between GNU find and HPC dfind in handling spaces with file names. - The second test case illustrates the issue that dfind --exec does not permit standard redirection of stderr output by a command forked to exec. --- test/tests/test_dfind/getgitroot.sh | 15 ++ test/tests/test_dfind/makefile | 117 +++++++++++ .../test_dfind_exec_stderr_redirect.sh | 195 ++++++++++++++++++ test/tests/test_dfind/test_dfind_spaces.sh | 193 +++++++++++++++++ 4 files changed, 520 insertions(+) create mode 100644 test/tests/test_dfind/getgitroot.sh create mode 100644 test/tests/test_dfind/makefile create mode 100644 test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh create mode 100644 test/tests/test_dfind/test_dfind_spaces.sh diff --git a/test/tests/test_dfind/getgitroot.sh b/test/tests/test_dfind/getgitroot.sh new file mode 100644 index 000000000..b357957a9 --- /dev/null +++ b/test/tests/test_dfind/getgitroot.sh @@ -0,0 +1,15 @@ +#!/bin/bash +#################### +# Author: Robert E. Novak +# email: novak5@llnl.gov +# +# Find and return the parent directory that contains ".git" +# +# That is the parent directory that is the "root" of all evil so that we can +# execute binaries located in ../install/bin +#################### +while [ ! -d .git ] +do + cd .. +done +pwd diff --git a/test/tests/test_dfind/makefile b/test/tests/test_dfind/makefile new file mode 100644 index 000000000..b3febdb7e --- /dev/null +++ b/test/tests/test_dfind/makefile @@ -0,0 +1,117 @@ +SHELL=/bin/bash +.sh: + cp $? `basename $? .sh` + chmod +x `basename $? .sh` + +#################### +# Perform testing of the dfind command +# Tests will be numbered and will report both +# the command name and the number as part of the +# diagnostic output. +#################### +PROJECTROOT := $(shell bash ./getgitroot.sh) + +#################### +# Define all of the hpc FIND command variables that come in from the +# command line and will eventually be passed to FIEMAP for parallel testing +# +# Just to make this (hopefully) a little less confusing +# +# dfind ........ the binary under test = DFIND_TEST_BIN +# mpirun|srun .. the command to execute the dfind on multiple machines +# DFIND_MPIRUN_BIN +# diff ......... the command to compare the difference in output between +# dfind and find (GNU find since we want to emulate +# the semantics +# DFIND_CMP_BIN +# ../test/src .. the directory relative to mpifileutils where source +# test data is place +# DFIND_SRC_DIR +# ../test/dest . The directory relative to mpifileutils where test +# output is placed +# DFIND_DEST_DIR +# dfind.test.sh The shell script generated inside this script to perform +# the testing. +# DFIND_TMP_FILE +# ../test/bin .. the directory in which executable files (including this +# script and the generated script) are placed to avoid +# cluttering up the project ../install/bin +# DFIND_TESTING_BIN_DIR +#################### +#################### +# A final word about the .. relativity to the project parent directory. +# The build process for mpifileutils installs the following: +# ../install/bin +# ../install/include +# ../install/lib +# ../install/lib64 +# ../install/share +# +# In order to avoid cluttering the installation directory further, the +# testing src, dest and bin directories are placed in +# ../test +# +# To facilitate finding the root of the project from within the directory +# where you run the tests (the above was done to keep from cluttering this +# directory as well), there is a short script "getgitroot" which determines +# the project root directory by walking up the tree to find the .git +# directory: +# Find and return the parent directory that contains ".git" +# +# That is the parent directory that is the "root" of all evil so that we can +# execute binaries located in ../install/bin +#################### +# while [ ! -d .git ] +# do +# cd .. +# done +# pwd +#################### +DFIND_INSTALL_DIR := $(PROJECTROOT)/../install/bin +DFIND_TEST_BIN := $(DFIND_INSTALL_DIR)/dfind +DFIND_MPIRUN_BIN := $(shell which srun) +DFIND_CMP_BIN := $(shell which diff) +DFIND_SRC_DIR := $(PROJECTROOT)/../test/src +DFIND_DEST_DIR := $(PROJECTROOT)/../test/dest +DFIND_TMP_FILE := dfind_test.sh +DFIND_TESTING_BIN_DIR := $(PROJECTROOT)/../test/bin + +TEST-01 := test_dfind_spaces +TEST-02 := test_dfind_exec_stderr_redirect +DFIND_TEST_NUM-01 := $(DFIND_TESTING_BIN_DIR)/$(TEST-01) +DFIND_TEST_NUM-02 := $(DFIND_TESTING_BIN_DIR)/$(TEST-02) + +TESTS = getgitroot $(TEST-01) $(TEST-02) + +.PHONY: all clean install uninstall run run1 run2 + +install: $(TESTS) + mkdir -p $(DFIND_TESTING_BIN_DIR) + install -m711 -g linuxdev -o $(USER) -C $? $(DFIND_TESTING_BIN_DIR) +clean: + @for script in $(TESTS) ; \ + do \ + echo "rm -f $$script" ; \ + rm -f $$script ; \ + done + rm -rf $(PROJECTROOT)/../test +uninstall: + @for script in $(TESTS) ; \ + do \ + echo "rm -f $(DFIND_TESTING_BIN_DIR)/$$script" ; \ + rm f $(DFIND_TESTING_BIN_DIR)/$$script ; \ + done +run: run1 run2 + echo testing complete +# run: $(DFIND_TEST_NUM-01) +run1: install $(DFIND_TEST_NUM-01) $(DFIND_TEST_BIN) + rm -rf ${DFIND_SRC_DIR} ${DFIND_DEST_DIR} + mkdir -p $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TESTING_BIN_DIR) + $(DFIND_TEST_NUM-01) $(DFIND_TEST_BIN) $(DFIND_MPIRUN_BIN) $(DFIND_CMP_BIN) \ + $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TMP_FILE) $(DFIND_TESTING_BIN_DIR) +run2: install $(DFIND_TEST_NUM-02) $(DFIND_TEST_BIN) + rm -rf ${DFIND_SRC_DIR} ${DFIND_DEST_DIR} + mkdir -p $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TESTING_BIN_DIR) + $(DFIND_TEST_NUM-02) $(DFIND_TEST_BIN) $(DFIND_MPIRUN_BIN) $(DFIND_CMP_BIN) \ + $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TMP_FILE) $(DFIND_TESTING_BIN_DIR) +# vim: set syntax=makefile,sw=4,t=4 diff --git a/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh b/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh new file mode 100644 index 000000000..48615d103 --- /dev/null +++ b/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh @@ -0,0 +1,195 @@ +#!/bin/bash +DFIND_TEST_VERBOSE=0 +# set -x +#################### +# Author: Robert E. Novak +# email: novak5@llnl.gov +# +# This test is designed to show the differences between Gnu find and dfind +# in processing spaces " " in filenames for the exec command. +# +# The challenge with this script is the large number of definitions that all +# look similar. In theory as we develop more tests, very litle in the +# base version of this file has to change. +#################### +# Define all of the hpc FIND command variables that come in from the +# command line and will eventually be passed to FIEMAP for parallel testing +# +# Just to make this (hopefully) a little less confusing +# +# dfind ........ the binary under test = DFIND_TEST_BIN +# mpirun|srun .. the command to execute the dfind on multiple machines +# DFIND_MPIRUN_BIN +# diff ......... the command to compare the difference in output between +# dfind and find (GNU find since we want to emulate +# the semantics +# DFIND_CMP_BIN +# ../test/src .. the directory relative to mpifileutils where source +# test data is place +# DFIND_SRC_DIR +# ../test/dest . The directory relative to mpifileutils where test +# output is placed +# DFIND_DEST_DIR +# dfind.test.sh The shell script generated inside this script to perform +# the testing. +# DFIND_TMP_FILE +# ../test/bin .. the directory in which executable files (including this +# script and the generated script) are placed to avoid +# cluttering up the project ../install/bin +# DFIND_TESTING_BIN_DIR +#################### +#################### +# A final word about the .. relativity to the project parent directory. +# The build process for mpifileutils installs the following: +# ../install/bin +# ../install/include +# ../install/lib +# ../install/lib64 +# ../install/share +# +# In order to avoid cluttering the installation directory further, the +# testing src, dest and bin directories are placed in +# ../test +# +# To facilitate finding the root of the project from within the directory +# where you run the tests (the above was done to keep from cluttering this +# directory as well), there is a short script "getgitroot" which determines +# the project root directory by walking up the tree to find the .git +# directory: +# Find and return the parent directory that contains ".git" +# +# That is the parent directory that is the "root" of all evil so that we can +# execute binaries located in ../install/bin +#################### +# while [ ! -d .git ] +# do +# cd .. +# done +# pwd +#################### +DFIND_TEST_BIN=${DFIND_TEST_BIN:-${1}} +DFIND_MPIRUN_BIN=${DFIND_MPIRUN_BIN:=${2}} +DFIND_CMP_BIN=${DFIND_CMP_BIN:-${3}} +DFIND_SRC_DIR=${DFIND_SRC_DIR:-${4}} +DFIND_DEST_DIR=${DFIND_DEST_DIR:-${5}} +DFIND_TMP_FILE=${DFIND_TMP_FILE:-${6}} +DFIND_TESTING_BIN_DIR=${DFIND_TESTING_BIN_DIR:-${7}} +echo "\${DFIND_TESTING_BIN_DIR} = ${DFIND_TESTING_BIN_DIR}" +#################### +# Define the Test Number +#################### +DFIND_TEST_NUMBER=02 +TEST_PREFIX="TEST-${DFIND_TEST_NUMBER}" + +#################### +# Make the directories REAL +#################### +DFIND_TEST_BIN=$(realpath ${DFIND_TEST_BIN}) +DFIND_SRC_DIR=$(realpath ${DFIND_SRC_DIR}) +DFIND_DEST_DIR=$(realpath ${DFIND_DEST_DIR}) +DFIND_TESTING_BIN_DIR=$(realpath ${DFIND_TESTING_BIN_DIR}) +DFIND_CMP_RESULT=${DFIND_DEST_DIR}/${TEST_PREFIX}_cmp_result.txt + +#################### +# Where we will put the output in the DEST_DIR +#################### +DFIND_FIND_OUT=${DFIND_DEST_DIR}/${TEST_PREFIX}_dfind_find_out.txt + +#################### +# Define the GNU programs that we are testing against. +#################### +GNU_FIND_BIN=$(which find) +GNU_FIND_OUT=${DFIND_DEST_DIR}/${TEST_PREFIX}_gnu_find_out.txt + +#################### +# The verbose name of this test. We had to wait until here so that +# the binaries are named. +#################### +DFIND_TEST_NAME="Test ${DFIND_TEST_NUMBER} --> ${DFIND_TEST_BIN} vs. ${GNU_FIND_BIN} \r\n +Test ${DFIND_TEST_NUMBER} --> $(basename ${DFIND_TEST_BIN}) vs. $(basename ${GNU_FIND_BIN})\r\n +for dfind --exec {} redirection of stderr fails\r\n" + +#################### +# Confirm that we were passed the right information +#################### +if [ $DFIND_TEST_VERBOSE -gt 0 ] +then + echo -e "Using dfind binary at:\t\t${DFIND_TEST_BIN}" + echo -e "Using mpirun binary at:\t\t${DFIND_MPIRUN_BIN}" + echo -e "Using cmp binary at:\t\t${DFIND_CMP_BIN}" + + #################### + # This helps to confirm that the comparison test is from GNU + #################### + strings ${DFIND_CMP_BIN} | egrep '^GNU' + echo -e "Using src directory at:\t\t${DFIND_SRC_DIR}" + echo -e "Using dest directory at:\t${DFIND_DEST_DIR}" + echo -e "Using tmp file at:\t\t${DFIND_TMP_FILE}" + echo -e "Using testing bin dir at:\t${DFIND_TESTING_BIN_DIR}" + echo -e "Comparison test against:\t${GNU_FIND_BIN}" + echo -e "Test Prefix:\t\t${TEST_PREFIX}" + echo -e "Test Name: ${DFIND_TEST_NAME}" + #################### + # This helps to confirm that the comparison is against the GNU version + #################### + strings ${GNU_FIND_BIN} | egrep "^GNU" +fi + +#################### +# Construct the test case +# Create a file name with no spaces +#################### +echo "A file with no spaces in the name" > ${DFIND_SRC_DIR}/A_file_with_no_spaces_in_the_name +echo "A file with spaces in the name" > "${DFIND_SRC_DIR}/A_file_with spaces_in_the_name" + +#################### +# Test the GNU find in single mode +#################### +if [ ${DFIND_TEST_VERBOSE} -gt 0 ] +then + echo "find ${DFIND_SRC_DIR} -exec ls {}a 2>> ${GNU_FIND_OUT}.err ';' > ${GNU_FIND_OUT}" +fi +find ${DFIND_SRC_DIR} -exec ls {}a 2>> ${GNU_FIND_OUT}.err ';' > ${GNU_FIND_OUT} + +#################### +# Test the HPC find in single mode +#################### +if [ ${DFIND_TEST_VERBOSE} -gt 0 ] +then +# echo "${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {} ';' > ${DFIND_FIND_OUT}" + echo "#!/bin/bash > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" + echo "${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {}a 2>> ${DFIND_FIND_OUT}.err ';' 2>&1 >> ${DFIND_FIND_OUT} > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" + echo "chmod +x ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" + echo "# ${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" +fi +echo "#!/bin/bash" > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +echo "${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {}a 2>> ${DFIND_FIND_OUT}.err ';' 2>&1 >> ${DFIND_FIND_OUT}" > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +chmod +x ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} + +# ${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +/bin/bash ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} + +#################### +# Compare the result files. +#################### +if [ ${DFIND_TEST_VERBOSE} -gt 0 ] +then + echo "${DFIND_CMP_BIN} ${GNU_FIND_OUT} ${DFIND_FIND_OUT} 2>&1 > ${DFIND_CMP_RESULT}" +fi +${DFIND_CMP_BIN} ${GNU_FIND_OUT} ${DFIND_FIND_OUT} 2>&1 > ${DFIND_CMP_RESULT} +if [ $? -ne 0 ] +then + echo -e "FAILURE: $DFIND_TEST_NAME" + echo "RESULT:" + cat ${DFIND_CMP_RESULT} ${GNU_FIND_OUT}.err ${DFIND_FIND_OUT}.err +else + #################### + # Only report success in verbose mode + #################### + if [ $DFIND_TEST_VERBOSE -gt 0 ] + then + echo -e "SUCCESS: $FIND_TEST_NAME" + echo "RESULT:" + echo ${DFIND_CMP_RESULT} + fi +fi diff --git a/test/tests/test_dfind/test_dfind_spaces.sh b/test/tests/test_dfind/test_dfind_spaces.sh new file mode 100644 index 000000000..444a94f01 --- /dev/null +++ b/test/tests/test_dfind/test_dfind_spaces.sh @@ -0,0 +1,193 @@ +#!/bin/bash +DFIND_TEST_VERBOSE=0 +#################### +# Author: Robert E. Novak +# email: novak5@llnl.gov +# +# This test is designed to show the differences between Gnu find and dfind +# in processing spaces " " in filenames for the exec command. +# +# The challenge with this script is the large number of definitions that all +# look similar. In theory as we develop more tests, very litle in the +# base version of this file has to change. +#################### +# Define all of the hpc FIND command variables that come in from the +# command line and will eventually be passed to FIEMAP for parallel testing +# +# Just to make this (hopefully) a little less confusing +# +# dfind ........ the binary under test = DFIND_TEST_BIN +# mpirun|srun .. the command to execute the dfind on multiple machines +# DFIND_MPIRUN_BIN +# diff ......... the command to compare the difference in output between +# dfind and find (GNU find since we want to emulate +# the semantics +# DFIND_CMP_BIN +# ../test/src .. the directory relative to mpifileutils where source +# test data is place +# DFIND_SRC_DIR +# ../test/dest . The directory relative to mpifileutils where test +# output is placed +# DFIND_DEST_DIR +# dfind.test.sh The shell script generated inside this script to perform +# the testing. +# DFIND_TMP_FILE +# ../test/bin .. the directory in which executable files (including this +# script and the generated script) are placed to avoid +# cluttering up the project ../install/bin +# DFIND_TESTING_BIN_DIR +#################### +#################### +# A final word about the .. relativity to the project parent directory. +# The build process for mpifileutils installs the following: +# ../install/bin +# ../install/include +# ../install/lib +# ../install/lib64 +# ../install/share +# +# In order to avoid cluttering the installation directory further, the +# testing src, dest and bin directories are placed in +# ../test +# +# To facilitate finding the root of the project from within the directory +# where you run the tests (the above was done to keep from cluttering this +# directory as well), there is a short script "getgitroot" which determines +# the project root directory by walking up the tree to find the .git +# directory: +# Find and return the parent directory that contains ".git" +# +# That is the parent directory that is the "root" of all evil so that we can +# execute binaries located in ../install/bin +#################### +# while [ ! -d .git ] +# do +# cd .. +# done +# pwd +#################### +DFIND_TEST_BIN=${DFIND_TEST_BIN:-${1}} +DFIND_MPIRUN_BIN=${DFIND_MPIRUN_BIN:=${2}} +DFIND_CMP_BIN=${DFIND_CMP_BIN:-${3}} +DFIND_SRC_DIR=${DFIND_SRC_DIR:-${4}} +DFIND_DEST_DIR=${DFIND_DEST_DIR:-${5}} +DFIND_TMP_FILE=${DFIND_TMP_FILE:-${6}} +DFIND_TESTING_BIN_DIR=${DFIND_TESTING_BIN_DIR:-${7}} +echo "\${DFIND_TESTING_BIN_DIR} = ${DFIND_TESTING_BIN_DIR}" +#################### +# Define the Test Number +#################### +DFIND_TEST_NUMBER=01 +TEST_PREFIX="TEST_${DFIND_TEST_NUMBER}" +#################### +# Make the directories REAL +#################### +DFIND_TEST_BIN=$(realpath ${DFIND_TEST_BIN}) +DFIND_SRC_DIR=$(realpath ${DFIND_SRC_DIR}) +DFIND_DEST_DIR=$(realpath ${DFIND_DEST_DIR}) +DFIND_TESTING_BIN_DIR=$(realpath ${DFIND_TESTING_BIN_DIR}) +DFIND_CMP_RESULT=${DFIND_DEST_DIR}/${TEST_PREFIX}_cmp_result.txt + +#################### +# Where we will put the output in the DEST_DIR +#################### +DFIND_FIND_OUT=${DFIND_DEST_DIR}/${TEST_PREFIX}_dfind_find_out.txt + +#################### +# Define the GNU programs that we are testing against. +#################### +GNU_FIND_BIN=$(which find) +GNU_FIND_OUT=${DFIND_DEST_DIR}/${TEST_PREFIX}_gnu_find_out.txt + +#################### +# The verbose name of this test. We had to wait until here so that +# the binaries are named. +#################### +DFIND_TEST_NAME="Test ${DFIND_TEST_NUMBER} --> ${DFIND_TEST_BIN} vs. ${GNU_FIND_BIN} \r\n +Test ${DFIND_TEST_NUMBER} --> $(basename ${DFIND_TEST_BIN}) vs. $(basename ${GNU_FIND_BIN})\r\n +for dfind --exec {} substitution of\r\n +file names containing spaces\r\n" + +#################### +# Confirm that we were passed the right information +#################### +if [ $DFIND_TEST_VERBOSE -gt 0 ] +then + echo -e "Using dfind binary at:\t\t${DFIND_TEST_BIN}" + echo -e "Using mpirun binary at:\t\t${DFIND_MPIRUN_BIN}" + echo -e "Using cmp binary at:\t\t${DFIND_CMP_BIN}" + + #################### + # This helps to confirm that the comparison test is from GNU + #################### + strings ${DFIND_CMP_BIN} | egrep '^GNU' + echo -e "Using src directory at:\t\t${DFIND_SRC_DIR}" + echo -e "Using dest directory at:\t${DFIND_DEST_DIR}" + echo -e "Using tmp file at:\t\t${DFIND_TMP_FILE}" + echo -e "Using testing bin dir at:\t${DFIND_TESTING_BIN_DIR}" + echo -e "Comparison test against:\t${GNU_FIND_BIN}" + echo -e "Test Prefix:\t\t${TEST_PREFIX}" + echo -e "Test Name: ${DFIND_TEST_NAME}" + #################### + # This helps to confirm that the comparison is against the GNU version + #################### + strings ${GNU_FIND_BIN} | egrep "^GNU" +fi + +#################### +# Construct the test case +# Create a file name with no spaces +#################### +echo "A file with no spaces in the name" > ${DFIND_SRC_DIR}/A_file_with_no_spaces_in_the_name +echo "A file with spaces in the name" > "${DFIND_SRC_DIR}/A_file_with spaces_in_the_name" + +#################### +# Test the GNU find in single mode +#################### +if [ ${DFIND_TEST_VERBOSE} -gt 0 ] +then + echo "find ${DFIND_SRC_DIR} -exec ls {}a 2>> ${GNU_FIND_OUT}.err ';' > ${GNU_FIND_OUT}" +fi +find ${DFIND_SRC_DIR} -exec ls {}a 2>> ${GNU_FIND_OUT}.err ';' > ${GNU_FIND_OUT} +#################### +# Test the HPC find in single mode +#################### +if [ ${DFIND_TEST_VERBOSE} -gt 0 ] +then +# echo "${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {} ';' > ${DFIND_FIND_OUT}" + echo "#!/bin/bash > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" + echo "${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {}a 2>> ${DFIND_FIND_OUT}.err ';' 2>&1 >> ${DFIND_FIND_OUT} > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" + echo "chmod +x ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" + echo "# ${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" +fi +echo "#!/bin/bash" > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +echo "${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {}a 2>> ${DFIND_FIND_OUT}.err ';' 2>&1 >> ${DFIND_FIND_OUT}" > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +chmod +x ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} + +# ${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +/bin/bash ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} + +#################### +# Compare the result files. +#################### +if [ ${DFIND_TEST_VERBOSE} -gt 0 ] +then + echo "${DFIND_CMP_BIN} ${GNU_FIND_OUT} ${DFIND_FIND_OUT} 2>&1 > ${DFIND_CMP_RESULT}" +fi +${DFIND_CMP_BIN} ${GNU_FIND_OUT} ${DFIND_FIND_OUT} 2>&1 > ${DFIND_CMP_RESULT} +if [ $? -ne 0 ] +then + echo -e "FAILURE: $DFIND_TEST_NAME" + echo "RESULT:" + cat ${DFIND_CMP_RESULT} ${GNU_FIND_OUT}.err ${DFIND_FIND_OUT}.err +else + #################### + # Only report success in verbose mode + #################### + if [ $DFIND_TEST_VERBOSE -gt 0 ] + then + echo -e "SUCCESS: $FIND_TEST_NAME" + echo "RESULT:" + echo ${DFIND_CMP_RESULT} + fi +fi From ff4ec3fa380dc4ce5e0f33204a1cfd4d368ae5c0 Mon Sep 17 00:00:00 2001 From: Robert Eustace Novak Date: Mon, 6 Jan 2020 11:48:49 -0800 Subject: [PATCH 2/5] Made the script easier to read I also fixed a bug with find vs. $GFIND --- .../test_dfind_exec_stderr_redirect.sh | 106 ++++++++++------- test/tests/test_dfind/test_dfind_spaces.sh | 108 +++++++++++------- 2 files changed, 126 insertions(+), 88 deletions(-) diff --git a/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh b/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh index 48615d103..5e59d7936 100644 --- a/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh +++ b/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh @@ -1,6 +1,4 @@ #!/bin/bash -DFIND_TEST_VERBOSE=0 -# set -x #################### # Author: Robert E. Novak # email: novak5@llnl.gov @@ -74,39 +72,51 @@ DFIND_SRC_DIR=${DFIND_SRC_DIR:-${4}} DFIND_DEST_DIR=${DFIND_DEST_DIR:-${5}} DFIND_TMP_FILE=${DFIND_TMP_FILE:-${6}} DFIND_TESTING_BIN_DIR=${DFIND_TESTING_BIN_DIR:-${7}} -echo "\${DFIND_TESTING_BIN_DIR} = ${DFIND_TESTING_BIN_DIR}" +DFIND_TEST_NUMBER=${DFIND_TEST_NUMBER:-${8}} +GNU_FIND_BIN=${GNU_FIND_BIN:-${9}} + +#################### +# To make the rest of the script more legible +#################### +DFIND=${DFIND_TEST_BIN} +MPIRUN=${DFIND_MPIRUN_BIN} +CMP=${DFIND_CMP_BIN} +SRCDIR=${DFIND_SRC_DIR} +DESTDIR=${DFIND_DEST_DIR} +TMPFILE=${DFIND_TMP_FILE} +TESTBINDIR=${DFIND_TESTING_BIN_DIR} + #################### # Define the Test Number #################### -DFIND_TEST_NUMBER=02 -TEST_PREFIX="TEST-${DFIND_TEST_NUMBER}" +TEST_PREFIX="TEST_${DFIND_TEST_NUMBER}" #################### # Make the directories REAL #################### -DFIND_TEST_BIN=$(realpath ${DFIND_TEST_BIN}) -DFIND_SRC_DIR=$(realpath ${DFIND_SRC_DIR}) -DFIND_DEST_DIR=$(realpath ${DFIND_DEST_DIR}) -DFIND_TESTING_BIN_DIR=$(realpath ${DFIND_TESTING_BIN_DIR}) -DFIND_CMP_RESULT=${DFIND_DEST_DIR}/${TEST_PREFIX}_cmp_result.txt +DFIND=$(realpath ${DFIND}) +SRCDIR=$(realpath ${SRCDIR}) +DESTDIR=$(realpath ${DESTDIR}) +TESTBINDIR=$(realpath ${TESTBINDIR}) #################### -# Where we will put the output in the DEST_DIR +# Define the GNU programs that we are testing against. #################### -DFIND_FIND_OUT=${DFIND_DEST_DIR}/${TEST_PREFIX}_dfind_find_out.txt +GFIND=$(which ${GNU_FIND_BIN}) #################### -# Define the GNU programs that we are testing against. +# Where we will put the output data #################### -GNU_FIND_BIN=$(which find) -GNU_FIND_OUT=${DFIND_DEST_DIR}/${TEST_PREFIX}_gnu_find_out.txt +DFIND_OUT=${DESTDIR}/${TEST_PREFIX}_dfind_find_out.txt +GFIND_OUT=${DESTDIR}/${TEST_PREFIX}_gnu_find_out.txt +DFIND_CMP_RESULT=${DESTDIR}/${TEST_PREFIX}_cmp_result.txt #################### # The verbose name of this test. We had to wait until here so that # the binaries are named. #################### -DFIND_TEST_NAME="Test ${DFIND_TEST_NUMBER} --> ${DFIND_TEST_BIN} vs. ${GNU_FIND_BIN} \r\n -Test ${DFIND_TEST_NUMBER} --> $(basename ${DFIND_TEST_BIN}) vs. $(basename ${GNU_FIND_BIN})\r\n +DFIND_TEST_NAME="Test ${DFIND_TEST_NUMBER} --> ${DFIND} vs. ${GFIND} \r\n +Test ${DFIND_TEST_NUMBER} --> $(basename ${DFIND}) vs. $(basename ${GFIND})\r\n for dfind --exec {} redirection of stderr fails\r\n" #################### @@ -114,74 +124,82 @@ for dfind --exec {} redirection of stderr fails\r\n" #################### if [ $DFIND_TEST_VERBOSE -gt 0 ] then - echo -e "Using dfind binary at:\t\t${DFIND_TEST_BIN}" - echo -e "Using mpirun binary at:\t\t${DFIND_MPIRUN_BIN}" - echo -e "Using cmp binary at:\t\t${DFIND_CMP_BIN}" + echo -e "Using dfind binary at:\t\t${DFIND}" + echo -e "Using mpirun binary at:\t\t${MPIRUN}" + echo -e "Using cmp binary at:\t\t${CMP}" #################### # This helps to confirm that the comparison test is from GNU #################### - strings ${DFIND_CMP_BIN} | egrep '^GNU' - echo -e "Using src directory at:\t\t${DFIND_SRC_DIR}" - echo -e "Using dest directory at:\t${DFIND_DEST_DIR}" - echo -e "Using tmp file at:\t\t${DFIND_TMP_FILE}" - echo -e "Using testing bin dir at:\t${DFIND_TESTING_BIN_DIR}" - echo -e "Comparison test against:\t${GNU_FIND_BIN}" + strings ${CMP} | egrep '^GNU' + echo -e "Using src directory at:\t\t${SRCDIR}" + echo -e "Using dest directory at:\t${DESTDIR}" + echo -e "Using tmp file at:\t\t${TMPFILE}" + echo -e "Using testing bin dir at:\t${TESTBINDIR}" + echo -e "Comparison test against:\t${GFIND}" echo -e "Test Prefix:\t\t${TEST_PREFIX}" echo -e "Test Name: ${DFIND_TEST_NAME}" #################### # This helps to confirm that the comparison is against the GNU version #################### - strings ${GNU_FIND_BIN} | egrep "^GNU" + strings ${GFIND} | egrep "^GNU" fi +################################################################################ +#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +# +# Everything up to here has been a preamble. Here is where we construct the +# test data to perform the test. +# +################################################################################ +################################################################################ #################### # Construct the test case # Create a file name with no spaces #################### -echo "A file with no spaces in the name" > ${DFIND_SRC_DIR}/A_file_with_no_spaces_in_the_name -echo "A file with spaces in the name" > "${DFIND_SRC_DIR}/A_file_with spaces_in_the_name" +echo "A file with no spaces in the name" > ${SRCDIR}/A_file_with_no_spaces_in_the_name +echo "A file with spaces in the name" > "${SRCDIR}/A_file_with spaces_in_the_name" #################### # Test the GNU find in single mode #################### if [ ${DFIND_TEST_VERBOSE} -gt 0 ] then - echo "find ${DFIND_SRC_DIR} -exec ls {}a 2>> ${GNU_FIND_OUT}.err ';' > ${GNU_FIND_OUT}" + echo "${GFIND} ${SRCDIR} -exec ls {}a 2>> ${GFIND_OUT}.err ';' > ${GFIND_OUT}" fi -find ${DFIND_SRC_DIR} -exec ls {}a 2>> ${GNU_FIND_OUT}.err ';' > ${GNU_FIND_OUT} +${GFIND} ${SRCDIR} -exec ls {}a 2>> ${GFIND_OUT}.err ';' > ${GFIND_OUT} #################### # Test the HPC find in single mode #################### if [ ${DFIND_TEST_VERBOSE} -gt 0 ] then -# echo "${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {} ';' > ${DFIND_FIND_OUT}" - echo "#!/bin/bash > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" - echo "${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {}a 2>> ${DFIND_FIND_OUT}.err ';' 2>&1 >> ${DFIND_FIND_OUT} > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" - echo "chmod +x ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" - echo "# ${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" +# echo "${MPIRUN} -n 1 ${DFIND} ${SRCDIR} --exec ls {} ';' > ${DFIND_OUT}" + echo "#!/bin/bash > ${TESTBINDIR}/${TMPFILE}" + echo "${DFIND} ${SRCDIR} --exec ls {}a 2>> ${DFIND_OUT}.err ';' 2>&1 >> ${DFIND_OUT} > ${TESTBINDIR}/${TMPFILE}" + echo "chmod +x ${TESTBINDIR}/${TMPFILE}" + echo "# ${MPIRUN} -n 1 ${TESTBINDIR}/${TMPFILE}" fi -echo "#!/bin/bash" > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} -echo "${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {}a 2>> ${DFIND_FIND_OUT}.err ';' 2>&1 >> ${DFIND_FIND_OUT}" > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} -chmod +x ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +echo "#!/bin/bash" > ${TESTBINDIR}/${TMPFILE} +echo "${DFIND} ${SRCDIR} --exec ls {}a 2>> ${DFIND_OUT}.err ';' 2>&1 >> ${DFIND_OUT}" > ${TESTBINDIR}/${TMPFILE} +chmod +x ${TESTBINDIR}/${TMPFILE} -# ${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} -/bin/bash ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +# ${MPIRUN} -n 1 ${TESTBINDIR}/${TMPFILE} +/bin/bash ${TESTBINDIR}/${TMPFILE} #################### # Compare the result files. #################### if [ ${DFIND_TEST_VERBOSE} -gt 0 ] then - echo "${DFIND_CMP_BIN} ${GNU_FIND_OUT} ${DFIND_FIND_OUT} 2>&1 > ${DFIND_CMP_RESULT}" + echo "${CMP} ${GFIND_OUT} ${DFIND_OUT} 2>&1 > ${DFIND_CMP_RESULT}" fi -${DFIND_CMP_BIN} ${GNU_FIND_OUT} ${DFIND_FIND_OUT} 2>&1 > ${DFIND_CMP_RESULT} +${CMP} ${GFIND_OUT} ${DFIND_OUT} 2>&1 > ${DFIND_CMP_RESULT} if [ $? -ne 0 ] then echo -e "FAILURE: $DFIND_TEST_NAME" echo "RESULT:" - cat ${DFIND_CMP_RESULT} ${GNU_FIND_OUT}.err ${DFIND_FIND_OUT}.err + cat ${DFIND_CMP_RESULT} ${GFIND_OUT}.err ${DFIND_OUT}.err else #################### # Only report success in verbose mode diff --git a/test/tests/test_dfind/test_dfind_spaces.sh b/test/tests/test_dfind/test_dfind_spaces.sh index 444a94f01..a3792cda3 100644 --- a/test/tests/test_dfind/test_dfind_spaces.sh +++ b/test/tests/test_dfind/test_dfind_spaces.sh @@ -1,5 +1,4 @@ #!/bin/bash -DFIND_TEST_VERBOSE=0 #################### # Author: Robert E. Novak # email: novak5@llnl.gov @@ -73,113 +72,134 @@ DFIND_SRC_DIR=${DFIND_SRC_DIR:-${4}} DFIND_DEST_DIR=${DFIND_DEST_DIR:-${5}} DFIND_TMP_FILE=${DFIND_TMP_FILE:-${6}} DFIND_TESTING_BIN_DIR=${DFIND_TESTING_BIN_DIR:-${7}} -echo "\${DFIND_TESTING_BIN_DIR} = ${DFIND_TESTING_BIN_DIR}" +DFIND_TEST_NUMBER=${DFIND_TEST_NUMBER:-${8}} +GNU_FIND_BIN=${GNU_FIND_BIN:-${9}} + +#################### +# To make the rest of the script more legible +#################### +DFIND=${DFIND_TEST_BIN} +MPIRUN=${DFIND_MPIRUN_BIN} +CMP=${DFIND_CMP_BIN} +SRCDIR=${DFIND_SRC_DIR} +DESTDIR=${DFIND_DEST_DIR} +TMPFILE=${DFIND_TMP_FILE} +TESTBINDIR=${DFIND_TESTING_BIN_DIR} + #################### # Define the Test Number #################### -DFIND_TEST_NUMBER=01 TEST_PREFIX="TEST_${DFIND_TEST_NUMBER}" + #################### # Make the directories REAL #################### -DFIND_TEST_BIN=$(realpath ${DFIND_TEST_BIN}) -DFIND_SRC_DIR=$(realpath ${DFIND_SRC_DIR}) -DFIND_DEST_DIR=$(realpath ${DFIND_DEST_DIR}) -DFIND_TESTING_BIN_DIR=$(realpath ${DFIND_TESTING_BIN_DIR}) -DFIND_CMP_RESULT=${DFIND_DEST_DIR}/${TEST_PREFIX}_cmp_result.txt +DFIND=$(realpath ${DFIND}) +SRCDIR=$(realpath ${SRCDIR}) +DESTDIR=$(realpath ${DESTDIR}) +TESTBINDIR=$(realpath ${TESTBINDIR}) #################### -# Where we will put the output in the DEST_DIR +# Define the GNU programs that we are testing against. #################### -DFIND_FIND_OUT=${DFIND_DEST_DIR}/${TEST_PREFIX}_dfind_find_out.txt +GFIND=$(which ${GNU_FIND_BIN}) #################### -# Define the GNU programs that we are testing against. +# Where we will put the output data #################### -GNU_FIND_BIN=$(which find) -GNU_FIND_OUT=${DFIND_DEST_DIR}/${TEST_PREFIX}_gnu_find_out.txt +DFIND_OUT=${DESTDIR}/${TEST_PREFIX}_dfind_find_out.txt +GFIND_OUT=${DESTDIR}/${TEST_PREFIX}_gnu_find_out.txt +DFIND_CMP_RESULT=${DESTDIR}/${TEST_PREFIX}_cmp_result.txt #################### # The verbose name of this test. We had to wait until here so that # the binaries are named. #################### -DFIND_TEST_NAME="Test ${DFIND_TEST_NUMBER} --> ${DFIND_TEST_BIN} vs. ${GNU_FIND_BIN} \r\n -Test ${DFIND_TEST_NUMBER} --> $(basename ${DFIND_TEST_BIN}) vs. $(basename ${GNU_FIND_BIN})\r\n -for dfind --exec {} substitution of\r\n -file names containing spaces\r\n" +DFIND_TEST_NAME="Test ${DFIND_TEST_NUMBER} --> ${DFIND} vs. ${GFIND} \r\n +Test ${DFIND_TEST_NUMBER} --> $(basename ${DFIND}) vs. $(basename ${GFIND})\r\n +for dfind --exec {} substitution of file names containing spaces\r\n" #################### # Confirm that we were passed the right information #################### if [ $DFIND_TEST_VERBOSE -gt 0 ] then - echo -e "Using dfind binary at:\t\t${DFIND_TEST_BIN}" - echo -e "Using mpirun binary at:\t\t${DFIND_MPIRUN_BIN}" - echo -e "Using cmp binary at:\t\t${DFIND_CMP_BIN}" + echo -e "Using dfind binary at:\t\t${DFIND}" + echo -e "Using mpirun binary at:\t\t${MPIRUN}" + echo -e "Using cmp binary at:\t\t${CMP}" #################### # This helps to confirm that the comparison test is from GNU #################### - strings ${DFIND_CMP_BIN} | egrep '^GNU' - echo -e "Using src directory at:\t\t${DFIND_SRC_DIR}" - echo -e "Using dest directory at:\t${DFIND_DEST_DIR}" - echo -e "Using tmp file at:\t\t${DFIND_TMP_FILE}" - echo -e "Using testing bin dir at:\t${DFIND_TESTING_BIN_DIR}" - echo -e "Comparison test against:\t${GNU_FIND_BIN}" + strings ${CMP} | egrep '^GNU' + echo -e "Using src directory at:\t\t${SRCDIR}" + echo -e "Using dest directory at:\t${DESTDIR}" + echo -e "Using tmp file at:\t\t${TMPFILE}" + echo -e "Using testing bin dir at:\t${TESTBINDIR}" + echo -e "Comparison test against:\t${GFIND}" echo -e "Test Prefix:\t\t${TEST_PREFIX}" echo -e "Test Name: ${DFIND_TEST_NAME}" #################### # This helps to confirm that the comparison is against the GNU version #################### - strings ${GNU_FIND_BIN} | egrep "^GNU" + strings ${GFIND} | egrep "^GNU" fi +################################################################################ +#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +# +# Everything up to here has been a preamble. Here is where we construct the +# test data to perform the test. +# +################################################################################ +################################################################################ #################### # Construct the test case # Create a file name with no spaces #################### -echo "A file with no spaces in the name" > ${DFIND_SRC_DIR}/A_file_with_no_spaces_in_the_name -echo "A file with spaces in the name" > "${DFIND_SRC_DIR}/A_file_with spaces_in_the_name" +echo "A file with no spaces in the name" > ${SRCDIR}/A_file_with_no_spaces_in_the_name +echo "A file with spaces in the name" > "${SRCDIR}/A_file_with spaces_in_the_name" #################### # Test the GNU find in single mode #################### if [ ${DFIND_TEST_VERBOSE} -gt 0 ] then - echo "find ${DFIND_SRC_DIR} -exec ls {}a 2>> ${GNU_FIND_OUT}.err ';' > ${GNU_FIND_OUT}" + echo "${GFIND} ${SRCDIR} -exec ls {}a 2>> ${GFIND_OUT}.err ';' > ${GFIND_OUT}" fi -find ${DFIND_SRC_DIR} -exec ls {}a 2>> ${GNU_FIND_OUT}.err ';' > ${GNU_FIND_OUT} +${GFIND} ${SRCDIR} -exec ls {}a 2>> ${GFIND_OUT}.err ';' > ${GFIND_OUT} + #################### # Test the HPC find in single mode #################### if [ ${DFIND_TEST_VERBOSE} -gt 0 ] then -# echo "${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {} ';' > ${DFIND_FIND_OUT}" - echo "#!/bin/bash > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" - echo "${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {}a 2>> ${DFIND_FIND_OUT}.err ';' 2>&1 >> ${DFIND_FIND_OUT} > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" - echo "chmod +x ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" - echo "# ${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE}" +# echo "${MPIRUN} -n 1 ${DFIND} ${SRCDIR} --exec ls {} ';' > ${DFIND_OUT}" + echo "#!/bin/bash > ${TESTBINDIR}/${TMPFILE}" + echo "${DFIND} ${SRCDIR} --exec ls {}a 2>> ${DFIND_OUT}.err ';' 2>&1 >> ${DFIND_OUT} > ${TESTBINDIR}/${TMPFILE}" + echo "chmod +x ${TESTBINDIR}/${TMPFILE}" + echo "# ${MPIRUN} -n 1 ${TESTBINDIR}/${TMPFILE}" fi -echo "#!/bin/bash" > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} -echo "${DFIND_TEST_BIN} ${DFIND_SRC_DIR} --exec ls {}a 2>> ${DFIND_FIND_OUT}.err ';' 2>&1 >> ${DFIND_FIND_OUT}" > ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} -chmod +x ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +echo "#!/bin/bash" > ${TESTBINDIR}/${TMPFILE} +echo "${DFIND} ${SRCDIR} --exec ls {}a 2>> ${DFIND_OUT}.err ';' 2>&1 >> ${DFIND_OUT}" > ${TESTBINDIR}/${TMPFILE} +chmod +x ${TESTBINDIR}/${TMPFILE} -# ${DFIND_MPIRUN_BIN} -n 1 ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} -/bin/bash ${DFIND_TESTING_BIN_DIR}/${DFIND_TMP_FILE} +# ${MPIRUN} -n 1 ${TESTBINDIR}/${TMPFILE} +/bin/bash ${TESTBINDIR}/${TMPFILE} #################### # Compare the result files. #################### if [ ${DFIND_TEST_VERBOSE} -gt 0 ] then - echo "${DFIND_CMP_BIN} ${GNU_FIND_OUT} ${DFIND_FIND_OUT} 2>&1 > ${DFIND_CMP_RESULT}" + echo "${CMP} ${GFIND_OUT} ${DFIND_OUT} 2>&1 > ${DFIND_CMP_RESULT}" fi -${DFIND_CMP_BIN} ${GNU_FIND_OUT} ${DFIND_FIND_OUT} 2>&1 > ${DFIND_CMP_RESULT} +${CMP} ${GFIND_OUT} ${DFIND_OUT} 2>&1 > ${DFIND_CMP_RESULT} if [ $? -ne 0 ] then echo -e "FAILURE: $DFIND_TEST_NAME" echo "RESULT:" - cat ${DFIND_CMP_RESULT} ${GNU_FIND_OUT}.err ${DFIND_FIND_OUT}.err + cat ${DFIND_CMP_RESULT} ${GFIND_OUT}.err ${DFIND_OUT}.err else #################### # Only report success in verbose mode From 63276185834c5944a62cc0105f8c5c2d1665d227 Mon Sep 17 00:00:00 2001 From: Robert Eustace Novak Date: Mon, 6 Jan 2020 11:49:37 -0800 Subject: [PATCH 3/5] Testing for Issue 311 Testing for Issue #311 Using the parameters from test_dcp/test_fiemap.sh as a starting point. The test template uses a makefile to harness the tests. Two Tests implemented: 1) Test for the correct handling of hpc dfind vs. GNU find for having blanks in file names when passing files to --exec. Only a single thread is needed to illustrate the error. 2) Test that illustrates that stderr redirection is incorrect for hpc dfind vs. GNU find. This will later be reported as a separate issue and the second test will be placed on a branch to repair that issue. Binaries under test are found in mpifileutils/../install (per normal build). Test scripts, source and destination files under ../test, e.g. ../test/bin for scripts/binaries ../test/src for test inputs ../test/dest for test output The test harness scripts accept the following parameters: -DFIND_TEST_BIN - the hpc binary under test, found in mpifileutils/../install -DFIND_MPIRUN_BIN - for mpirun vs. srun -DFIND_CMP_BIN - for the result comparison program (e.g. diff) -DFIND_SRC_DIR - for the test input files -DFIND_DEST_DIR - for the test output files -DFIND_TMP_FILE - in this case for the constructed script file -DFIND_TESTING_BIN_DIR - for the directory where test executables and scripts are placed -DFIND_TEST_NUMBER - The test number so we can re-sequence testing -GNU_FIND_BIN - The GNU binary that we use for comparison --- test/tests/test_dfind/getgitroot.sh | 15 ------- test/tests/test_dfind/makefile | 66 +++++++++++++++-------------- 2 files changed, 35 insertions(+), 46 deletions(-) delete mode 100644 test/tests/test_dfind/getgitroot.sh diff --git a/test/tests/test_dfind/getgitroot.sh b/test/tests/test_dfind/getgitroot.sh deleted file mode 100644 index b357957a9..000000000 --- a/test/tests/test_dfind/getgitroot.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -#################### -# Author: Robert E. Novak -# email: novak5@llnl.gov -# -# Find and return the parent directory that contains ".git" -# -# That is the parent directory that is the "root" of all evil so that we can -# execute binaries located in ../install/bin -#################### -while [ ! -d .git ] -do - cd .. -done -pwd diff --git a/test/tests/test_dfind/makefile b/test/tests/test_dfind/makefile index b3febdb7e..6bc211935 100644 --- a/test/tests/test_dfind/makefile +++ b/test/tests/test_dfind/makefile @@ -2,14 +2,14 @@ SHELL=/bin/bash .sh: cp $? `basename $? .sh` chmod +x `basename $? .sh` - +.ONESHELL #################### # Perform testing of the dfind command # Tests will be numbered and will report both # the command name and the number as part of the # diagnostic output. #################### -PROJECTROOT := $(shell bash ./getgitroot.sh) +PROJECTROOT=$(shell git rev-parse --git-dir)/.. #################### # Define all of the hpc FIND command variables that come in from the @@ -30,8 +30,10 @@ PROJECTROOT := $(shell bash ./getgitroot.sh) # ../test/dest . The directory relative to mpifileutils where test # output is placed # DFIND_DEST_DIR -# dfind.test.sh The shell script generated inside this script to perform -# the testing. +# dfind.test.sh The shell script installed inside this script to perform +# the testing. These scripts are found in the same directory +# as the make file and are copied into the ../test/bin +# directory to provide an actual test script. # DFIND_TMP_FILE # ../test/bin .. the directory in which executable files (including this # script and the generated script) are placed to avoid @@ -53,35 +55,33 @@ PROJECTROOT := $(shell bash ./getgitroot.sh) # # To facilitate finding the root of the project from within the directory # where you run the tests (the above was done to keep from cluttering this -# directory as well), there is a short script "getgitroot" which determines -# the project root directory by walking up the tree to find the .git -# directory: -# Find and return the parent directory that contains ".git" -# -# That is the parent directory that is the "root" of all evil so that we can -# execute binaries located in ../install/bin +# directory as well), we use the "git rev-parse --git-dir" to find the .git +# root directory: #################### -# while [ ! -d .git ] -# do -# cd .. -# done -# pwd -#################### -DFIND_INSTALL_DIR := $(PROJECTROOT)/../install/bin -DFIND_TEST_BIN := $(DFIND_INSTALL_DIR)/dfind -DFIND_MPIRUN_BIN := $(shell which srun) -DFIND_CMP_BIN := $(shell which diff) -DFIND_SRC_DIR := $(PROJECTROOT)/../test/src -DFIND_DEST_DIR := $(PROJECTROOT)/../test/dest -DFIND_TMP_FILE := dfind_test.sh -DFIND_TESTING_BIN_DIR := $(PROJECTROOT)/../test/bin +DFIND_INSTALL_DIR?=$(PROJECTROOT)/../install/bin +DFIND_TEST_BIN?=$(DFIND_INSTALL_DIR)/dfind +DFIND_MPIRUN_BIN?=$(shell which srun) +DFIND_CMP_BIN?=$(shell which diff) +DFIND_SRC_DIR?=$(PROJECTROOT)/../test/src +DFIND_DEST_DIR?=$(PROJECTROOT)/../test/dest +DFIND_TMP_FILE?=dfind_test.sh +DFIND_TESTING_BIN_DIR?=$(PROJECTROOT)/../test/bin +GNU_FIND?=find +VERBOSE?=1 +#################### +# At first blush it may seem redundant to pass in the test name... +# until you have to re-order the testing sequence +#################### TEST-01 := test_dfind_spaces -TEST-02 := test_dfind_exec_stderr_redirect +TEST-01_Number := 01 DFIND_TEST_NUM-01 := $(DFIND_TESTING_BIN_DIR)/$(TEST-01) + +TEST-02 := test_dfind_exec_stderr_redirect +TEST-02_Number := 02 DFIND_TEST_NUM-02 := $(DFIND_TESTING_BIN_DIR)/$(TEST-02) -TESTS = getgitroot $(TEST-01) $(TEST-02) +TESTS = $(TEST-01) $(TEST-02) .PHONY: all clean install uninstall run run1 run2 @@ -107,11 +107,15 @@ run: run1 run2 run1: install $(DFIND_TEST_NUM-01) $(DFIND_TEST_BIN) rm -rf ${DFIND_SRC_DIR} ${DFIND_DEST_DIR} mkdir -p $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TESTING_BIN_DIR) - $(DFIND_TEST_NUM-01) $(DFIND_TEST_BIN) $(DFIND_MPIRUN_BIN) $(DFIND_CMP_BIN) \ - $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TMP_FILE) $(DFIND_TESTING_BIN_DIR) + DFIND_TEST_VERBOSE=$(VERBOSE) $(DFIND_TEST_NUM-01) $(DFIND_TEST_BIN) \ + $(DFIND_MPIRUN_BIN) $(DFIND_CMP_BIN) $(DFIND_SRC_DIR) \ + $(DFIND_DEST_DIR) $(DFIND_TMP_FILE) \ + $(DFIND_TESTING_BIN_DIR) $(TEST-01_Number) $(GNU_FIND) run2: install $(DFIND_TEST_NUM-02) $(DFIND_TEST_BIN) rm -rf ${DFIND_SRC_DIR} ${DFIND_DEST_DIR} mkdir -p $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TESTING_BIN_DIR) - $(DFIND_TEST_NUM-02) $(DFIND_TEST_BIN) $(DFIND_MPIRUN_BIN) $(DFIND_CMP_BIN) \ - $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TMP_FILE) $(DFIND_TESTING_BIN_DIR) + DFIND_TEST_VERBOSE=$(VERBOSE) $(DFIND_TEST_NUM-02) $(DFIND_TEST_BIN) \ + $(DFIND_MPIRUN_BIN) $(DFIND_CMP_BIN) $(DFIND_SRC_DIR) \ + $(DFIND_DEST_DIR) $(DFIND_TMP_FILE) \ + $(DFIND_TESTING_BIN_DIR) $(TEST-02_Number) $(GNU_FIND) # vim: set syntax=makefile,sw=4,t=4 From 133d3dfd45ac4b110aad8c6dcfea0731f9e0a490 Mon Sep 17 00:00:00 2001 From: Robert Eustace Novak Date: Tue, 7 Jan 2020 14:38:23 -0800 Subject: [PATCH 4/5] Use strings to make sure we have the GNU... Use the strings command to insure that we have the GNU version of the find command to test against. Also verify that the diff command came from GNU as well. --- test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh | 6 +++--- test/tests/test_dfind/test_dfind_spaces.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh b/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh index 5e59d7936..17d2bdbf4 100644 --- a/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh +++ b/test/tests/test_dfind/test_dfind_exec_stderr_redirect.sh @@ -131,7 +131,7 @@ then #################### # This helps to confirm that the comparison test is from GNU #################### - strings ${CMP} | egrep '^GNU' + strings ${CMP} | egrep '^GNU ' echo -e "Using src directory at:\t\t${SRCDIR}" echo -e "Using dest directory at:\t${DESTDIR}" echo -e "Using tmp file at:\t\t${TMPFILE}" @@ -142,7 +142,7 @@ then #################### # This helps to confirm that the comparison is against the GNU version #################### - strings ${GFIND} | egrep "^GNU" + strings ${GFIND} | egrep '^GNU ' fi ################################################################################ @@ -151,7 +151,7 @@ fi # Everything up to here has been a preamble. Here is where we construct the # test data to perform the test. # -################################################################################ +#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ################################################################################ #################### # Construct the test case diff --git a/test/tests/test_dfind/test_dfind_spaces.sh b/test/tests/test_dfind/test_dfind_spaces.sh index a3792cda3..6f3cd36be 100644 --- a/test/tests/test_dfind/test_dfind_spaces.sh +++ b/test/tests/test_dfind/test_dfind_spaces.sh @@ -131,7 +131,7 @@ then #################### # This helps to confirm that the comparison test is from GNU #################### - strings ${CMP} | egrep '^GNU' + strings ${CMP} | egrep '^GNU ' echo -e "Using src directory at:\t\t${SRCDIR}" echo -e "Using dest directory at:\t${DESTDIR}" echo -e "Using tmp file at:\t\t${TMPFILE}" @@ -142,7 +142,7 @@ then #################### # This helps to confirm that the comparison is against the GNU version #################### - strings ${GFIND} | egrep "^GNU" + strings ${GFIND} | egrep '^GNU ' fi ################################################################################ @@ -151,7 +151,7 @@ fi # Everything up to here has been a preamble. Here is where we construct the # test data to perform the test. # -################################################################################ +#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ################################################################################ #################### # Construct the test case From 444ee150027e9b4886145bcc15e35719f27d82c7 Mon Sep 17 00:00:00 2001 From: Robert Eustace Novak Date: Tue, 7 Jan 2020 14:40:09 -0800 Subject: [PATCH 5/5] Testing for Issue #311 Using the parameters from test_dcp/test_fiemap.sh as a starting point. The test template uses a makefile to harness the tests. Two Tests implemented: 1) Test for the correct handling of hpc dfind vs. GNU find for having blanks in file names when passing files to --exec. Only a single thread is needed to illustrate the error. 2) Test that illustrates that stderr redirection is incorrect for hpc dfind vs. GNU find. This will later be reported as a separate issue and the second test will be placed on a branch to repair that issue. Binaries under test are found in mpifileutils/../install (per normal build). Test scripts, source and destination files under ../test, e.g. ../test/bin for scripts/binaries ../test/src for test inputs ../test/dest for test output The test harness scripts accept the following parameters: -DFIND_TEST_BIN - the hpc binary under test, found in mpifileutils/../install -DFIND_MPIRUN_BIN - for mpirun vs. srun -DFIND_CMP_BIN - for the result comparison program (e.g. diff) -DFIND_SRC_DIR - for the test input files -DFIND_DEST_DIR - for the test output files -DFIND_TMP_FILE - in this case for the constructed script file -DFIND_TESTING_BIN_DIR - for the directory where test executables and scripts are placed -DFIND_TEST_NUMBER - The test number so we can re-sequence testing -GNU_FIND_BIN - The GNU binary that we use for comparison --- test/tests/test_dfind/makefile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/tests/test_dfind/makefile b/test/tests/test_dfind/makefile index 6bc211935..934d7dcae 100644 --- a/test/tests/test_dfind/makefile +++ b/test/tests/test_dfind/makefile @@ -2,7 +2,7 @@ SHELL=/bin/bash .sh: cp $? `basename $? .sh` chmod +x `basename $? .sh` -.ONESHELL +.ONESHELL: #################### # Perform testing of the dfind command # Tests will be numbered and will report both @@ -27,6 +27,14 @@ PROJECTROOT=$(shell git rev-parse --git-dir)/.. # ../test/src .. the directory relative to mpifileutils where source # test data is place # DFIND_SRC_DIR +# +# Using the parameters from test_dcp/test_fiemap.sh as a starting point. +# The test template uses a makefile to harness the tests. +# +# Two Tests implemented: +# +# 1) Test for the correct handling of hpc dfind vs. GNU find for having blanks in file names when passing files to --exec. +# 2) Test that illustrates that stderr redirection is incorrect for hpc dfind vs. GNU find. This will later be reported as a separate issue and the second test will be placed on a branch to repair that issue. # ../test/dest . The directory relative to mpifileutils where test # output is placed # DFIND_DEST_DIR @@ -110,12 +118,16 @@ run1: install $(DFIND_TEST_NUM-01) $(DFIND_TEST_BIN) DFIND_TEST_VERBOSE=$(VERBOSE) $(DFIND_TEST_NUM-01) $(DFIND_TEST_BIN) \ $(DFIND_MPIRUN_BIN) $(DFIND_CMP_BIN) $(DFIND_SRC_DIR) \ $(DFIND_DEST_DIR) $(DFIND_TMP_FILE) \ - $(DFIND_TESTING_BIN_DIR) $(TEST-01_Number) $(GNU_FIND) + $(DFIND_TESTING_BIN_DIR) $(TEST-01_Number) \ + $(GNU_FIND) 2>&1 | \ + tee $(DFIND_DEST_DIR)/result-$(TEST-01_Number)_$(TEST-01) run2: install $(DFIND_TEST_NUM-02) $(DFIND_TEST_BIN) rm -rf ${DFIND_SRC_DIR} ${DFIND_DEST_DIR} mkdir -p $(DFIND_SRC_DIR) $(DFIND_DEST_DIR) $(DFIND_TESTING_BIN_DIR) DFIND_TEST_VERBOSE=$(VERBOSE) $(DFIND_TEST_NUM-02) $(DFIND_TEST_BIN) \ $(DFIND_MPIRUN_BIN) $(DFIND_CMP_BIN) $(DFIND_SRC_DIR) \ $(DFIND_DEST_DIR) $(DFIND_TMP_FILE) \ - $(DFIND_TESTING_BIN_DIR) $(TEST-02_Number) $(GNU_FIND) + $(DFIND_TESTING_BIN_DIR) $(TEST-02_Number) \ + $(GNU_FIND) 2>&1 | \ + tee $(DFIND_DEST_DIR)/result-$(TEST-02)_$(TEST-02) # vim: set syntax=makefile,sw=4,t=4