]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
common/rc: new functions for multi-level mount/umount operations
authorZorro Lang <zlang@redhat.com>
Tue, 14 Feb 2017 00:55:42 +0000 (19:55 -0500)
committerEryu Guan <eguan@redhat.com>
Wed, 15 Feb 2017 09:55:33 +0000 (17:55 +0800)
commit74a84259c5a896ca3716f23a41e59af11ddb05d4
tree83d425faf0b0173e4abbf2c3965cea8c506a8b97
parente78ae074b2ab3db4b850fc59421edaa2d543e2bc
common/rc: new functions for multi-level mount/umount operations

When I try to write cases about mount shared subtrees test, I find I
always need to do many mount operations, then then umount those
mount point one by one.

To make the code clear, I use a stack to save mounted points
sequentially, then I write 3 common functions to operate this stack.

1. The global stack named MOUNTED_POINT_STACK
2. _get_mount() accepts mount parameters like _mount() does, but the
   mountpoint parameter must be the last one. It will run the
   mount operation and push the mountpoint name into stack.
3. _put_mount() doesn't need any parameter. It will pop the newest
   mountpoint name from the stack, and umount it.
4. _clear_mount_stack() doesn't need any parameter either. It will
   umount all mountpoints in the stack sequentially, and set
   MOUNTED_POINT_STACK=""

Generally, the _clear_mount_stack() function also can be used as
_init_mount_stack() at the beginning of a case. Because it will
prepare an empty stack.

[eguan: add comments and fix code style]

Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc