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

📄 exec.test

📁 linux系统下的音频通信
💻 TEST
📖 第 1 页 / 共 2 页
字号:
# Commands covered:  exec## 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) 1991-1994 The Regents of the University of California.# Copyright (c) 1994-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: @(#) exec.test 1.58 97/08/01 11:10:00if {[string compare test [info procs test]] == 1} then {source defs}# If exec is not defined just return with no error# Some platforms like the Macintosh do not have the exec commandif {[info commands exec] == ""} {    puts "exec not implemented for this machine"    return}if {$testConfig(stdio) == 0} {    return}set f [open echo w]puts $f {    puts -nonewline [lindex $argv 0]    foreach str [lrange $argv 1 end] {	puts -nonewline " $str"    }    puts {}}close $fset f [open cat w]puts $f {    if {$argv == {}} {	set argv -    }    foreach name $argv {	if {$name == "-"} {	    set f stdin	} elseif {[catch {open $name r} f] != 0} {	    puts stderr $f	    continue	}	while {[eof $f] == 0} {	    puts -nonewline [read $f]	}	if {$f != "stdin"} {	    close $f	}    }}close $fset f [open wc w]puts $f {    set data [read stdin]    set lines [regsub -all "\n" $data {} dummy]    set words [regsub -all "\[^ \t\n]+" $data {} dummy]    set chars [string length $data]    puts [format "%8.d%8.d%8.d" $lines $words $chars]}close $fset f [open sh w]puts $f {    if {[lindex $argv 0] != "-c"} {	error "sh: unexpected arguments $argv"    }    set cmd [lindex $argv 1]    lappend cmd ";"    set newcmd {}        foreach arg $cmd {	if {$arg == ";"} {	    eval exec >@stdout 2>@stderr [list [info nameofexecutable]] $newcmd	    set newcmd {}	    continue	}	if {$arg == "1>&2"} {	    set arg >@stderr	}	lappend newcmd $arg    }}close $fset f [open sleep w]puts $f {    after [expr $argv*1000]}close $fset f [open exit w]puts $f {    exit $argv}close $f# Basic operations.test exec-1.1 {basic exec operation} {    exec $tcltest echo a b c} "a b c"test exec-1.2 {pipelining} {    exec $tcltest echo a b c d | $tcltest cat | $tcltest cat} "a b c d"test exec-1.3 {pipelining} {    set a [exec $tcltest echo a b c d | $tcltest cat | $tcltest wc]    list [scan $a "%d %d %d" b c d] $b $c} {3 1 4}set arg {12345678901234567890123456789012345678901234567890}set arg "$arg$arg$arg$arg$arg$arg"test exec-1.4 {long command lines} {    exec $tcltest echo $arg} $argset arg {}# I/O redirection: input from Tcl command.test exec-2.1 {redirecting input from immediate source} {    exec $tcltest cat << "Sample text"} {Sample text}test exec-2.2 {redirecting input from immediate source} {    exec << "Sample text" $tcltest cat | $tcltest cat} {Sample text}test exec-2.3 {redirecting input from immediate source} {    exec $tcltest cat << "Sample text" | $tcltest cat} {Sample text}test exec-2.4 {redirecting input from immediate source} {    exec $tcltest cat | $tcltest cat << "Sample text"} {Sample text}test exec-2.5 {redirecting input from immediate source} {    exec $tcltest cat "<<Joined to arrows"} {Joined to arrows}# I/O redirection: output to file.file delete gorp.filetest exec-3.1 {redirecting output to file} {    exec $tcltest echo "Some simple words" > gorp.file    exec $tcltest cat gorp.file} "Some simple words"test exec-3.2 {redirecting output to file} {    exec $tcltest echo "More simple words" | >gorp.file $tcltest cat | $tcltest cat    exec $tcltest cat gorp.file} "More simple words"test exec-3.3 {redirecting output to file} {    exec > gorp.file $tcltest echo "Different simple words" | $tcltest cat | $tcltest cat    exec $tcltest cat gorp.file} "Different simple words"test exec-3.4 {redirecting output to file} {    exec $tcltest echo "Some simple words" >gorp.file    exec $tcltest cat gorp.file} "Some simple words"test exec-3.5 {redirecting output to file} {    exec $tcltest echo "First line" >gorp.file    exec $tcltest echo "Second line" >> gorp.file    exec $tcltest cat gorp.file} "First line\nSecond line"test exec-3.6 {redirecting output to file} {    exec $tcltest echo "First line" >gorp.file    exec $tcltest echo "Second line" >>gorp.file    exec $tcltest cat gorp.file} "First line\nSecond line"test exec-3.7 {redirecting output to file} {    set f [open gorp.file w]    puts $f "Line 1"    flush $f    exec $tcltest echo "More text" >@ $f    exec $tcltest echo >@$f "Even more"    puts $f "Line 3"    close $f    exec $tcltest cat gorp.file} "Line 1\nMore text\nEven more\nLine 3"# I/O redirection: output and stderr to file.file delete gorp.filetest exec-4.1 {redirecting output and stderr to file} {    exec $tcltest echo "test output" >& gorp.file    exec $tcltest cat gorp.file} "test output"test exec-4.2 {redirecting output and stderr to file} {    list [exec $tcltest sh -c "echo foo bar 1>&2" >&gorp.file] \	    [exec $tcltest cat gorp.file]} {{} {foo bar}}test exec-4.3 {redirecting output and stderr to file} {    exec $tcltest echo "first line" > gorp.file    list [exec $tcltest sh -c "echo foo bar 1>&2" >>&gorp.file] \	    [exec $tcltest cat gorp.file]} "{} {first line\nfoo bar}"test exec-4.4 {redirecting output and stderr to file} {    set f [open gorp.file w]    puts $f "Line 1"    flush $f    exec $tcltest echo "More text" >&@ $f    exec $tcltest echo >&@$f "Even more"    puts $f "Line 3"    close $f    exec $tcltest cat gorp.file} "Line 1\nMore text\nEven more\nLine 3"test exec-4.5 {redirecting output and stderr to file} {    set f [open gorp.file w]    puts $f "Line 1"    flush $f    exec >&@ $f $tcltest sh -c "echo foo bar 1>&2"    exec >&@$f $tcltest sh -c "echo xyzzy 1>&2"    puts $f "Line 3"    close $f    exec $tcltest cat gorp.file} "Line 1\nfoo bar\nxyzzy\nLine 3"# I/O redirection: input from file.exec $tcltest echo "Just a few thoughts" > gorp.filetest exec-5.1 {redirecting input from file} {    exec $tcltest cat < gorp.file} {Just a few thoughts}test exec-5.2 {redirecting input from file} {    exec $tcltest cat | $tcltest cat < gorp.file} {Just a few thoughts}test exec-5.3 {redirecting input from file} {    exec $tcltest cat < gorp.file | $tcltest cat} {Just a few thoughts}test exec-5.4 {redirecting input from file} {    exec < gorp.file $tcltest cat | $tcltest cat} {Just a few thoughts}test exec-5.5 {redirecting input from file} {    exec $tcltest cat <gorp.file} {Just a few thoughts}test exec-5.6 {redirecting input from file} {    set f [open gorp.file r]    set result [exec $tcltest cat <@ $f]    close $f    set result} {Just a few thoughts}test exec-5.7 {redirecting input from file} {    set f [open gorp.file r]    set result [exec <@$f $tcltest cat]    close $f    set result} {Just a few thoughts}# I/O redirection: standard error through a pipeline.test exec-6.1 {redirecting stderr through a pipeline} {    exec $tcltest sh -c "echo foo bar" |& $tcltest cat} "foo bar"test exec-6.2 {redirecting stderr through a pipeline} {    exec $tcltest sh -c "echo foo bar 1>&2" |& $tcltest cat} "foo bar"test exec-6.3 {redirecting stderr through a pipeline} {    exec $tcltest sh -c "echo foo bar 1>&2" \	|& $tcltest sh -c "echo second msg 1>&2 ; cat" |& $tcltest cat} "second msg\nfoo bar"# I/O redirection: combinations.catch {exec rm -f gorp.file2}test exec-7.1 {multiple I/O redirections} {    exec << "command input" > gorp.file2 $tcltest cat < gorp.file    exec $tcltest cat gorp.file2} {Just a few thoughts}test exec-7.2 {multiple I/O redirections} {    exec < gorp.file << "command input" $tcltest cat} {command input}# Long input to command and output from command.set a "0123456789 xxxxxxxxx abcdefghi ABCDEFGHIJK\n"set a [concat $a $a $a $a]set a [concat $a $a $a $a]set a [concat $a $a $a $a]

⌨️ 快捷键说明

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