home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / tcl / tcl+tk+t / tclx7.3bl / tclx7 / tclX7.3b / tests / chroot.test < prev    next >
Encoding:
Text File  |  1994-07-16  |  2.0 KB  |  79 lines

  1. #
  2. # chroot.test
  3. #
  4. # Tests for the chroot command.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1993-1994 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: 
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] != "test"} then {source testlib.tcl}
  20.  
  21. #
  22. # Fork without exec will not work under Tk, skip this test
  23. #
  24. if ![lempty [info commands button]] {
  25.     puts "*************************************************************"
  26.     puts "Chroot tests are constructed in a way that does not work"
  27.     puts "under Tk.  Test skipped."
  28.     puts "*************************************************************"
  29.     puts ""
  30.     return
  31. }
  32.  
  33. Test chroot-1.1 {chroot tests} {
  34.     chroot
  35. } 1 {wrong # args: chroot path}
  36.  
  37. Test chroot-1.2 {chroot tests} {
  38.     chroot a b
  39. } 1 {wrong # args: chroot path}
  40.  
  41. if {[id user] != "root"} {
  42.     puts "*************************************************************"
  43.     puts "You are not running as `root', certain chroot tests will be"
  44.     puts "skipped"
  45.     puts "*************************************************************"
  46.     return
  47. }
  48.  
  49. #
  50. # clean up and create an empty test directory
  51. #
  52. exec rm -rf CHROOTDIR
  53. mkdir CHROOTDIR
  54.  
  55. #
  56. # since you can't chroot back up, we spawn a child process to do the
  57. # actual chroot
  58. #
  59. set pid [fork]
  60.  
  61. #
  62. # parent waits for child to complete
  63. #
  64. if {$pid > 0} {
  65.     wait $pid
  66.     exec rm -rf CHROOTDIR
  67.     return
  68. }
  69.  
  70. #
  71. # child tests chroot then exits
  72. #
  73. Test chroot-1.3 {chroot tests} {
  74.     chroot CHROOTDIR
  75.     glob -nocomplain /*
  76. } 0 {}
  77.  
  78. exit
  79.