home *** CD-ROM | disk | FTP | other *** search
- #
- # unixcmds.test
- #
- # Tests for the link, unlink, times, umask, system and sleep commands.
- #---------------------------------------------------------------------------
- # Copyright 1992 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: unixcmds.test,v 2.0 1992/10/16 04:50:19 markd Rel $
- #------------------------------------------------------------------------------
- #
-
- if {[info procs test] != "test"} then {source testlib.tcl}
-
-
- # Proc to create a small file.
-
- proc TestCreate {fname} {
- set fh [open $fname w]
- puts $fh "Hello, world"
- close $fh
- }
-
- # Test link and unlink commands.
-
- Test unixcmds-1.1 {link and unlink tests} {
- unlink -nocomplain LINK2.TMP
- TestCreate LINK1.TMP
- link LINK1.TMP LINK2.TMP
- catch {unset stat}
- file stat LINK1.TMP stat
- set ino1 $stat(ino)
- set dev1 $stat(dev)
- file stat LINK2.TMP stat
- set ino2 $stat(ino)
- set dev2 $stat(dev)
- set result [list [file exists LINK2.TMP] [expr $ino1==$ino2] \
- [expr $dev1==$dev2]]
- unlink {LINK1.TMP LINK2.TMP}
- set result
- } 0 {1 1 1}
-
- Test unixcmds-1.2 {link and unlink tests} {
- list [catch {link LINK1.TMP LINK2.TMP} msg] [string tolower $msg]
- } 0 {1 {no such file or directory}}
-
- Test unixcmds-1.3 {link and unlink tests} {
- link
- } 1 {wrong # args: link [-sym] srcpath destpath}
-
- # Test -sym only if we have symbolic links.
-
- catch {link -sym doesNotExist doesNotExist2} msg
- unlink -nocomplain doesNotExist2
- set haveSymLinks 1
- if {$msg == "symbolic links are not supported on this system"} {
- set haveSymLinks 0
- }
-
- if $haveSymLinks {
- Test unixcmds-1.4 {link and unlink tests} {
- unlink -nocomplain LINK2.TMP
- TestCreate LINK1.TMP
- link -sym LINK1.TMP LINK2.TMP
- catch {unset stat}
- set result [file readlink LINK2.TMP]
- unlink {LINK1.TMP LINK2.TMP}
- set result
- } 0 {LINK1.TMP}
- }
-
- # Test unlink command.
-
- Test unixcmds-2.1 {link and unlink tests} {
- set fh [open UNLINK.TMP w]
- puts $fh "Hello, world"
- close $fh
- unlink UNLINK.TMP
- file exists UNLINK.TMP
- } 0 0
-
- Test unixcmds-2.2 {link and unlink tests} {
- list [catch {unlink UNLINK.TMP} msg] [string tolower $msg]
- } 0 {1 {unlink.tmp: no such file or directory}}
-
- Test unixcmds-2.3 {link and unlink tests} {
- unlink
- } 1 {wrong # args: unlink [-nocomplain] filelist}
-
- Test unixcmds-2.4 {link and unlink tests} {
- set fh [open UNLINK.TMP w]
- puts $fh "Hello, world"
- close $fh
- unlink -nocomplain {../src/FOOWAPFOO UNLINK.TMP}
- file exists UNLINK.TMP
- } 0 0
-
- # Test the times command (the best we can).
-
- Test unixcmds-3.1 {times tests} {
- llength [times]
- } 0 4
-
- Test unixcmds-3.2 {times tests} {
- times foo
- } 1 {wrong # args: times}
-
- # Test umask command.
-
- Test unixcmds-4.1 {umask tests} {
- set oldMask [umask]
- umask 666
- set newMask [umask]
- umask $oldMask
- set newMask
- } 0 666
-
- Test unixcmds-4.2 {umask tests} {
- umask 999
- } 1 {Expected octal number got: 999}
-
- Test unixcmds-4.3 {umask tests} {
- umask 7 7
- } 1 {wrong # args: umask octalmask}
-
- # Test the system command
-
- Test unixcmds-5.1 {system tests} {
- system "ls / >/dev/null"
- } 0 0
-
- Test unixcmds-5.2 {system tests} {
- system
- } 1 {wrong # args: system command}
-
- Test unixcmds-5.3 {system tests} {
- system x y z
- } 1 {wrong # args: system command}
-
- # Test the sleep command, as well as we can.
-
- Test unixcmds-6.1 {sleep tests} {
- sleep 1
- } 0 {}
-
- Test unixcmds-6.2 {sleep tests} {
- sleep
- } 1 {wrong # args: sleep seconds}
-
- Test unixcmds-6.3 {sleep tests} {
- sleep 1 2
- } 1 {wrong # args: sleep seconds}
-
- # Test mkdir and rmdir commands.
-
- Test unixcmds-7.1 {mkdir and rmdir tests} {
- catch {rmdir {MKDIR1.TMP MKDIR2.TMP}}
- mkdir {MKDIR1.TMP MKDIR2.TMP}
- set result [list [file isdirectory MKDIR1.TMP] \
- [file isdirectory MKDIR2.TMP]]
- catch {rmdir {MKDIR1.TMP MKDIR2.TMP}}
- set result
- } 0 {1 1}
-
- Test unixcmds-7.2 {mkdir and rmdir tests} {
- catch {rmdir {MKDIR1.TMP/a/b/c MKDIR1.TMP/a/b MKDIR1.TMP/a MKDIR1.TMP}}
- mkdir -path MKDIR1.TMP/a/b/c
- set result [file isdirectory MKDIR1.TMP/a/b/c]
- catch {rmdir {MKDIR1.TMP/a/b/c MKDIR1.TMP/a/b MKDIR1.TMP/a MKDIR1.TMP}}
- set result
- } 0 1
-
- Test unixcmds-7.3 {mkdir and rmdir tests} {
- catch {mkdir {MKDIR1.TMP MKDIR2.TMP}}
- rmdir {MKDIR1.TMP MKDIR2.TMP}
- list [file isdirectory MKDIR1.TMP] [file isdirectory MKDIR2.TMP]
- } 0 {0 0}
-
- Test unixcmds-7.4 {mkdir and rmdir tests} {
- catch {mkdir MKDIR1.TMP}
- set result [list [catch {mkdir MKDIR1.TMP} msg] [string tolower $msg]]
- catch {rmdir MKDIR1.TMP}
- set result
- } 0 {1 {mkdir1.tmp: file exists}}
-
- Test unixcmds-7.5 {mkdir and rmdir tests} {
- mkdir
- } 1 {wrong # args: mkdir [-path] dirlist}
-
- Test unixcmds-7.6 {mkdir and rmdir tests} {
- catch {rmdir MKDIR1.TMP}
- set result [list [catch {rmdir MKDIR1.TMP} msg] [string tolower $msg]]
- set result
- } 0 {1 {mkdir1.tmp: no such file or directory}}
-
- Test unixcmds-7.7 {mkdir and rmdir tests} {
- catch {rmdir MKDIR1.TMP}
- rmdir -nocomplain MKDIR1.TMP
- } 0 {}
-
- Test unixcmds-7.8 {mkdir and rmdir tests} {
- rmdir
- } 1 {wrong # args: rmdir [-nocomplain] dirlist}
-
-
-