[Ocfs2-tools-devel] [PATCH 1/3] Ocfs2-tests: Fix bugs when executing testing binaries as none-root user.
Tristan Ye
tristan.ye at oracle.com
Tue Oct 14 00:14:15 PDT 2008
Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
programs/xattr_tests/xattr-multi-run.sh | 68 +++++++++++++++---------------
programs/xattr_tests/xattr-single-run.sh | 24 ++++++++++-
2 files changed, 56 insertions(+), 36 deletions(-)
diff --git a/programs/xattr_tests/xattr-multi-run.sh b/programs/xattr_tests/xattr-multi-run.sh
index 39f0837..6abc707 100755
--- a/programs/xattr_tests/xattr-multi-run.sh
+++ b/programs/xattr_tests/xattr-multi-run.sh
@@ -21,11 +21,9 @@
PATH=$PATH:/sbin # Add /sbin to the path for ocfs2 tools
export PATH=$PATH:.
-MPI_RUN=`rpm -ql openmpi|grep bin|grep mpirun`
-MPI_BIN_PATH=`dirname ${MPI_RUN}`
-export PATH=$PATH:$MPI_BIN_PATH
+. ./config.sh
-MPIRUN_BIN="`which mpirun`"
+#MPIRUN="`which mpirun`"
RM="`which rm`"
MKDIR="`which mkdir`"
@@ -34,12 +32,16 @@ RSH_BIN="`which rsh`"
SSH_BIN="`which ssh`"
REMOTE_SH_BIN=${SSH_BIN}
+USERNAME=`/usr/bin/whoami`
+GROUPNAME=`id -gn`
+
+SUDO="`which sudo` -u root"
AWK_BIN="`which awk`"
TOUCH_BIN="`which touch`"
MOUNT_BIN="`which sudo` -u root `which mount`"
-REMOTE_MOUNT_BIN="`which sudo` -u root `which remote_mount.py`"
+REMOTE_MOUNT_BIN="`which remote_mount.py`"
UMOUNT_BIN="`which sudo` -u root `which umount`"
-REMOTE_UMOUNT_BIN="`which sudo` -u root `which remote_umount.py`"
+REMOTE_UMOUNT_BIN="`which remote_umount.py`"
MKFS_BIN="`which sudo` -u root `which mkfs.ocfs2`"
CHMOD_BIN="`which sudo` -u root `which chmod`"
CHOWN_BIN="`which sudo` -u root `which chown`"
@@ -109,8 +111,6 @@ echo_status()
echo
exit 1
fi
-
-
}
exit_or_not()
@@ -177,22 +177,16 @@ f_create_hostfile()
continue
fi
- echo "$line slots=2">>$MPI_HOSTFILE
+ echo "$line">>$MPI_HOSTFILE
done<$TMP_FILE
-
${RM} -rf $TMP_FILE
-
}
f_setup()
{
- rpm -q --quiet openmpi ||{
- echo "Need to install openmpi in advance"
- exit 1
- }
f_getoptions $*
@@ -204,8 +198,8 @@ f_setup()
if [ -z "${MOUNT_POINT}" ];then
f_usage
else
- if [ ! -d ${MOUNT_POINT} -o ! -w ${MOUNT_POINT} ]; then
- echo "Mount point ${MOUNT_POINT} does not exist or is not writable."
+ if [ ! -d ${MOUNT_POINT} ]; then
+ echo "Mount point ${MOUNT_POINT} does not exist."
exit 1
else
#To assure that mount point will not end with a trailing '/'
@@ -237,7 +231,7 @@ f_setup()
${CHMOD_BIN} -R 777 ${MOUNT_POINT}
- ${CHOWN_BIN} -R ${USER}:${USER} ${MOUNT_POINT}
+ ${CHOWN_BIN} -R ${USERNAME}:${GROUPNAME} ${MOUNT_POINT}
WORKPLACE="`dirname ${MOUNT_POINT}`/`basename ${MOUNT_POINT}`/multi_xattr_test_place"
@@ -267,6 +261,9 @@ f_do_mkfs_and_mount()
echo_status ${RET} |tee -a ${RUN_LOG_FILE}
exit_or_not ${RET}
+ ${SUDO} chown -R ${USERNAME}:${GROUPNAME} ${MOUNT_POINT}
+ ${SUDO} chmod -R 777 ${MOUNT_POINT}
+
${MKDIR} -p ${WORKPLACE} || exit 1
}
@@ -302,10 +299,10 @@ f_runtest()
do
for filetype in normal directory symlink
do
- echo -e "Testing Binary:\t\t${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 20 -n ${namespace} -t ${filetype} -l 50 -s 200 ${WORKPLACE}">>${LOG_FILE}
+ echo -e "Testing Binary:\t\t${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 20 -n ${namespace} -t ${filetype} -l 50 -s 200 ${WORKPLACE}">>${LOG_FILE}
echo "********${namespace} mode on ${filetype}********">>${LOG_FILE}
- ${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 20 -n ${namespace} -t ${filetype} -l 50 -s 200 ${WORKPLACE}>>${LOG_FILE} 2>&1
+ ${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 20 -n ${namespace} -t ${filetype} -l 50 -s 200 ${WORKPLACE}>>${LOG_FILE} 2>&1
rc=$?
if [ "$rc" != "0" ];then
if [ "$namespace" == "user" -a "$filetype" == "symlink" ]; then
@@ -343,8 +343,8 @@ f_runtest()
echo >>${LOG_FILE}
echo "==========================================================">>${LOG_FILE}
for((i=0;i<4;i++));do
- echo -e "Testing Binary:\t\t${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 10 -n user -t normal -l 50 -s 100 ${WORKPLACE}">>${LOG_FILE}
- ${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 10 -n user -t normal -l 50 -s 100 ${WORKPLACE}>>${LOG_FILE} 2>&1
+ echo -e "Testing Binary:\t\t${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 10 -n user -t normal -l 50 -s 100 ${WORKPLACE}">>${LOG_FILE}
+ ${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 10 -n user -t normal -l 50 -s 100 ${WORKPLACE}>>${LOG_FILE} 2>&1
rc=$?
if [ ! "$rc" == "0" ];then
echo_failure |tee -a ${RUN_LOG_FILE}
@@ -365,8 +365,8 @@ f_runtest()
echo -ne "Check Max Multinode Xattr EA_Name_Length:">> ${LOG_FILE}
echo >>${LOG_FILE}
echo "==========================================================">>${LOG_FILE}
- echo -e "Testing Binary:\t\t${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 4 -n user -t normal -l 255 -s 300 ${WORKPLACE}">>${LOG_FILE}
- ${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 4 -n user -t normal -l 255 -s 300 ${WORKPLACE}>>${LOG_FILE} 2>&1
+ echo -e "Testing Binary:\t\t${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 4 -n user -t normal -l 255 -s 300 ${WORKPLACE}">>${LOG_FILE}
+ ${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 4 -n user -t normal -l 255 -s 300 ${WORKPLACE}>>${LOG_FILE} 2>&1
RET=$?
echo_status ${RET} |tee -a ${RUN_LOG_FILE}
exit_or_not ${RET}
@@ -379,8 +379,8 @@ f_runtest()
echo -ne "Check Max Multinode Xattr EA_Size:">> ${LOG_FILE}
echo >>${LOG_FILE}
echo "==========================================================">>${LOG_FILE}
- echo -e "Testing Binary:\t\t${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1 -n user -t normal -l 50 -s 65536 ${WORKPLACE}">>${LOG_FILE}
- ${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1 -n user -t normal -l 50 -s 65536 ${WORKPLACE}>>${LOG_FILE} 2>&1
+ echo -e "Testing Binary:\t\t${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1 -n user -t normal -l 50 -s 65536 ${WORKPLACE}">>${LOG_FILE}
+ ${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1 -n user -t normal -l 50 -s 65536 ${WORKPLACE}>>${LOG_FILE} 2>&1
RET=$?
echo_status ${RET} |tee -a ${RUN_LOG_FILE}
exit_or_not ${RET}
@@ -393,8 +393,8 @@ f_runtest()
echo -ne "Check Huge Multinode Xattr EA_Entry_Nums:">> ${LOG_FILE}
echo >>${LOG_FILE}
echo "==========================================================">>${LOG_FILE}
- echo -e "Testing Binary:\t\t${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 10000 -n user -t normal -l 100 -s 200 ${WORKPLACE}">>${LOG_FILE}
- ${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 10000 -n user -t normal -l 100 -s 200 ${WORKPLACE}>>${LOG_FILE} 2>&1
+ echo -e "Testing Binary:\t\t${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 10000 -n user -t normal -l 100 -s 200 ${WORKPLACE}">>${LOG_FILE}
+ ${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 10000 -n user -t normal -l 100 -s 200 ${WORKPLACE}>>${LOG_FILE} 2>&1
RET=$?
echo_status ${RET} |tee -a ${RUN_LOG_FILE}
exit_or_not ${RET}
@@ -407,8 +407,8 @@ f_runtest()
echo -ne "Check All Max Multinode Xattr Arguments Together:">> ${LOG_FILE}
echo >>${LOG_FILE}
echo "==========================================================">>${LOG_FILE}
- echo -e "Testing Binary:\t\t${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1000 -n user -t normal -l 255 -s 65536 ${WORKPLACE}">>${LOG_FILE}
- ${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1000 -n user -t normal -l 255 -s 65536 ${WORKPLACE}>>${LOG_FILE} 2>&1
+ echo -e "Testing Binary:\t\t${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1000 -n user -t normal -l 255 -s 65536 ${WORKPLACE}">>${LOG_FILE}
+ ${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1000 -n user -t normal -l 255 -s 65536 ${WORKPLACE}>>${LOG_FILE} 2>&1
RET=$?
echo_status ${RET} |tee -a ${RUN_LOG_FILE}
exit_or_not ${RET}
@@ -421,8 +421,8 @@ f_runtest()
echo -ne "Launch Concurrent Adding Test:">> ${LOG_FILE}
echo >>${LOG_FILE}
echo "==========================================================">>${LOG_FILE}
- echo -e "Testing Binary:\t\t${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1000 -n user -t normal -l 255 -s 5000 -o -r -k ${WORKPLACE}">>${LOG_FILE}
- ${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1000 -n user -t normal -l 255 -s 5000 -o -r -k ${WORKPLACE}>>${LOG_FILE} 2>&1
+ echo -e "Testing Binary:\t\t${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1000 -n user -t normal -l 255 -s 5000 -o -r -k ${WORKPLACE}">>${LOG_FILE}
+ ${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 1000 -n user -t normal -l 255 -s 5000 -o -r -k ${WORKPLACE}>>${LOG_FILE} 2>&1
RET=$?
echo_status ${RET} |tee -a ${RUN_LOG_FILE}
exit_or_not ${RET}
@@ -435,8 +435,8 @@ f_runtest()
echo -ne "Launch MultiNode Xattr Stress Test:">> ${LOG_FILE}
echo >>${LOG_FILE}
echo "==========================================================">>${LOG_FILE}
- echo -e "Testing Binary:\t\t${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 2000 -n user -t normal -l 255 -s 5000 -r -k ${WORKPLACE}">>${LOG_FILE}
- ${MPIRUN_BIN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 2000 -n user -t normal -l 255 -s 5000 -r -k ${WORKPLACE}>>${LOG_FILE} 2>&1
+ echo -e "Testing Binary:\t\t${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 2000 -n user -t normal -l 255 -s 5000 -r -k ${WORKPLACE}">>${LOG_FILE}
+ ${MPIRUN} ${MPI_PLS_AGENT_ARG} -mca btl tcp,self -mca btl_tcp_if_include eth0 -np ${MPI_RANKS} --host ${MPI_HOSTS} ${XATTR_TEST_BIN} -i 1 -x 2000 -n user -t normal -l 255 -s 5000 -r -k ${WORKPLACE}>>${LOG_FILE} 2>&1
RET=$?
echo_status ${RET} |tee -a ${RUN_LOG_FILE}
exit_or_not ${RET}
diff --git a/programs/xattr_tests/xattr-single-run.sh b/programs/xattr_tests/xattr-single-run.sh
index 6371c8d..2ec4587 100755
--- a/programs/xattr_tests/xattr-single-run.sh
+++ b/programs/xattr_tests/xattr-single-run.sh
@@ -19,15 +19,21 @@
################################################################################
PATH=$PATH:/sbin # Add /sbin to the path for ocfs2 tools
export PATH=$PATH:.
+
GETXATTR="`which sudo` -u root `which getfattr`"
SETXATTR="`which sudo` -u root `which setfattr`"
+
+USERNAME=`/usr/bin/whoami`
+GROUPNAME=`id -gn`
+
+SUDO="`which sudo` -u root"
RM="`which rm`"
MKDIR="`which mkdir`"
TOUCH_BIN="`which touch`"
MOUNT_BIN="`which sudo` -u root `which mount`"
UMOUNT_BIN="`which sudo` -u root `which umount`"
MKFS_BIN="`which sudo` -u root `which mkfs.ocfs2`"
-XATTR_TEST_BIN=`which xattr-test`
+XATTR_TEST_BIN="`which xattr-test`"
DEFAULT_LOG="xattr-test-logs"
LOG_OUT_DIR=
@@ -145,6 +151,18 @@ f_setup()
if [ -z "${MOUNT_POINT}" ];then
f_usage
+ else
+ if [ ! -d ${MOUNT_POINT} ]; then
+ echo "Mount point ${MOUNT_POINT} does not exist."
+ exit 1
+ else
+ #To assure that mount point will not end with a trailing '/'
+ if [ "`dirname ${MOUNT_POINT}`" = "/" ]; then
+ MOUNT_POINT="`dirname ${MOUNT_POINT}``basename ${MOUNT_POINT}`"
+ else
+ MOUNT_POINT="`dirname ${MOUNT_POINT}`/`basename ${MOUNT_POINT}`"
+ fi
+ fi
fi
LOG_POSTFIX=$(date +%Y%m%d-%H%M%S)
@@ -178,6 +196,9 @@ f_do_mkfs_and_mount()
echo_status ${RET} |tee -a ${RUN_LOG_FILE}
exit_or_not ${RET}
+ ${SUDO} chown -R ${USERNAME}:${GROUPNAME} ${MOUNT_POINT}
+ ${SUDO} chmod -R 777 ${MOUNT_POINT}
+
${MKDIR} -p ${WORKPLACE} || exit 1
}
@@ -402,7 +423,6 @@ f_runtest()
exit_or_not ${RET}
${RM} -rf ${WORKPLACE}/* || exit 1
-
}
f_cleanup()
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list