Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
CORTX-30751: Codacy code cleanup (#1606)
Browse files Browse the repository at this point in the history
This patch fixes some of the codacy warnings.
warning fixed : "Double quote to prevent globing and words splitting".

Signed-off-by: alfhad <fahadshah2411@gmail.com>
  • Loading branch information
alfhad committed Aug 22, 2022
1 parent 882a3a0 commit 8623783
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions spiel/st/m0t1fs_spiel_st.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ error() { echo "$@" >&2; stop 1; }
M0_SRC_DIR=`readlink -f $0`
M0_SRC_DIR=${M0_SRC_DIR%/*/*/*}

. $M0_SRC_DIR/utils/functions # die, sandbox_init, report_and_exit
. "$M0_SRC_DIR"/utils/functions # die, sandbox_init, report_and_exit

## Path to the file with configuration string for confd.
CONF_FILE=$SANDBOX_DIR/confd/conf.txt
Expand All @@ -61,14 +61,14 @@ if spiel.rconfc_start():
sys.exit('cannot start rconfc')"

iosloopdevs() {
cat > $CONF_DRIVES << EOF
cat > "$CONF_DRIVES" << EOF
Device:
EOF
for i in $(seq $DEV_NR); do
dd if=/dev/zero of=$SANDBOX_DIR/${i}.img bs=$DEV_SIZE seek=$DEV_SIZE count=1
losetup -d /dev/loop$i &> /dev/null || true
losetup /dev/loop$i $SANDBOX_DIR/${i}.img
cat >> $CONF_DRIVES << EOF
dd if=/dev/zero of="$SANDBOX_DIR"/"${i}".img bs=$DEV_SIZE seek=$DEV_SIZE count=1
losetup -d "/dev/loop$i" &> /dev/null || true
losetup "/dev/loop$i" "$SANDBOX_DIR"/"${i}".img
cat >> "$CONF_DRIVES" << EOF
- id: $i
filename: /dev/loop$i
EOF
Expand All @@ -77,7 +77,7 @@ EOF

start() {
# install "motr" Python module required by m0spiel tool
cd $M0_SRC_DIR/utils/spiel
cd "$M0_SRC_DIR"/utils/spiel
python3 setup.py install --record $INSTALLED_FILES > /dev/null ||
die 'Cannot install Python "motr" module'
sandbox_init
Expand All @@ -89,7 +89,7 @@ stop() {
local rc=${1:-$?}

trap - EXIT
if mount | grep -q m0t1fs; then umount $SANDBOX_DIR/mnt; fi
if mount | grep -q m0t1fs; then umount "$SANDBOX_DIR"/mnt; fi

pkill m0d && wait || rc=$?
_fini
Expand All @@ -104,18 +104,18 @@ stop() {
_init() {
lnet_up
m0_modules_insert
mkdir -p $SANDBOX_DIR/mnt
mkdir -p $SANDBOX_DIR/confd
mkdir -p $SANDBOX_DIR/systest-$$
mkdir -p "$SANDBOX_DIR"/mnt
mkdir -p "$SANDBOX_DIR"/confd
mkdir -p "$SANDBOX_DIR"/systest-$$
iosloopdevs
}

_fini() {
for i in $(seq $DEV_NR); do
losetup -d /dev/loop$i
losetup -d /dev/loop"$i"
done
m0_modules_remove
cd $M0_SRC_DIR/utils/spiel
cd "$M0_SRC_DIR"/utils/spiel
cat $INSTALLED_FILES | xargs rm -rf
rm -rf build/ $INSTALLED_FILES
}
Expand Down Expand Up @@ -212,17 +212,17 @@ m0d_with_rms_start() {
local FI_OPTS="m0_ha_msg_accept:invalid_confc:always"
local M0D_OPTS="$OPTS -o $FI_OPTS"

stub_confdb | $M0_SRC_DIR/utils/m0confgen >$CONF_FILE
stub_confdb | "$M0_SRC_DIR"/utils/m0confgen >"$CONF_FILE"

echo "--- `date` ---" >>$path/m0d.log
cd $path
echo "--- `date` ---" >>"$path"/m0d.log
cd "$path"

echo $M0_SRC_DIR/utils/mkfs/m0mkfs $OPTS
$M0_SRC_DIR/utils/mkfs/m0mkfs $OPTS >>$path/mkfs.log ||
echo "$M0_SRC_DIR"/utils/mkfs/m0mkfs $OPTS
"$M0_SRC_DIR"/utils/mkfs/m0mkfs $OPTS >>"$path"/mkfs.log ||
error 'm0mkfs failed'

echo $M0_SRC_DIR/motr/m0d $M0D_OPTS
$M0_SRC_DIR/motr/m0d $M0D_OPTS >>$path/m0d.log 2>&1 &
echo "$M0_SRC_DIR"/motr/m0d "$M0D_OPTS"
"$M0_SRC_DIR"/motr/m0d "$M0D_OPTS" >>"$path"/m0d.log 2>&1 &
local PID=$!
sleep 10
kill -0 $PID 2>/dev/null ||
Expand All @@ -237,10 +237,10 @@ test_m0mkfs() {
-m $MAX_RPC_MSG_SIZE -q $TM_MIN_RECV_QUEUE_LEN -w 3 \
-f $PROC_FID2 -d $CONF_DRIVES -H $M0D2_ENDPOINT"

cd $path
cd "$path"

echo $M0_SRC_DIR/utils/mkfs/m0mkfs $OPTS
$M0_SRC_DIR/utils/mkfs/m0mkfs $OPTS >>$path/mkfs.log ||
echo "$M0_SRC_DIR"/utils/mkfs/m0mkfs "$OPTS"
"$M0_SRC_DIR"/utils/mkfs/m0mkfs "$OPTS" >>"$path"/mkfs.log ||
error 'm0mkfs failed'
}

Expand All @@ -252,10 +252,10 @@ test_m0d_start() {
-m $MAX_RPC_MSG_SIZE -q $TM_MIN_RECV_QUEUE_LEN -w 3 \
-f $PROC_FID2 -d $CONF_DRIVES -H $M0D2_ENDPOINT"

cd $path
cd "$path"

echo $M0_SRC_DIR/motr/m0d $OPTS
$M0_SRC_DIR/motr/m0d $OPTS >>$path/m0d.log 2>&1 &
echo "$M0_SRC_DIR"/motr/m0d "$OPTS"
"$M0_SRC_DIR"/motr/m0d "$OPTS" >>"$path"/m0d.log 2>&1 &
local PID=$!
sleep 10
kill -0 $PID 2>/dev/null ||
Expand Down Expand Up @@ -332,7 +332,7 @@ HEALTH_GOOD, HEALTH_BAD, HEALTH_INACTIVE, HEALTH_UNKNOWN = range(4)
}

construct_db() {
$M0_SRC_DIR/utils/spiel/m0spiel $M0_SPIEL_OPTS <<EOF
"$M0_SRC_DIR"/utils/spiel/m0spiel "$M0_SPIEL_OPTS" <<EOF
$FIDS_LIST
N, K, S, P = 2, 1, 1, 4
mask = c_uint64(3)
Expand Down Expand Up @@ -447,7 +447,7 @@ EOF

validate_health() {
say 'Validate health'
$M0_SRC_DIR/utils/spiel/m0spiel $M0_SPIEL_OPTS <<EOF
"$M0_SRC_DIR"/utils/spiel/m0spiel "$M0_SPIEL_OPTS" <<EOF
$FIDS_LIST
$SERVICES
$HEALTH
Expand All @@ -469,7 +469,7 @@ EOF
}

restart_services() {
$M0_SRC_DIR/utils/spiel/m0spiel $M0_SPIEL_OPTS <<EOF
"$M0_SRC_DIR"/utils/spiel/m0spiel "$M0_SPIEL_OPTS" <<EOF
$FIDS_LIST
$SERVICES
Expand All @@ -494,7 +494,7 @@ EOF
}

reconfig_process() {
$M0_SRC_DIR/utils/spiel/m0spiel $M0_SPIEL_OPTS <<EOF
"$M0_SRC_DIR"/utils/spiel/m0spiel "$M0_SPIEL_OPTS" <<EOF
$FIDS_LIST
$PYTHON_BOILERPLATE
Expand All @@ -511,16 +511,16 @@ perform_io() {
local TEST_STR="Hello world"
local TEST_FILE=$SANDBOX_DIR/mnt/file.txt

ls $SANDBOX_DIR/mnt
touch $TEST_FILE || die "m0t1fs: Can't touch file"
setfattr -n lid -v 5 $TEST_FILE || die "m0t1fs: Can't set an attribute"
dd if=/dev/zero of=$TEST_FILE bs=1M count=10
echo $TEST_STR > $TEST_FILE || die "m0t1fs: Can't write to file"
[ "`cat $TEST_FILE`" == "$TEST_STR" ] || die "IO error"
ls "$SANDBOX_DIR"/mnt
touch "$TEST_FILE" || die "m0t1fs: Can't touch file"
setfattr -n lid -v 5 "$TEST_FILE" || die "m0t1fs: Can't set an attribute"
dd if=/dev/zero of="$TEST_FILE" bs=1M count=10
echo "$TEST_STR" > "$TEST_FILE" || die "m0t1fs: Can't write to file"
[ "`cat "$TEST_FILE"`" == "$TEST_STR" ] || die "IO error"
}

fs_stats_fetch() {
$M0_SRC_DIR/utils/spiel/m0spiel $M0_SPIEL_OPTS <<EOF
"$M0_SRC_DIR"/utils/spiel/m0spiel "$M0_SPIEL_OPTS" <<EOF
$FIDS_LIST
$PYTHON_BOILERPLATE
Expand All @@ -543,11 +543,11 @@ _mount() {
local MOUNT_OPTS="-t m0t1fs -o pfid=<0x7200000000000001:1>,profile=$PROF_OPT,ha=$M0D2_ENDPOINT \
none $SANDBOX_DIR/mnt"
echo "mount $MOUNT_OPTS"
mount $MOUNT_OPTS || return $?
mount "$MOUNT_OPTS" || return $?
}

device_commands_check() {
$M0_SRC_DIR/utils/spiel/m0spiel $M0_SPIEL_OPTS <<EOF
"$M0_SRC_DIR"/utils/spiel/m0spiel "$M0_SPIEL_OPTS" <<EOF
$FIDS_LIST
$PYTHON_BOILERPLATE
Expand All @@ -568,7 +568,7 @@ EOF
}

## Keep the audience engaged.
say() { echo "$@" | tee -a $SANDBOX_DIR/confd/m0d.log; }
say() { echo "$@" | tee -a "$SANDBOX_DIR"/confd/m0d.log; }

usage() {
cat <<EOF
Expand Down Expand Up @@ -638,7 +638,7 @@ reconfig_process || stop

say "Wait for reconfigure"
sleep 10
grep -q "Restarting" $SANDBOX_DIR/systest-$$/m0d.log ||
grep -q "Restarting" "$SANDBOX_DIR"/systest-$$/m0d.log ||
die "Reconfigure is not finished"
validate_health || stop

Expand Down

0 comments on commit 8623783

Please sign in to comment.