home *** CD-ROM | disk | FTP | other *** search
- #
- # nice.test
- #
- # Tests for the nice command.
- #---------------------------------------------------------------------------
- # Copyright 1993-1994 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 "*************************************************************"
- puts "Nice tests are constructed in a way that does not work"
- puts "under Tk. Test skipped."
- puts "*************************************************************"
- puts ""
- return
- }
-
- #
- # Right now, we depend on the base priority being zero.
- #
- if {[nice] != 0} {
- puts "*************************************************************"
- puts "Nice priority is [nice], not zero. May cause some failures."
- puts "(but everything is probably ok)"
- puts "*************************************************************"
- puts ""
- }
-
- set niceBase [nice]
-
- Test nice-1.1 {nice tests} {
- nice 0 1
- } 1 {wrong # args: nice ?priorityincr?}
-
- Test nice-1.2 {nice tests} {
- nice 0
- } 0 $niceBase
-
- #
- # Since you can't nice back up unless you're root, we spawn a child process
- # to run the nice tests.
- #
-
- flush stdout
- flush stderr
- set pid [fork]
-
- #
- # Parent waits for child to complete.
- #
- if {$pid > 0} {
- wait $pid
- return
- }
-
- Test nice-1.4 {nice tests} {
- nice 3
- } 0 [expr $niceBase+3]
-
- Test nice-1.5 {nice tests} {
- nice 4
- } 0 [expr $niceBase+3+4]
-
- if {[id user] != "root"} {
-
- Test nice-1.7 {nice tests} {
- set errList {{not owner} {permission denied} {not privileged}
- {no permission match} {invalid argument}}
- set stat [catch {nice -1} msg]
- set msg [string tolower $msg]
- if {[lsearch $errList $msg] < 0} {
- set stat [list $stat $msg]
- }
- set stat
- } 0 1
-
- puts "*************************************************************"
- puts "You are not running as `root', certain nice tests will be"
- puts "skipped"
- puts "*************************************************************"
- exit
- }
-
- Test nice-1.8 {nice tests} {
- nice -1
- } 0 [expr $niceBase+3+4-1]
-
- Test nice-1.10 {nice tests} {
- nice -9
- } 0 [expr $niceBase+3+4-1-9]
-
- Test nice-1.11 {nice tests} {
- nice -10
- } 0 [expr $niceBase+3+4-1-9-10]
-
- Test nice-1.12 {nice tests} {
- nice -1
- } 0 [expr $niceBase+3+4-1-9-10-1]
-
- exit
-