# # chroot.test # # Tests for the chroot command. #--------------------------------------------------------------------------- # Copyright 1993-1999 Karl Lehenbauer and Mark Diekhans. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided # that the above copyright notice appear in all copies. Karl Lehenbauer and # Mark Diekhans make no representations about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. #------------------------------------------------------------------------------ # $Id: #------------------------------------------------------------------------------ # if {[cequal [info procs Test] {}]} { source [file join [file dirname [info script]] testlib.tcl] } # # Fork without exec will not work under Tk, skip this test # if {[info exists tk_version]} { puts "*************************************************************" puts "Chroot tests are constructed in a way that does not work" puts "under Tk. Test skipped." puts "*************************************************************" return } test chroot-1.1 {chroot tests} {unixOnly} { list [catch {chroot} msg] $msg } {1 {wrong # args: chroot path}} test chroot-1.2 {chroot tests} {unixOnly} { list [catch {chroot a b} msg] $msg } {1 {wrong # args: chroot path}} test chroot-1.3 {chroot tests} {pcOnly} { list [catch {chroot a} msg] $msg } {1 {chroot is not available on MS Windows}} # # Actually doing something real with chroot only makes sense on unix. # if ![cequal $tcl_platform(platform) "unix"] { # cleanup ::tcltest::cleanupTests return } if {[id user] != "root"} { puts "*******************************************************************" puts "You are not running as `root', certain chroot tests will be skipped" puts "*******************************************************************" # cleanup ::tcltest::cleanupTests return } # # clean up and create an empty test directory # set CHROOTDIR __CHROOTDIR.TEST catch {file delete -force $CHROOTDIR} file mkdir $CHROOTDIR # # since you can't chroot back up, we spawn a child process to do the # actual chroot # set pid [fork] # # parent waits for child to complete # if {$pid > 0} { wait $pid file delete -force $CHROOTDIR # cleanup ::tcltest::cleanupTests return } # # child tests chroot then exits # test chroot-2.1 {chroot tests} {isRoot} { chroot $CHROOTDIR glob -nocomplain /* } {} # cleanup ::tcltest::cleanupTests exit