diff --git a/os/run/chroot_loader.run b/os/run/chroot_loader.run index a27747278..95d35b615 100644 --- a/os/run/chroot_loader.run +++ b/os/run/chroot_loader.run @@ -10,7 +10,7 @@ if {![have_spec linux]} { puts "Run script requires Linux"; exit 0 } # Build # -build { core init drivers/timer/linux test/timer +build { core init drivers/timer test/timer server/loader test/chroot_loader } if {[catch { exec which setcap }]} { @@ -18,6 +18,23 @@ if {[catch { exec which setcap }]} { return 0 } +# +# Clean up remains of a potentially failed previous run +# + +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 } { + umount_and_rmdir [chroot_cwd_path $id] + umount_and_rmdir [chroot_path $id]/lib + umount_and_rmdir [chroot_path $id]/lib64 + } +} + +cleanup_chroot create_boot_directory @@ -58,18 +75,6 @@ set config { } -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 } { - umount_and_rmdir [chroot_cwd_path $id] - umount_and_rmdir [chroot_path $id]/lib - umount_and_rmdir [chroot_path $id]/lib64 - } -} - # replace 'chroot_path' markers in config with actual paths foreach id { 1 2 } { regsub "chroot_path_$id" $config [chroot_path $id] config } @@ -100,7 +105,6 @@ exec sudo setcap cap_sys_admin,cap_sys_chroot=ep [run_dir]/core # # start with fresh directory -cleanup_chroot foreach id { 1 2 } { exec mkdir -p [chroot_path $id] exec mkdir -p [chroot_path $id]/lib @@ -125,7 +129,7 @@ if {[regexp -all -- {--- timer test ---} $output] != 6} { exit 2 } -if {![regexp -- {init-1 -> test-timer] wait 2/10} $output]} { +if {![regexp -- {init-1 -> test-timer] Done 500 ms period 4 times} $output]} { puts stderr "Long-running timer test has made too little progress" exit 3 } @@ -135,4 +139,7 @@ if {![regexp -- {init-1 -> test-timer] wait 2/10} $output]} { # cleanup_chroot +puts "Test succeeded" + # vi: set ft=tcl : + diff --git a/os/src/test/chroot_loader/main.cc b/os/src/test/chroot_loader/main.cc index 5015cbee2..98379548e 100644 --- a/os/src/test/chroot_loader/main.cc +++ b/os/src/test/chroot_loader/main.cc @@ -61,6 +61,7 @@ static char const *subsystem_config() " \n" " \n" " \n" + " \n" " \n" " \n" " \n"