# # \brief Test for using chroot on Linux # \author Norman Feske # \date 2012-04-18 # # if {![have_spec linux]} { puts "Run script requires Linux"; exit 0 } # # Build # build { core init app/chroot drivers/timer/linux test/timer } if {[catch { exec which setcap }]} { puts stderr "Error: setcap not available, please install the libcap2-bin package" return 0 } create_boot_directory # # Generate config # set config { } proc chroot_path { } { return "/tmp/chroot-test" } 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] } exec rm -rf [chroot_path] } # replace 'chroot_path' marker in config with actual path regsub "chroot_path" $config [chroot_path] config install_config $config # # Copy boot modules into run directory # # We cannot use the predefined 'build_boot_image' function here because # this would create mere symlinks. However, we want to hardlink the # run directory into the chroot environment. If the directory entries # were symlinks, those would point to nowhere within the chroot. # foreach binary { core init chroot timer test-timer } { exec cp -H bin/$binary [run_dir] } # # Grant chroot permission to 'chroot' tool # # CAP_SYS_ADMIN is needed for bind mounting genode runtime directories # CAP_SYS_CHROOT is needed to perform the chroot syscall # exec sudo setcap cap_sys_admin,cap_sys_chroot=ep [run_dir]/chroot # # Setup chroot environment # # start with fresh directory cleanup_chroot exec mkdir -p [chroot_path] # # Execute test case # run_genode_until {.*--- timer test finished ---.*} 60 # # Remove artifacts created while running the test # cleanup_chroot # vi: set ft=tcl :