diff options
author | Karel Zak | 2017-12-06 14:38:44 +0100 |
---|---|---|
committer | Karel Zak | 2017-12-06 15:55:09 +0100 |
commit | e140506af35821857a47c1013bad03b12f31062d (patch) | |
tree | 967ef56e98223c8546b56b9348ae23a657755533 /tests/functions.sh | |
parent | tests: add lock on shared resources (e.g. scsi_debug) (diff) | |
download | kernel-qcow2-util-linux-e140506af35821857a47c1013bad03b12f31062d.tar.gz kernel-qcow2-util-linux-e140506af35821857a47c1013bad03b12f31062d.tar.xz kernel-qcow2-util-linux-e140506af35821857a47c1013bad03b12f31062d.zip |
tests: use flock to modify fstab
Note that for btrfs test we need to use low-level ts_fstab_addline,
because we add multiple lines there.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r-- | tests/functions.sh | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/functions.sh b/tests/functions.sh index 0409b6283..181fe7972 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -628,6 +628,7 @@ function ts_fstab_open { function ts_fstab_close { echo "# -->" >> /etc/fstab + sync /etc/fstab } function ts_fstab_addline { @@ -639,7 +640,12 @@ function ts_fstab_addline { echo "$SPEC $MNT $FS $OPT 0 0" >> /etc/fstab } +function ts_fstab_lock { + ts_lock "fstab" +} + function ts_fstab_add { + ts_fstab_lock ts_fstab_open ts_fstab_addline $* ts_fstab_close @@ -655,6 +661,9 @@ function ts_fstab_clean { } s/# <!-- util-linux.*-->//; /^$/d" /etc/fstab + + sync /etc/fstab + ts_unlock "fstab" } function ts_fdisk_clean { @@ -694,7 +703,7 @@ function ts_lock { # Note that flock(2) lock is released on FD close. function ts_unlock { - 200<&- + 200<&- || : } function ts_scsi_debug_init { |