home *** CD-ROM | disk | FTP | other *** search
- #
- # chroot.test
- #
- # Tests for the chroot command.
- #---------------------------------------------------------------------------
- # Copyright 1993 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 {[info procs test] != "test"} then {source testlib.tcl}
-
- #
- # Fork without exec will not work under Tk, skip this test
- #
- if ![lempty [info commands button]] {
- puts stderr "*************************************************************"
- puts stderr "Chroot tests are constructed in a way that does not work"
- puts stderr "under Tk. Test skipped."
- puts stderr "*************************************************************"
- puts stderr ""
- return
- }
-
- Test chroot-1.1 {chroot tests} {
- chroot
- } 1 {wrong # args: chroot path}
-
- Test chroot-1.2 {chroot tests} {
- chroot a b
- } 1 {wrong # args: chroot path}
-
- if {[id user] != "root"} {
- puts stderr "*************************************************************"
- puts stderr "You are not running as `root', certain chroot tests will be"
- puts stderr "skipped"
- puts stderr "*************************************************************"
- return
- }
-
- #
- # clean up and create an empty test directory
- #
- exec rm -rf CHROOTDIR
- 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
- exec rm -rf CHROOTDIR
- return
- }
-
- #
- # child tests chroot then exits
- #
- Test chroot-1.3 {chroot tests} {
- chroot CHROOTDIR
- glob -nocomplain /*
- } 0 {}
-
- exit
-