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: Michal Berger <michalx.berger@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/456 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
1fd3d8e994
commit
83086b5973
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user