⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fcmd.test

📁 linux系统下的音频通信
💻 TEST
📖 第 1 页 / 共 5 页
字号:
# This file tests the tclFCmd.c file.## This file contains a collection of tests for one or more of the Tcl# built-in commands.  Sourcing this file into Tcl runs the tests and# generates output for errors.  No output means no errors were found.## Copyright (c) 1996-1997 Sun Microsystems, Inc.## See the file "license.terms" for information on usage and redistribution# of this file, and for a DISCLAIMER OF ALL WARRANTIES.## SCCS: @(#) fCmd.test 1.33 97/11/03 15:58:08#if {[string compare test [info procs test]] == 1} then {source defs}set platform [testgetplatform]if {$user == "root"} {    puts "Skipping fCmd tests.  They depend on not being able to write to"    puts "certain directories.  It would be too dangerous to run them as root."    return}if {"[info commands testchmod]" != "testchmod"} {    puts "Skipping fCmd tests. This application does not seem to have the"    puts "testchmod command that is needed to run these tests."    return}proc createfile {file {string a}} {    set f [open $file w]    puts -nonewline $f $string    close $f    return $string}# # checkcontent --##  Ensures that file "file" contains only the string "matchString"#  returns 0 if the file does not exist, or has a different content#proc checkcontent {file matchString} {    if {[catch {	set f [open $file]	set fileString [read $f]	close $f     }]} {	return 0    }    return [string match $matchString $fileString]}proc openup {path} {    testchmod 777 $path    if {[file isdirectory $path]} {	catch {	    foreach p [glob [file join $path *]] {		openup $p	    }	}    }}proc cleanup {args} {    foreach p ". $args" {	set x ""	catch {	    set x [glob [file join $p tf*] [file join $p td*]]	}	foreach file $x {	    if {[catch {file delete -force -- $file}]} {		openup $file		file delete -force -- $file	    }	}    }}proc contents {file} {    set f [open $file r]    set r [read $f]    close $f    set r}set testConfig(NT) 0set testConfig(95) 0switch $tcl_platform(os) {    "Windows NT" {set testConfig(NT) 1}    "Windows 95" {set testConfig(95) 1}}set testConfig(fileSharing) 0set testConfig(notFileSharing) 1if {$tcl_platform(platform) == "macintosh"} {    catch {file delete -force foo.dir}    file mkdir foo.dir    if {[catch {file attributes foo.dir -readonly 1}] == 0} {    	set testConfig(fileSharing) 1    	set testConfig(notFileSharing) 0    }    file delete -force foo.dir}set testConfig(xdev) 0if {$tcl_platform(platform) == "unix"} {    if {[catch {set m1 [exec df .]; set m2 [exec df /tmp]}] == 0} {	set m1 [string range $m1 0 [expr [string first " " $m1]-1]]	set m2 [string range $m2 0 [expr [string first " " $m2]-1]]	if {$m1 != "" && $m2 != "" && $m1 != $m2 && [file exists $m1] && [file exists $m2]} {	    set testConfig(xdev) 1	}    }}set root [lindex [file split [pwd]] 0]# A really long file name# length of long is 1216 chars, which should be greater than any static# buffer or allowable filename.set long "abcdefghihjllmnopqrstuvwxyz01234567890"append long $longappend long $longappend long $longappend long $longappend long $longtest fCmd-1.1 {TclFileRenameCmd} {    cleanup    createfile tf1    file rename tf1 tf2    glob tf*} {tf2}test fCmd-2.1 {TclFileCopyCmd} {    cleanup    createfile tf1    file copy tf1 tf2    lsort [glob tf*]} {tf1 tf2}test fCmd-3.1 {FileCopyRename: FileForceOption fails} {    list [catch {file rename -xyz} msg] $msg} {1 {bad option "-xyz": should be -force or --}}test fCmd-3.2 {FileCopyRename: not enough args} {    list [catch {file rename xyz} msg] $msg} {1 {wrong # args: should be "file rename ?options? source ?source ...? target"}}test fCmd-3.3 {FileCopyRename: Tcl_TranslateFileName fails} {    list [catch {file rename xyz ~nonexistantuser} msg] $msg} {1 {user "nonexistantuser" doesn't exist}}test fCmd-3.4 {FileCopyRename: Tcl_TranslateFileName passes} {    cleanup    list [catch {file copy tf1 ~} msg] $msg} {1 {error copying "tf1": no such file or directory}}test fCmd-3.5 {FileCopyRename: target doesn't exist: stat(target) != 0} {    cleanup    list [catch {file rename tf1 tf2 tf3} msg] $msg} {1 {error renaming: target "tf3" is not a directory}}test fCmd-3.6 {FileCopyRename: target tf3 is not a directory: !S_ISDIR(target)} {    cleanup    createfile tf3    list [catch {file rename tf1 tf2 tf3} msg] $msg} {1 {error renaming: target "tf3" is not a directory}}test fCmd-3.7 {FileCopyRename: target exists & is directory} {    cleanup    file mkdir td1    createfile tf1 tf1    file rename tf1 td1    contents [file join td1 tf1]} {tf1}test fCmd-3.8 {FileCopyRename: too many arguments: argc - i > 2} {    cleanup    list [catch {file rename tf1 tf2 tf3} msg] $msg} {1 {error renaming: target "tf3" is not a directory}}test fCmd-3.9 {FileCopyRename: too many arguments: argc - i > 2} {    cleanup    list [catch {file copy -force -- tf1 tf2 tf3} msg] $msg} {1 {error copying: target "tf3" is not a directory}}test fCmd-3.10 {FileCopyRename: just 2 arguments} {    cleanup    createfile tf1 tf1    file rename tf1 tf2    contents tf2} {tf1}test fCmd-3.11 {FileCopyRename: just 2 arguments} {    cleanup    createfile tf1 tf1    file rename -force -force -- tf1 tf2    contents tf2} {tf1}test fCmd-3.12 {FileCopyRename: move each source: 1 source} {    cleanup    createfile tf1 tf1    file mkdir td1    file rename tf1 td1    contents [file join td1 tf1]} {tf1}test fCmd-3.13 {FileCopyRename: move each source: multiple sources} {    cleanup    createfile tf1 tf1    createfile tf2 tf2    createfile tf3 tf3    createfile tf4 tf4    file mkdir td1    file rename tf1 tf2 tf3 tf4 td1    list [contents [file join td1 tf1]] [contents [file join td1 tf2]] \	[contents [file join td1 tf3]] [contents [file join td1 tf4]]} {tf1 tf2 tf3 tf4}test fCmd-3.14 {FileCopyRename: FileBasename fails} {    cleanup    file mkdir td1    list [catch {file rename ~nonexistantuser td1} msg] $msg} {1 {user "nonexistantuser" doesn't exist}}test fCmd-3.15 {FileCopyRename: source[0] == '\0'} {unixOrPc} {    cleanup    file mkdir td1    list [catch {file rename / td1} msg] $msg} {1 {error renaming "/" to "td1": file already exists}}test fCmd-3.16 {FileCopyRename: break on first error} {    cleanup    createfile tf1     createfile tf2     createfile tf3     createfile tf4     file mkdir td1    createfile [file join td1 tf3]    list [catch {file rename tf1 tf2 tf3 tf4 td1} msg] $msg} [subst {1 {error renaming "tf3" to "[file join td1 tf3]": file already exists}}]test fCmd-4.1 {TclFileMakeDirsCmd: make each dir: 1 dir} {    cleanup    file mkdir td1    glob td*} {td1}test fCmd-4.2 {TclFileMakeDirsCmd: make each dir: multiple dirs} {    cleanup    file mkdir td1 td2 td3    lsort [glob td*]} {td1 td2 td3}test fCmd-4.3 {TclFileMakeDirsCmd: stops on first error} {    cleanup    createfile tf1    catch {file mkdir td1 td2 tf1 td3 td4}    glob td1 td2 tf1 td3 td4} {td1 td2 tf1}test fCmd-4.4 {TclFileMakeDirsCmd: Tcl_TranslateFileName fails} {    cleanup    list [catch {file mkdir ~nonexistantuser} msg] $msg} {1 {user "nonexistantuser" doesn't exist}}test fCmd-4.5 {TclFileMakeDirsCmd: Tcl_SplitPath returns 0: *name == '\0'} {    cleanup    list [catch {file mkdir ""} msg] $msg} {1 {can't create directory "": no such file or directory}}test fCmd-4.6 {TclFileMakeDirsCmd: one level deep} {    cleanup    file mkdir td1    glob td1} {td1}test fCmd-4.7 {TclFileMakeDirsCmd: multi levels deep} {    cleanup    file mkdir [file join td1 td2 td3 td4]    glob td1 [file join td1 td2]} "td1 [file join td1 td2]"test fCmd-4.8 {TclFileMakeDirsCmd: already exist: lstat(target) == 0} {    cleanup    file mkdir td1    set x [file exist td1]    file mkdir td1    list $x [file exist td1]} {1 1}test fCmd-4.9 {TclFileMakeDirsCmd: exists, not dir} {    cleanup    createfile tf1    list [catch {file mkdir tf1} msg] $msg} [subst {1 {can't create directory "[file join tf1]": file already exists}}]test fCmd-4.10 {TclFileMakeDirsCmd: exists, is dir} {    cleanup    file mkdir td1    set x [file exist td1]    file mkdir td1    list $x [file exist td1]} {1 1}test fCmd-4.11 {TclFileMakeDirsCmd: doesn't exist: errno != ENOENT} {unixOnly} {    cleanup    file mkdir td1/td2/td3    testchmod 000 td1/td2    set msg [list [catch {file mkdir td1/td2/td3/td4} msg] $msg]    testchmod 755 td1/td2    set msg} {1 {can't create directory "td1/td2/td3": permission denied}}test fCmd-4.12 {TclFileMakeDirsCmd: doesn't exist: errno != ENOENT} {macOnly} {    cleanup    list [catch {file mkdir nonexistantvolume:} msg] $msg} {1 {can't create directory "nonexistantvolume:": invalid argument}}test fCmd-4.13 {TclFileMakeDirsCmd: doesn't exist: errno == ENOENT} {    cleanup    set x [file exist td1]    file mkdir td1    list $x [file exist td1]} {0 1}test fCmd-4.14 {TclFileMakeDirsCmd: TclpCreateDirectory fails} {unixOnly} {    cleanup    file delete -force foo    file mkdir foo    file attr foo -perm 040000    set result [list [catch {file mkdir foo/tf1} msg] $msg]    file delete -force foo    set result} {1 {can't create directory "foo/tf1": permission denied}}test fCmd-4.15 {TclFileMakeDirsCmd: TclpCreateDirectory fails} {macOnly} {    list [catch {file mkdir ${root}:} msg] $msg} [subst {1 {can't create directory "${root}:": no such file or directory}}]test fCmd-4.16 {TclFileMakeDirsCmd: TclpCreateDirectory succeeds} {    cleanup    file mkdir tf1    file exists tf1} {1}test fCmd-5.1 {TclFileDeleteCmd: FileForceOption fails} {    list [catch {file delete -xyz} msg] $msg} {1 {bad option "-xyz": should be -force or --}}test fCmd-5.2 {TclFileDeleteCmd: not enough args} {    list [catch {file delete -force -force} msg] $msg} {1 {wrong # args: should be "file delete ?options? file ?file ...?"}}test fCmd-5.3 {TclFileDeleteCmd: 1 file} {    cleanup    createfile tf1    createfile tf2    file mkdir td1    file delete tf2    glob tf* td*} {tf1 td1}test fCmd-5.4 {TclFileDeleteCmd: multiple files} {    cleanup    createfile tf1    createfile tf2    file mkdir td1    set x [list [file exist tf1] [file exist tf2] [file exist td1]]    file delete tf1 td1 tf2    lappend x [file exist tf1] [file exist tf2] [file exist tf3]} {1 1 1 0 0 0}test fCmd-5.5 {TclFileDeleteCmd: stop at first error} {unixOrPc} {    cleanup    createfile tf1    createfile tf2    file mkdir td1    catch {file delete tf1 td1 $root tf2}    list [file exist tf1] [file exist tf2] [file exist td1]} {0 1 0}test fCmd-5.6 {TclFileDeleteCmd: Tcl_TranslateFileName fails} {    list [catch {file delete ~nonexistantuser} msg] $msg} {1 {user "nonexistantuser" doesn't exist}}test fCmd-5.7 {TclFileDeleteCmd: Tcl_TranslateFileName succeeds} {    catch {file delete ~/tf1}    createfile ~/tf1    file delete ~/tf1} {}test fCmd-5.8 {TclFileDeleteCmd: file doesn't exist: lstat(name) != 0} {    cleanup    set x [file exist tf1]    file delete tf1    list $x [file exist tf1]} {0 0}    test fCmd-5.9 {TclFileDeleteCmd: is directory} {    cleanup    file mkdir td1    file delete td1    file exist td1} {0}test fCmd-5.10 {TclFileDeleteCmd: TclpRemoveDirectory fails} {    cleanup    file mkdir td1/td2    list [catch {file delete td1} msg] $msg} {1 {error deleting "td1": directory not empty}}test fCmd-6.1 {CopyRenameOneFile: bad source} {    # can't test this, because it's caught by FileCopyRename} {}test fCmd-6.2 {CopyRenameOneFile: bad target} {    # can't test this, because it's caught by FileCopyRename} {}test fCmd-6.3 {CopyRenameOneFile: lstat(source) != 0} {    cleanup    list [catch {file rename tf1 tf2} msg] $msg} {1 {error renaming "tf1": no such file or directory}}test fCmd-6.4 {CopyRenameOneFile: lstat(source) == 0} {    cleanup    createfile tf1    file rename tf1 tf2    glob tf*} {tf2}test fCmd-6.5 {CopyRenameOneFile: lstat(target) != 0} {    cleanup    createfile tf1    file rename tf1 tf2    glob tf*} {tf2}test fCmd-6.6 {CopyRenameOneFile: errno != ENOENT} {unixOnly} {    cleanup    file mkdir td1    testchmod 000 td1    createfile tf1    set msg [list [catch {file rename tf1 td1} msg] $msg]    testchmod 755 td1    set msg} {1 {error renaming "tf1" to "td1/tf1": permission denied}}test fCmd-6.7 {CopyRenameOneFile: errno != ENOENT} {95} {    cleanup    createfile tf1    list [catch {file rename tf1 $long} msg] $msg} [subst {1 {error renaming "tf1" to "$long": file name too long}}]test fCmd-6.8 {CopyRenameOneFile: errno != ENOENT} {macOnly} {    cleanup

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -