test/setup: Adjust use of nullglob, extglob in cleanup_linux()
Signed-off-by: Michal Berger <michal.berger@intel.com> Change-Id: I4e5a28f916c5855fefba8594d549b56c63d71013 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15094 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
8c19851209
commit
af5b654df8
@ -410,39 +410,37 @@ function configure_linux_pci() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_linux() {
|
function cleanup_linux() {
|
||||||
dirs_to_clean=""
|
local dirs_to_clean=() files_to_clean=() opened_files=() file_locks=()
|
||||||
dirs_to_clean="$(echo {/var/run,/tmp}/dpdk/spdk{,_pid}+([0-9])) "
|
local match_spdk="spdk_tgt|iscsi|vhost|nvmf|rocksdb|bdevio|bdevperf|vhost_fuzz|nvme_fuzz|accel_perf|bdev_svc"
|
||||||
if [[ -d $XDG_RUNTIME_DIR && $XDG_RUNTIME_DIR != *" "* ]]; then
|
|
||||||
dirs_to_clean+="$(readlink -e assert_not_empty $XDG_RUNTIME_DIR/dpdk/spdk{,_pid}+([0-9]) || true) "
|
dirs_to_clean=({/var/run,/tmp}/dpdk/spdk{,_pid}+([0-9]))
|
||||||
|
if [[ -d $XDG_RUNTIME_DIR ]]; then
|
||||||
|
dirs_to_clean+=("$XDG_RUNTIME_DIR/dpdk/spdk"{,_pid}+([0-9]))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
files_to_clean="" file_locks=()
|
for dir in "${dirs_to_clean[@]}"; do
|
||||||
for dir in $dirs_to_clean; do
|
files_to_clean+=("$dir/"*)
|
||||||
files_to_clean+="$(echo $dir/*) "
|
|
||||||
done
|
done
|
||||||
file_locks+=(/var/tmp/spdk_pci_lock*)
|
file_locks+=(/var/tmp/spdk_pci_lock*)
|
||||||
|
|
||||||
files_to_clean+="$(ls -1 /dev/shm/* \
|
files_to_clean+=(/dev/shm/@(@($match_spdk)_trace|spdk_iscsi_conns))
|
||||||
| grep -E '(spdk_tgt|iscsi|vhost|nvmf|rocksdb|bdevio|bdevperf|vhost_fuzz|nvme_fuzz|accel_perf|bdev_svc)_trace|spdk_iscsi_conns' || true) "
|
files_to_clean+=("${file_locks[@]}")
|
||||||
files_to_clean+=" ${file_locks[*]}"
|
if ((${#files_to_clean[@]} == 0)); then
|
||||||
files_to_clean="$(readlink -e assert_not_empty $files_to_clean || true)"
|
|
||||||
if [[ -z "$files_to_clean" ]]; then
|
|
||||||
echo "Clean"
|
echo "Clean"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for fd_dir in $(echo /proc/+([0-9])); do
|
opened_files+=($(readlink -f /proc/+([0-9])/fd/+([0-9])))
|
||||||
opened_files+="$(readlink -e assert_not_empty $fd_dir/fd/* || true)"
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -z "$opened_files" ]]; then
|
if ((${#opened_files[@]} == 0)); then
|
||||||
echo "Can't get list of opened files!"
|
echo "Can't get list of opened files!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo 'Cleaning'
|
echo 'Cleaning'
|
||||||
for f in $files_to_clean; do
|
for f in "${files_to_clean[@]}"; do
|
||||||
if ! echo "$opened_files" | grep -E -q "^$f\$"; then
|
[[ -e $f ]] || continue
|
||||||
|
if [[ ${opened_files[*]} != *"$f"* ]]; then
|
||||||
echo "Removing: $f"
|
echo "Removing: $f"
|
||||||
rm $f
|
rm $f
|
||||||
else
|
else
|
||||||
@ -450,8 +448,9 @@ function cleanup_linux() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for dir in $dirs_to_clean; do
|
for dir in "${dirs_to_clean[@]}"; do
|
||||||
if ! echo "$opened_files" | grep -E -q "^$dir\$"; then
|
[[ -d $dir ]] || continue
|
||||||
|
if [[ ${opened_files[*]} != *"$dir"* ]]; then
|
||||||
echo "Removing: $dir"
|
echo "Removing: $dir"
|
||||||
rmdir $dir
|
rmdir $dir
|
||||||
else
|
else
|
||||||
@ -459,8 +458,6 @@ function cleanup_linux() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "Clean"
|
echo "Clean"
|
||||||
|
|
||||||
unset dirs_to_clean files_to_clean opened_files
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_hugepages_alloc() {
|
check_hugepages_alloc() {
|
||||||
|
Loading…
Reference in New Issue
Block a user