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

📄 exec.test

📁 linux系统下的音频通信
💻 TEST
📖 第 1 页 / 共 2 页
字号:
set a [concat $a $a $a $a]test exec-8.1 {long input and output} {    exec $tcltest cat << $a} $a# Commands that return errors.test exec-9.1 {commands returning errors} {    set x [catch {exec gorp456} msg]    list $x [string tolower $msg] [string tolower $errorCode]} {1 {couldn't execute "gorp456": no such file or directory} {posix enoent {no such file or directory}}}test exec-9.2 {commands returning errors} {    string tolower [list [catch {exec $tcltest echo foo | foo123} msg] $msg $errorCode]} {1 {couldn't execute "foo123": no such file or directory} {posix enoent {no such file or directory}}}test exec-9.3 {commands returning errors} {    list [catch {exec $tcltest sleep 1 | $tcltest exit 43 | $tcltest sleep 1} msg] $msg} {1 {child process exited abnormally}}test exec-9.4 {commands returning errors} {    list [catch {exec $tcltest exit 43 | $tcltest echo "foo bar"} msg] $msg} {1 {foo barchild process exited abnormally}}test exec-9.5 {commands returning errors} {    list [catch {exec gorp456 | $tcltest echo a b c} msg] [string tolower $msg]} {1 {couldn't execute "gorp456": no such file or directory}}test exec-9.6 {commands returning errors} {    list [catch {exec $tcltest sh -c "echo error msg 1>&2"} msg] $msg} {1 {error msg}}test exec-9.7 {commands returning errors} {    list [catch {exec $tcltest sh -c "echo error msg 1>&2" \		     | $tcltest sh -c "echo error msg 1>&2"} msg] $msg} {1 {error msgerror msg}}# Errors in executing the Tcl command, as opposed to errors in the# processes that are invoked.test exec-10.1 {errors in exec invocation} {    list [catch {exec} msg] $msg} {1 {wrong # args: should be "exec ?switches? arg ?arg ...?"}}test exec-10.2 {errors in exec invocation} {    list [catch {exec | cat} msg] $msg} {1 {illegal use of | or |& in command}}test exec-10.3 {errors in exec invocation} {    list [catch {exec cat |} msg] $msg} {1 {illegal use of | or |& in command}}test exec-10.4 {errors in exec invocation} {    list [catch {exec cat | | cat} msg] $msg} {1 {illegal use of | or |& in command}}test exec-10.5 {errors in exec invocation} {    list [catch {exec cat | |& cat} msg] $msg} {1 {illegal use of | or |& in command}}test exec-10.6 {errors in exec invocation} {    list [catch {exec cat |&} msg] $msg} {1 {illegal use of | or |& in command}}test exec-10.7 {errors in exec invocation} {    list [catch {exec cat <} msg] $msg} {1 {can't specify "<" as last word in command}}test exec-10.8 {errors in exec invocation} {    list [catch {exec cat >} msg] $msg} {1 {can't specify ">" as last word in command}}test exec-10.9 {errors in exec invocation} {    list [catch {exec cat <<} msg] $msg} {1 {can't specify "<<" as last word in command}}test exec-10.10 {errors in exec invocation} {    list [catch {exec cat >>} msg] $msg} {1 {can't specify ">>" as last word in command}}test exec-10.11 {errors in exec invocation} {    list [catch {exec cat >&} msg] $msg} {1 {can't specify ">&" as last word in command}}test exec-10.12 {errors in exec invocation} {    list [catch {exec cat >>&} msg] $msg} {1 {can't specify ">>&" as last word in command}}test exec-10.13 {errors in exec invocation} {    list [catch {exec cat >@} msg] $msg} {1 {can't specify ">@" as last word in command}}test exec-10.14 {errors in exec invocation} {    list [catch {exec cat <@} msg] $msg} {1 {can't specify "<@" as last word in command}}test exec-10.15 {errors in exec invocation} {    list [catch {exec cat < a/b/c} msg] [string tolower $msg]} {1 {couldn't read file "a/b/c": no such file or directory}}test exec-10.16 {errors in exec invocation} {    list [catch {exec cat << foo > a/b/c} msg] [string tolower $msg]} {1 {couldn't write file "a/b/c": no such file or directory}}test exec-10.17 {errors in exec invocation} {    list [catch {exec cat << foo > a/b/c} msg] [string tolower $msg]} {1 {couldn't write file "a/b/c": no such file or directory}}set f [open gorp.file w]test exec-10.18 {errors in exec invocation} {    list [catch {exec cat <@ $f} msg] $msg} "1 {channel \"$f\" wasn't opened for reading}"close $fset f [open gorp.file r]test exec-10.19 {errors in exec invocation} {    list [catch {exec cat >@ $f} msg] $msg} "1 {channel \"$f\" wasn't opened for writing}"close $ftest exec-10.20 {errors in exec invocation} {    list [catch {exec ~non_existent_user/foo/bar} msg] $msg} {1 {user "non_existent_user" doesn't exist}}test exec-10.21 {errors in exec invocation} {    list [catch {exec $tcltest true | ~xyzzy_bad_user/x | false} msg] $msg} {1 {user "xyzzy_bad_user" doesn't exist}}# Commands in background.test exec-11.1 {commands in background} {    set x [lindex [time {exec $tcltest sleep 2 &}] 0]    expr $x<1000000} 1test exec-11.2 {commands in background} {    list [catch {exec $tcltest echo a &b} msg] $msg} {0 {a &b}}test exec-11.3 {commands in background} {    llength [exec $tcltest sleep 1 &]} 1test exec-11.4 {commands in background} {    llength [exec $tcltest sleep 1 | $tcltest sleep 1 | $tcltest sleep 1 &]} 3test exec-11.5 {commands in background} {    set f [open gorp.file w]    puts $f { catch { exec [info nameofexecutable] echo foo & } }    close $f    string compare "foo" [exec $tcltest gorp.file]} 0# Make sure that background commands are properly reaped when# they eventually die.exec $tcltest sleep 3test exec-12.1 {reaping background processes} {unixOnly nonPortable} {    for {set i 0} {$i < 20} {incr i} {	exec echo foo > /dev/null &    }    exec sleep 1    catch {exec ps | fgrep "echo foo" | fgrep -v fgrep | wc} msg    lindex $msg 0} 0test exec-12.2 {reaping background processes} {unixOnly nonPortable} {    exec sleep 2 | sleep 2 | sleep 2 &    catch {exec ps | fgrep -i "sleep" | fgrep -i -v fgrep | wc} msg    set x [lindex $msg 0]    exec sleep 3    catch {exec ps | fgrep -i "sleep" | fgrep -i -v fgrep | wc} msg    list $x [lindex $msg 0]} {3 0}test exec-12.3 {reaping background processes} {unixOnly nonPortable} {    exec sleep 1000 &    exec sleep 1000 &    set x [exec ps | fgrep "sleep" | fgrep -v fgrep]    set pids {}    foreach i [split $x \n] {	lappend pids [lindex $i 0]    }    foreach i $pids {	catch {exec kill -STOP $i}    }    catch {exec ps | fgrep "sleep" | fgrep -v fgrep | wc} msg    set x [lindex $msg 0]    foreach i $pids {	catch {exec kill -KILL $i}    }    catch {exec ps | fgrep "sleep" | fgrep -v fgrep | wc} msg    list $x [lindex $msg 0]} {2 0}# Make sure "errorCode" is set correctly.test exec-13.1 {setting errorCode variable} {    list [catch {exec $tcltest cat < a/b/c} msg] [string tolower $errorCode]} {1 {posix enoent {no such file or directory}}}test exec-13.2 {setting errorCode variable} {    list [catch {exec $tcltest cat > a/b/c} msg] [string tolower $errorCode]} {1 {posix enoent {no such file or directory}}}test exec-13.3 {setting errorCode variable} {    set x [catch {exec _weird_cmd_} msg]    list $x [string tolower $msg] [lindex $errorCode 0] \	    [string tolower [lrange $errorCode 2 end]]} {1 {couldn't execute "_weird_cmd_": no such file or directory} POSIX {{no such file or directory}}}# Switches before the first argumenttest exec-14.1 {-keepnewline switch} {    exec -keepnewline $tcltest echo foo} "foo\n"test exec-14.2 {-keepnewline switch} {    list [catch {exec -keepnewline} msg] $msg} {1 {wrong # args: should be "exec ?switches? arg ?arg ...?"}}test exec-14.3 {unknown switch} {    list [catch {exec -gorp} msg] $msg} {1 {bad switch "-gorp": must be -keepnewline or --}}test exec-14.4 {-- switch} {    list [catch {exec -- -gorp} msg] [string tolower $msg]} {1 {couldn't execute "-gorp": no such file or directory}}# Redirecting standard error separately from standard outputtest exec-15.1 {standard error redirection} {    exec $tcltest echo "First line" > gorp.file    list [exec $tcltest sh -c "echo foo bar 1>&2" 2> gorp.file] \	    [exec $tcltest cat gorp.file]} {{} {foo bar}}test exec-15.2 {standard error redirection} {    list [exec $tcltest sh -c "echo foo bar 1>&2" \		| $tcltest echo biz baz >gorp.file 2> gorp.file2] \	    [exec $tcltest cat gorp.file] \	    [exec $tcltest cat gorp.file2]} {{} {biz baz} {foo bar}}test exec-15.3 {standard error redirection} {    list [exec $tcltest sh -c "echo foo bar 1>&2" \	        | $tcltest echo biz baz 2>gorp.file > gorp.file2] \	    [exec $tcltest cat gorp.file] \	    [exec $tcltest cat gorp.file2]} {{} {foo bar} {biz baz}}test exec-15.4 {standard error redirection} {    set f [open gorp.file w]    puts $f "Line 1"    flush $f    exec $tcltest sh -c "echo foo bar 1>&2" 2>@ $f    puts $f "Line 3"    close $f    exec $tcltest cat gorp.file} {Line 1foo barLine 3}test exec-15.5 {standard error redirection} {    exec $tcltest echo "First line" > gorp.file    exec $tcltest sh -c "echo foo bar 1>&2" 2>> gorp.file    exec $tcltest cat gorp.file} {First linefoo bar}test exec-15.6 {standard error redirection} {    exec $tcltest sh -c "echo foo bar 1>&2" > gorp.file2 2> gorp.file \	    >& gorp.file 2> gorp.file2 | $tcltest echo biz baz    list [exec $tcltest cat gorp.file] [exec $tcltest cat gorp.file2]} {{biz baz} {foo bar}}test exec-16.1 {flush output before exec} {    set f [open gorp.file w]    puts $f "First line"    exec $tcltest echo "Second line" >@ $f    puts $f "Third line"    close $f    exec $tcltest cat gorp.file} {First lineSecond lineThird line}test exec-16.2 {flush output before exec} {} {    set f [open gorp.file w]    puts $f "First line"    exec $tcltest << {puts stderr {Second line}} >&@ $f > gorp.file2    puts $f "Third line"    close $f    exec $tcltest cat gorp.file} {First lineSecond lineThird line}test exec-17.1 { inheriting standard I/O } {    set f [open script w]    puts $f {close stdout	set f [open gorp.file w]	catch {exec [info nameofexecutable] echo foobar &}	exec [info nameofexecutable] sleep 2	close $f    }    close $f    catch {exec $tcltest script} result    set f [open gorp.file r]    lappend result [read $f]    close $f    set result} {{foobar}}file delete script gorp.file gorp.file2file delete echo cat wc sh sleep exit

⌨️ 快捷键说明

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