From cd23cc61cad82645b89d56ef32ef439815dddc3b Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 14 Feb 2022 10:23:55 -0800 Subject: [PATCH] Add mount option test bash functions Add some test functions which work with mount options. Signed-off-by: Zach Brown --- tests/funcs/fs.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/funcs/fs.sh b/tests/funcs/fs.sh index b68bcfe7..3345688a 100644 --- a/tests/funcs/fs.sh +++ b/tests/funcs/fs.sh @@ -362,3 +362,49 @@ t_wait_for_leader() { done done } + +t_set_sysfs_mount_option() { + local nr="$1" + local name="$2" + local val="$3" + local opt="$(t_sysfs_path $nr)/mount_options/$name" + + echo "$val" > "$opt" +} + +t_set_all_sysfs_mount_options() { + local name="$1" + local val="$2" + local i + + for i in $(t_fs_nrs); do + t_set_sysfs_mount_option $i $name $val + done +} + +declare -A _saved_opts +t_save_all_sysfs_mount_options() { + local name="$1" + local ind + local opt + local i + + for i in $(t_fs_nrs); do + opt="$(t_sysfs_path $i)/mount_options/$name" + ind="$name_$i" + + _saved_opts[$ind]="$(cat $opt)" + done +} + +t_restore_all_sysfs_mount_options() { + local name="$1" + local ind + local i + + for i in $(t_fs_nrs); do + ind="$name_$i" + + t_set_sysfs_mount_option $i $name "${_saved_opts[$ind]}" + done +}