mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-07 11:50:24 +00:00
Improve robustness of chroot-related tests
This commit is contained in:
parent
53529e0eeb
commit
deb465e442
@ -41,3 +41,27 @@ proc run_genode_until {{wait_for_re forever} {timeout_value 0}} {
|
|||||||
set output $expect_out(buffer)
|
set output $expect_out(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# Umount a directory that was bind-mounted beforehand
|
||||||
|
#
|
||||||
|
# This function is used by chroot-related tests, e.g., 'os/run/chroot.run',
|
||||||
|
# 'os/run/chroot_loader.run'.
|
||||||
|
#
|
||||||
|
proc umount_and_rmdir { path } {
|
||||||
|
|
||||||
|
puts "umounting $path"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Invoke umount until it returns an error. Apparently, the unmounting
|
||||||
|
# of bind-mounted mount points does not always take immediate effect
|
||||||
|
# (regardless of the -l option).
|
||||||
|
#
|
||||||
|
while {1} {
|
||||||
|
if {[catch { exec sudo umount -l $path }]} { break; }
|
||||||
|
sleep 0.25
|
||||||
|
}
|
||||||
|
|
||||||
|
catch { exec rmdir -p $path }
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -53,10 +53,9 @@ proc chroot_cwd_path { } { return "[chroot_path][pwd]/[run_dir]" }
|
|||||||
proc chroot_genode_tmp_path { } { return "[chroot_path]/tmp/genode-[exec id -u]" }
|
proc chroot_genode_tmp_path { } { return "[chroot_path]/tmp/genode-[exec id -u]" }
|
||||||
|
|
||||||
proc cleanup_chroot { } {
|
proc cleanup_chroot { } {
|
||||||
catch { exec sudo umount -l [chroot_cwd_path] }
|
umount_and_rmdir [chroot_cwd_path]
|
||||||
catch { exec sudo umount -l [chroot_genode_tmp_path] }
|
umount_and_rmdir [chroot_path]/lib
|
||||||
catch { exec sudo umount -l [chroot_path]/lib }
|
umount_and_rmdir [chroot_path]/lib64
|
||||||
exec rm -rf [chroot_path]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# replace 'chroot_path' marker in config with actual path
|
# replace 'chroot_path' marker in config with actual path
|
||||||
|
@ -59,15 +59,14 @@ set config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc chroot_path { id } { return "/tmp/chroot-test-$id" }
|
proc chroot_path { id } { return "/tmp/chroot-test-$id" }
|
||||||
|
|
||||||
proc chroot_cwd_path { id } { return "[chroot_path $id][pwd]/[run_dir]" }
|
proc chroot_cwd_path { id } { return "[chroot_path $id][pwd]/[run_dir]" }
|
||||||
|
|
||||||
proc cleanup_chroot { } {
|
proc cleanup_chroot { } {
|
||||||
|
|
||||||
foreach id { 1 2 } {
|
foreach id { 1 2 } {
|
||||||
catch { exec sudo umount -l [chroot_cwd_path $id] }
|
umount_and_rmdir [chroot_cwd_path $id]
|
||||||
catch { exec sudo umount -l [chroot_path $id]/lib }
|
umount_and_rmdir [chroot_path $id]/lib
|
||||||
catch { exec sudo umount -l [chroot_path $id]/lib64 }
|
umount_and_rmdir [chroot_path $id]/lib64
|
||||||
catch { exec rm -rf [chroot_path $id] }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user