Improve robustness of chroot-related tests

This commit is contained in:
Norman Feske 2012-11-21 20:02:22 +01:00
parent 53529e0eeb
commit deb465e442
3 changed files with 32 additions and 10 deletions

View File

@ -41,3 +41,27 @@ proc run_genode_until {{wait_for_re forever} {timeout_value 0}} {
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 }
}

View File

@ -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 cleanup_chroot { } {
catch { exec sudo umount -l [chroot_cwd_path] }
catch { exec sudo umount -l [chroot_genode_tmp_path] }
catch { exec sudo umount -l [chroot_path]/lib }
exec rm -rf [chroot_path]
umount_and_rmdir [chroot_cwd_path]
umount_and_rmdir [chroot_path]/lib
umount_and_rmdir [chroot_path]/lib64
}
# replace 'chroot_path' marker in config with actual path

View File

@ -58,16 +58,15 @@ set config {
</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 cleanup_chroot { } {
foreach id { 1 2 } {
catch { exec sudo umount -l [chroot_cwd_path $id] }
catch { exec sudo umount -l [chroot_path $id]/lib }
catch { exec sudo umount -l [chroot_path $id]/lib64 }
catch { exec rm -rf [chroot_path $id] }
umount_and_rmdir [chroot_cwd_path $id]
umount_and_rmdir [chroot_path $id]/lib
umount_and_rmdir [chroot_path $id]/lib64
}
}