Skip to content

Commit 3f0c7bd

Browse files
committed
check: call fallback_device() in the same bash context
Currently, the callback function fallback_device() is called with bash $() feature. This runs the function call in a new bash context. Then, global variable changes in the function call are not reflected in the caller context. This is not handy and does not allow checking MODULES_TO_UNLOAD status change in the caller, which will be added in the following commit. To share the same bash context between the caller and the callee of fallback_device(), do not use $(). Instead, use a temporary file to keep the output of fallback_device(). Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent 1967331 commit 3f0c7bd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

check

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ _check_and_call_test_device() {
708708
local unset_skip_reason
709709
local ret=0
710710
local fallback=0
711+
local fb_dev_file
711712

712713
if declare -fF requires >/dev/null; then
713714
requires
@@ -726,10 +727,14 @@ _check_and_call_test_device() {
726727
return 0
727728
fi
728729

729-
if ! TEST_DEV=$(fallback_device); then
730+
# Use a tmp file to keep bash context in fallback_device
731+
fb_dev_file="${OUTPUT}/${TEST_NAME/\//_}_fallback_dev"
732+
if ! fallback_device > "$fb_dev_file"; then
730733
_warning "$TEST_NAME: fallback_device call failure"
731734
return 0
732735
fi
736+
TEST_DEV=$(<"$fb_dev_file")
737+
rm -f "$fb_dev_file"
733738

734739
if ! _find_sysfs_dirs "$TEST_DEV"; then
735740
_warning "$TEST_NAME: could not find sysfs directory for ${TEST_DEV}"

0 commit comments

Comments
 (0)