Commit 83086b59 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

test/blobfs: Refactor exit behavior



The on_error_exit() function was being called via the local ERR trap
to cleanup after the tests in case any failure occurred during the
execution. However, this was masking the backtrace trap so the
on_error_exit() had to also call print_backtrace() to compensate -
this was resulting in an additional function being unnecessarily
placed onto the stack and included in the actual backtrace.

Avoid the above by refactoring on_error_exit() into simple cleanup()
function called upon exit()ing from the script. The rationale is that
cleanup has to happen regardless if the script failed or not and
elements like $conf_file are always created from the very scratch by
the script itself anyway prior running the tests.

Change-Id: I6bb8f4155525037624f0bd5aab288f8c502141f6
Signed-off-by: default avatarMichal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/456


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 1fd3d8e9
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -18,16 +18,14 @@ test_cache_size=512

source $rootdir/test/common/autotest_common.sh

function on_error_exit() {
	if [ -n "$blobfs_pid" ]; then
function cleanup() {
	if [[ -n $blobfs_pid && -e /proc/$blobfs_pid ]]; then
		killprocess $blobfs_pid
	fi

	rm -rf $mount_dir
	rm -f $tmp_file
	rm -f $conf_file
	print_backtrace
	exit 1
}

function blobfs_start_app {
@@ -122,7 +120,7 @@ function blobfs_fuse_test() {
	killprocess $blobfs_pid
}

trap 'on_error_exit;' ERR
trap 'cleanup' EXIT

# Create one temp file as test bdev
dd if=/dev/zero of=${tmp_file} bs=4k count=1M
@@ -139,7 +137,3 @@ blobfs_create_test
# Create dir for FUSE mount
mkdir -p $mount_dir
blobfs_fuse_test


rm -rf $mount_dir
rm -f $tmp_file