OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [tests/] [defs] - Diff between revs 578 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 578 Rev 1765
# This file contains support code for the Tcl test suite.  It is
# This file contains support code for the Tcl test suite.  It is
# normally sourced by the individual files in the test suite before
# normally sourced by the individual files in the test suite before
# they run their tests.  This improved approach to testing was designed
# they run their tests.  This improved approach to testing was designed
# and initially implemented by Mary Ann May-Pumphrey of Sun Microsystems.
# and initially implemented by Mary Ann May-Pumphrey of Sun Microsystems.
#
#
# Copyright (c) 1990-1994 The Regents of the University of California.
# Copyright (c) 1990-1994 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
#
#
# See the file "license.terms" for information on usage and redistribution
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#
# RCS: @(#) $Id: defs,v 1.1.1.1 2002-01-16 10:25:35 markom Exp $
# RCS: @(#) $Id: defs,v 1.1.1.1 2002-01-16 10:25:35 markom Exp $
if ![info exists srcdir] {
if ![info exists srcdir] {
    set srcdir .
    set srcdir .
}
}
if ![info exists VERBOSE] {
if ![info exists VERBOSE] {
    set VERBOSE 0
    set VERBOSE 0
}
}
if ![info exists TESTS] {
if ![info exists TESTS] {
    set TESTS {}
    set TESTS {}
}
}
# If tests are being run as root, issue a warning message and set a
# If tests are being run as root, issue a warning message and set a
# variable to prevent some tests from running at all.
# variable to prevent some tests from running at all.
set user {}
set user {}
if {$tcl_platform(platform) == "unix"} {
if {$tcl_platform(platform) == "unix"} {
    catch {set user [exec whoami]}
    catch {set user [exec whoami]}
    if {$user == ""} {
    if {$user == ""} {
        catch {regexp {^[^(]*\(([^)]*)\)} [exec id] dummy user}
        catch {regexp {^[^(]*\(([^)]*)\)} [exec id] dummy user}
    }
    }
    if {$user == ""} {set user root}
    if {$user == ""} {set user root}
    if {$user == "root"} {
    if {$user == "root"} {
        puts stdout "Warning: you're executing as root.  I'll have to"
        puts stdout "Warning: you're executing as root.  I'll have to"
        puts stdout "skip some of the tests, since they'll fail as root."
        puts stdout "skip some of the tests, since they'll fail as root."
        set testConfig(root) 1
        set testConfig(root) 1
    }
    }
}
}
# Some of the tests don't work on some system configurations due to
# Some of the tests don't work on some system configurations due to
# differences in word length, file system configuration, etc.  In order
# differences in word length, file system configuration, etc.  In order
# to prevent false alarms, these tests are generally only run in the
# to prevent false alarms, these tests are generally only run in the
# master development directory for Tcl.  The presence of a file
# master development directory for Tcl.  The presence of a file
# "doAllTests" in this directory is used to indicate that the non-portable
# "doAllTests" in this directory is used to indicate that the non-portable
# tests should be run.
# tests should be run.
# If there is no "memory" command (because memory debugging isn't
# If there is no "memory" command (because memory debugging isn't
# enabled), generate a dummy command that does nothing.
# enabled), generate a dummy command that does nothing.
if {[info commands memory] == ""} {
if {[info commands memory] == ""} {
    proc memory args {}
    proc memory args {}
}
}
# Check configuration information that will determine which tests
# Check configuration information that will determine which tests
# to run.  To do this, create an array testConfig.  Each element
# to run.  To do this, create an array testConfig.  Each element
# has a 0 or 1 value, and the following elements are defined:
# has a 0 or 1 value, and the following elements are defined:
#       unixOnly -      1 means this is a UNIX platform, so it's OK
#       unixOnly -      1 means this is a UNIX platform, so it's OK
#                       to run tests that only work under UNIX.
#                       to run tests that only work under UNIX.
#       macOnly -       1 means this is a Mac platform, so it's OK
#       macOnly -       1 means this is a Mac platform, so it's OK
#                       to run tests that only work on Macs.
#                       to run tests that only work on Macs.
#       pcOnly -        1 means this is a PC platform, so it's OK to
#       pcOnly -        1 means this is a PC platform, so it's OK to
#                       run tests that only work on PCs.
#                       run tests that only work on PCs.
#       unixOrPc -      1 means this is a UNIX or PC platform.
#       unixOrPc -      1 means this is a UNIX or PC platform.
#       macOrPc -       1 means this is a Mac or PC platform.
#       macOrPc -       1 means this is a Mac or PC platform.
#       macOrUnix -     1 means this is a Mac or UNIX platform.
#       macOrUnix -     1 means this is a Mac or UNIX platform.
#       nonPortable -   1 means this the tests are being running in
#       nonPortable -   1 means this the tests are being running in
#                       the master Tcl/Tk development environment;
#                       the master Tcl/Tk development environment;
#                       Some tests are inherently non-portable because
#                       Some tests are inherently non-portable because
#                       they depend on things like word length, file system
#                       they depend on things like word length, file system
#                       configuration, window manager, etc.  These tests
#                       configuration, window manager, etc.  These tests
#                       are only run in the main Tcl development directory
#                       are only run in the main Tcl development directory
#                       where the configuration is well known.  The presence
#                       where the configuration is well known.  The presence
#                       of the file "doAllTests" in this directory indicates
#                       of the file "doAllTests" in this directory indicates
#                       that it is safe to run non-portable tests.
#                       that it is safe to run non-portable tests.
#       knownBug -      The test is known to fail and the bug is not yet
#       knownBug -      The test is known to fail and the bug is not yet
#                       fixed. The test will be run only if the file
#                       fixed. The test will be run only if the file
#                       "doBuggyTests" exists (intended for Tcl dev. group
#                       "doBuggyTests" exists (intended for Tcl dev. group
#                       internal use only).
#                       internal use only).
#       tempNotPc -     The inverse of pcOnly.  This flag is used to
#       tempNotPc -     The inverse of pcOnly.  This flag is used to
#                       temporarily disable a test.
#                       temporarily disable a test.
#       tempNotMac -    The inverse of macOnly.  This flag is used to
#       tempNotMac -    The inverse of macOnly.  This flag is used to
#                       temporarily disable a test.
#                       temporarily disable a test.
#       nonBlockFiles - 1 means this platform supports setting files into
#       nonBlockFiles - 1 means this platform supports setting files into
#                       nonblocking mode.
#                       nonblocking mode.
#       asyncPipeClose- 1 means this platform supports async flush and
#       asyncPipeClose- 1 means this platform supports async flush and
#                       async close on a pipe.
#                       async close on a pipe.
#       unixExecs     - 1 means this machine has commands such as 'cat',
#       unixExecs     - 1 means this machine has commands such as 'cat',
#                       'echo' etc available.
#                       'echo' etc available.
#       notIfCompiled - 1 means this that it is safe to run tests that
#       notIfCompiled - 1 means this that it is safe to run tests that
#                       might fail if the bytecode compiler is used. This
#                       might fail if the bytecode compiler is used. This
#                       element is set 1 if the file "doAllTests" exists in
#                       element is set 1 if the file "doAllTests" exists in
#                       this directory. Normally, this element is 0 so that
#                       this directory. Normally, this element is 0 so that
#                       tests that fail with the bytecode compiler are
#                       tests that fail with the bytecode compiler are
#                       skipped. As of 11/2/96 these are the history tests
#                       skipped. As of 11/2/96 these are the history tests
#                       since they depend on accurate source location
#                       since they depend on accurate source location
#                       information.
#                       information.
catch {unset testConfig}
catch {unset testConfig}
if {$tcl_platform(platform) == "unix"} {
if {$tcl_platform(platform) == "unix"} {
    set testConfig(unixOnly) 1
    set testConfig(unixOnly) 1
    set testConfig(tempNotPc) 1
    set testConfig(tempNotPc) 1
    set testConfig(tempNotMac) 1
    set testConfig(tempNotMac) 1
} else {
} else {
    set testConfig(unixOnly) 0
    set testConfig(unixOnly) 0
}
}
if {$tcl_platform(platform) == "macintosh"} {
if {$tcl_platform(platform) == "macintosh"} {
    set testConfig(tempNotPc) 1
    set testConfig(tempNotPc) 1
    set testConfig(macOnly) 1
    set testConfig(macOnly) 1
} else {
} else {
    set testConfig(macOnly) 0
    set testConfig(macOnly) 0
}
}
if {$tcl_platform(platform) == "windows"} {
if {$tcl_platform(platform) == "windows"} {
    set testConfig(tempNotMac) 1
    set testConfig(tempNotMac) 1
    set testConfig(pcOnly) 1
    set testConfig(pcOnly) 1
} else {
} else {
    set testConfig(pcOnly) 0
    set testConfig(pcOnly) 0
}
}
set testConfig(unixOrPc) [expr $testConfig(unixOnly) || $testConfig(pcOnly)]
set testConfig(unixOrPc) [expr $testConfig(unixOnly) || $testConfig(pcOnly)]
set testConfig(macOrPc) [expr $testConfig(macOnly) || $testConfig(pcOnly)]
set testConfig(macOrPc) [expr $testConfig(macOnly) || $testConfig(pcOnly)]
set testConfig(macOrUnix) [expr $testConfig(macOnly) || $testConfig(unixOnly)]
set testConfig(macOrUnix) [expr $testConfig(macOnly) || $testConfig(unixOnly)]
set testConfig(nonPortable)     [expr [file exists doAllTests] || [file exists doAllTe]]
set testConfig(nonPortable)     [expr [file exists doAllTests] || [file exists doAllTe]]
set testConfig(knownBug) [expr [file exists doBuggyTests] || [file exists doBuggyT]]
set testConfig(knownBug) [expr [file exists doBuggyTests] || [file exists doBuggyT]]
set testConfig(notIfCompiled) [file exists doAllCompilerTests]
set testConfig(notIfCompiled) [file exists doAllCompilerTests]
set testConfig(unix)    $testConfig(unixOnly)
set testConfig(unix)    $testConfig(unixOnly)
set testConfig(mac)     $testConfig(macOnly)
set testConfig(mac)     $testConfig(macOnly)
set testConfig(pc)      $testConfig(pcOnly)
set testConfig(pc)      $testConfig(pcOnly)
set testConfig(nt)      [expr {$tcl_platform(os) == "Windows NT"}]
set testConfig(nt)      [expr {$tcl_platform(os) == "Windows NT"}]
set testConfig(95)      [expr {$tcl_platform(os) == "Windows 95"}]
set testConfig(95)      [expr {$tcl_platform(os) == "Windows 95"}]
set testConfig(win32s)  [expr {$tcl_platform(os) == "Win32s"}]
set testConfig(win32s)  [expr {$tcl_platform(os) == "Win32s"}]
# The following config switches are used to mark tests that crash on
# The following config switches are used to mark tests that crash on
# certain platforms, so that they can be reactivated again when the
# certain platforms, so that they can be reactivated again when the
# underlying problem is fixed.
# underlying problem is fixed.
set testConfig(pcCrash) $testConfig(macOrUnix)
set testConfig(pcCrash) $testConfig(macOrUnix)
set testConfig(macCrash) $testConfig(unixOrPc)
set testConfig(macCrash) $testConfig(unixOrPc)
set testConfig(unixCrash) $testConfig(macOrPc)
set testConfig(unixCrash) $testConfig(macOrPc)
if {[catch {set f [open $srcdir/defs r]}]} {
if {[catch {set f [open $srcdir/defs r]}]} {
    set testConfig(nonBlockFiles) 1
    set testConfig(nonBlockFiles) 1
} else {
} else {
    if {[expr [catch {fconfigure $f -blocking off}]] == 0} {
    if {[expr [catch {fconfigure $f -blocking off}]] == 0} {
        set testConfig(nonBlockFiles) 1
        set testConfig(nonBlockFiles) 1
    } else {
    } else {
        set testConfig(nonBlockFiles) 0
        set testConfig(nonBlockFiles) 0
    }
    }
    close $f
    close $f
}
}
trace variable testConfig r safeFetch
trace variable testConfig r safeFetch
proc safeFetch {n1 n2 op} {
proc safeFetch {n1 n2 op} {
    global testConfig
    global testConfig
    if {($n2 != {}) && ([info exists testConfig($n2)] == 0)} {
    if {($n2 != {}) && ([info exists testConfig($n2)] == 0)} {
        set testConfig($n2) 0
        set testConfig($n2) 0
    }
    }
}
}
# Test for SCO Unix - cannot run async flushing tests because a potential
# Test for SCO Unix - cannot run async flushing tests because a potential
# problem with select is apparently interfering. (Mark Diekhans).
# problem with select is apparently interfering. (Mark Diekhans).
if {$tcl_platform(platform) == "unix"} {
if {$tcl_platform(platform) == "unix"} {
    if {[catch {exec uname -X | fgrep {Release = 3.2v}}] == 0} {
    if {[catch {exec uname -X | fgrep {Release = 3.2v}}] == 0} {
        set testConfig(asyncPipeClose) 0
        set testConfig(asyncPipeClose) 0
    } else {
    } else {
        set testConfig(asyncPipeClose) 1
        set testConfig(asyncPipeClose) 1
    }
    }
} else {
} else {
    set testConfig(asyncPipeClose) 1
    set testConfig(asyncPipeClose) 1
}
}
# Test to see if we have a broken version of sprintf with respect to the
# Test to see if we have a broken version of sprintf with respect to the
# "e" format of floating-point numbers.
# "e" format of floating-point numbers.
set testConfig(eformat) 1
set testConfig(eformat) 1
if {[string compare "[format %g 5e-5]" "5e-05"] != 0} {
if {[string compare "[format %g 5e-5]" "5e-05"] != 0} {
    set testConfig(eformat) 0
    set testConfig(eformat) 0
    puts "(will skip tests that depend on the \"e\" format of floating-point numbers)"
    puts "(will skip tests that depend on the \"e\" format of floating-point numbers)"
}
}
# Test to see if execed commands such as cat, echo, rm and so forth are
# Test to see if execed commands such as cat, echo, rm and so forth are
# present on this machine.
# present on this machine.
set testConfig(unixExecs) 1
set testConfig(unixExecs) 1
if {$tcl_platform(platform) == "macintosh"} {
if {$tcl_platform(platform) == "macintosh"} {
    set testConfig(unixExecs) 0
    set testConfig(unixExecs) 0
}
}
if {($testConfig(unixExecs) == 1) && ($tcl_platform(platform) == "windows")} {
if {($testConfig(unixExecs) == 1) && ($tcl_platform(platform) == "windows")} {
    if {[catch {exec cat $srcdir/defs}] == 1} {
    if {[catch {exec cat $srcdir/defs}] == 1} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    }
    }
    if {($testConfig(unixExecs) == 1) && ([catch {exec echo hello}] == 1)} {
    if {($testConfig(unixExecs) == 1) && ([catch {exec echo hello}] == 1)} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    }
    }
    if {($testConfig(unixExecs) == 1) && \
    if {($testConfig(unixExecs) == 1) && \
                ([catch {exec sh -c echo hello}] == 1)} {
                ([catch {exec sh -c echo hello}] == 1)} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    }
    }
    if {($testConfig(unixExecs) == 1) && ([catch {exec wc $srcdir/defs}] == 1)} {
    if {($testConfig(unixExecs) == 1) && ([catch {exec wc $srcdir/defs}] == 1)} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    }
    }
    if {$testConfig(unixExecs) == 1} {
    if {$testConfig(unixExecs) == 1} {
        exec echo hello > removeMe
        exec echo hello > removeMe
        if {[catch {exec rm removeMe}] == 1} {
        if {[catch {exec rm removeMe}] == 1} {
            set testConfig(unixExecs) 0
            set testConfig(unixExecs) 0
        }
        }
    }
    }
    if {($testConfig(unixExecs) == 1) && ([catch {exec sleep 1}] == 1)} {
    if {($testConfig(unixExecs) == 1) && ([catch {exec sleep 1}] == 1)} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    }
    }
    if {($testConfig(unixExecs) == 1) && \
    if {($testConfig(unixExecs) == 1) && \
                ([catch {exec fgrep unixExecs $srcdir/defs}] == 1)} {
                ([catch {exec fgrep unixExecs $srcdir/defs}] == 1)} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    }
    }
    if {($testConfig(unixExecs) == 1) && ([catch {exec ps}] == 1)} {
    if {($testConfig(unixExecs) == 1) && ([catch {exec ps}] == 1)} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    }
    }
    if {($testConfig(unixExecs) == 1) && \
    if {($testConfig(unixExecs) == 1) && \
                ([catch {exec echo abc > removeMe}] == 0) && \
                ([catch {exec echo abc > removeMe}] == 0) && \
                ([catch {exec chmod 644 removeMe}] == 1) && \
                ([catch {exec chmod 644 removeMe}] == 1) && \
                ([catch {exec rm removeMe}] == 0)} {
                ([catch {exec rm removeMe}] == 0)} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    } else {
    } else {
        catch {exec rm -f removeMe}
        catch {exec rm -f removeMe}
    }
    }
    if {($testConfig(unixExecs) == 1) && \
    if {($testConfig(unixExecs) == 1) && \
                ([catch {exec mkdir removeMe}] == 1)} {
                ([catch {exec mkdir removeMe}] == 1)} {
        set testConfig(unixExecs) 0
        set testConfig(unixExecs) 0
    } else {
    } else {
        catch {exec rm -r removeMe}
        catch {exec rm -r removeMe}
    }
    }
    if {$testConfig(unixExecs) == 0} {
    if {$testConfig(unixExecs) == 0} {
        puts stdout "Warning: Unix-style executables are not available, so"
        puts stdout "Warning: Unix-style executables are not available, so"
        puts stdout "some tests will be skipped."
        puts stdout "some tests will be skipped."
    }
    }
}
}
proc print_verbose {name description constraints script code answer} {
proc print_verbose {name description constraints script code answer} {
    puts stdout "\n"
    puts stdout "\n"
    if {[string length $constraints]} {
    if {[string length $constraints]} {
        puts stdout "==== $name $description\t--- ($constraints) ---"
        puts stdout "==== $name $description\t--- ($constraints) ---"
    } else {
    } else {
        puts stdout "==== $name $description"
        puts stdout "==== $name $description"
    }
    }
    puts stdout "==== Contents of test case:"
    puts stdout "==== Contents of test case:"
    puts stdout "$script"
    puts stdout "$script"
    if {$code != 0} {
    if {$code != 0} {
        if {$code == 1} {
        if {$code == 1} {
            puts stdout "==== Test generated error:"
            puts stdout "==== Test generated error:"
            puts stdout $answer
            puts stdout $answer
        } elseif {$code == 2} {
        } elseif {$code == 2} {
            puts stdout "==== Test generated return exception;  result was:"
            puts stdout "==== Test generated return exception;  result was:"
            puts stdout $answer
            puts stdout $answer
        } elseif {$code == 3} {
        } elseif {$code == 3} {
            puts stdout "==== Test generated break exception"
            puts stdout "==== Test generated break exception"
        } elseif {$code == 4} {
        } elseif {$code == 4} {
            puts stdout "==== Test generated continue exception"
            puts stdout "==== Test generated continue exception"
        } else {
        } else {
            puts stdout "==== Test generated exception $code;  message was:"
            puts stdout "==== Test generated exception $code;  message was:"
            puts stdout $answer
            puts stdout $answer
        }
        }
    } else {
    } else {
        puts stdout "==== Result was:"
        puts stdout "==== Result was:"
        puts stdout "$answer"
        puts stdout "$answer"
    }
    }
}
}
# test --
# test --
# This procedure runs a test and prints an error message if the
# This procedure runs a test and prints an error message if the
# test fails.  If VERBOSE has been set, it also prints a message
# test fails.  If VERBOSE has been set, it also prints a message
# even if the test succeeds.  The test will be skipped if it
# even if the test succeeds.  The test will be skipped if it
# doesn't match the TESTS variable, or if one of the elements
# doesn't match the TESTS variable, or if one of the elements
# of "constraints" turns out not to be true.
# of "constraints" turns out not to be true.
#
#
# Arguments:
# Arguments:
# name -                Name of test, in the form foo-1.2.
# name -                Name of test, in the form foo-1.2.
# description -         Short textual description of the test, to
# description -         Short textual description of the test, to
#                       help humans understand what it does.
#                       help humans understand what it does.
# constraints -         A list of one or more keywords, each of
# constraints -         A list of one or more keywords, each of
#                       which must be the name of an element in
#                       which must be the name of an element in
#                       the array "testConfig".  If any of these
#                       the array "testConfig".  If any of these
#                       elements is zero, the test is skipped.
#                       elements is zero, the test is skipped.
#                       This argument may be omitted.
#                       This argument may be omitted.
# script -              Script to run to carry out the test.  It must
# script -              Script to run to carry out the test.  It must
#                       return a result that can be checked for
#                       return a result that can be checked for
#                       correctness.
#                       correctness.
# answer -              Expected result from script.
# answer -              Expected result from script.
proc test {name description script answer args} {
proc test {name description script answer args} {
    global VERBOSE TESTS testConfig
    global VERBOSE TESTS testConfig
    if {[string compare $TESTS ""] != 0} then {
    if {[string compare $TESTS ""] != 0} then {
        set ok 0
        set ok 0
        foreach test $TESTS {
        foreach test $TESTS {
            if [string match $test $name] then {
            if [string match $test $name] then {
                set ok 1
                set ok 1
                break
                break
            }
            }
        }
        }
        if !$ok then return
        if !$ok then return
    }
    }
    set i [llength $args]
    set i [llength $args]
    if {$i == 0} {
    if {$i == 0} {
        set constraints {}
        set constraints {}
    } elseif {$i == 1} {
    } elseif {$i == 1} {
        # "constraints" argument exists;  shuffle arguments down, then
        # "constraints" argument exists;  shuffle arguments down, then
        # make sure that the constraints are satisfied.
        # make sure that the constraints are satisfied.
        set constraints $script
        set constraints $script
        set script $answer
        set script $answer
        set answer [lindex $args 0]
        set answer [lindex $args 0]
        set doTest 0
        set doTest 0
        if {[string match {*[$\[]*} $constraints] != 0} {
        if {[string match {*[$\[]*} $constraints] != 0} {
            # full expression, e.g. {$foo > [info tclversion]}
            # full expression, e.g. {$foo > [info tclversion]}
            catch {set doTest [uplevel #0 expr [list $constraints]]} msg
            catch {set doTest [uplevel #0 expr [list $constraints]]} msg
        } elseif {[regexp {[^.a-zA-Z0-9 ]+} $constraints] != 0} {
        } elseif {[regexp {[^.a-zA-Z0-9 ]+} $constraints] != 0} {
            # something like {a || b} should be turned into
            # something like {a || b} should be turned into
            # $testConfig(a) || $testConfig(b).
            # $testConfig(a) || $testConfig(b).
            regsub -all {[.a-zA-Z0-9]+} $constraints {$testConfig(&)} c
            regsub -all {[.a-zA-Z0-9]+} $constraints {$testConfig(&)} c
            catch {set doTest [eval expr $c]}
            catch {set doTest [eval expr $c]}
        } else {
        } else {
            # just simple constraints such as {unixOnly fonts}.
            # just simple constraints such as {unixOnly fonts}.
            set doTest 1
            set doTest 1
            foreach constraint $constraints {
            foreach constraint $constraints {
                if {![info exists testConfig($constraint)]
                if {![info exists testConfig($constraint)]
                        || !$testConfig($constraint)} {
                        || !$testConfig($constraint)} {
                    set doTest 0
                    set doTest 0
                    break
                    break
                }
                }
            }
            }
        }
        }
        if {$doTest == 0} {
        if {$doTest == 0} {
            if $VERBOSE then {
            if $VERBOSE then {
                puts stdout "++++ $name SKIPPED: $constraints"
                puts stdout "++++ $name SKIPPED: $constraints"
            }
            }
            return
            return
        }
        }
    } else {
    } else {
        error "wrong # args: must be \"test name description ?constraints? script answer\""
        error "wrong # args: must be \"test name description ?constraints? script answer\""
    }
    }
    memory tag $name
    memory tag $name
    set code [catch {uplevel $script} result]
    set code [catch {uplevel $script} result]
    if {$code != 0} {
    if {$code != 0} {
        print_verbose $name $description $constraints $script \
        print_verbose $name $description $constraints $script \
                $code $result
                $code $result
    } elseif {[string compare $result $answer] == 0} then {
    } elseif {[string compare $result $answer] == 0} then {
        if $VERBOSE then {
        if $VERBOSE then {
            if {$VERBOSE > 0} {
            if {$VERBOSE > 0} {
                print_verbose $name $description $constraints $script \
                print_verbose $name $description $constraints $script \
                    $code $result
                    $code $result
            }
            }
            if {$VERBOSE != -2} {
            if {$VERBOSE != -2} {
                puts stdout "++++ $name PASSED"
                puts stdout "++++ $name PASSED"
            }
            }
        }
        }
    } else {
    } else {
        print_verbose $name $description $constraints $script \
        print_verbose $name $description $constraints $script \
                $code $result
                $code $result
        puts stdout "---- Result should have been:"
        puts stdout "---- Result should have been:"
        puts stdout "$answer"
        puts stdout "$answer"
        puts stdout "---- $name FAILED"
        puts stdout "---- $name FAILED"
    }
    }
}
}
proc dotests {file args} {
proc dotests {file args} {
    global TESTS
    global TESTS
    set savedTests $TESTS
    set savedTests $TESTS
    set TESTS $args
    set TESTS $args
    source $file
    source $file
    set TESTS $savedTests
    set TESTS $savedTests
}
}
proc normalizeMsg {msg} {
proc normalizeMsg {msg} {
    regsub "\n$" [string tolower $msg] "" msg
    regsub "\n$" [string tolower $msg] "" msg
    regsub -all "\n\n" $msg "\n" msg
    regsub -all "\n\n" $msg "\n" msg
    regsub -all "\n\}" $msg "\}" msg
    regsub -all "\n\}" $msg "\}" msg
    return $msg
    return $msg
}
}
proc makeFile {contents name} {
proc makeFile {contents name} {
    set fd [open $name w]
    set fd [open $name w]
    fconfigure $fd -translation lf
    fconfigure $fd -translation lf
    if {[string index $contents [expr [string length $contents] - 1]] == "\n"} {
    if {[string index $contents [expr [string length $contents] - 1]] == "\n"} {
        puts -nonewline $fd $contents
        puts -nonewline $fd $contents
    } else {
    } else {
        puts $fd $contents
        puts $fd $contents
    }
    }
    close $fd
    close $fd
}
}
proc removeFile {name} {
proc removeFile {name} {
    file delete $name
    file delete $name
}
}
proc makeDirectory {name} {
proc makeDirectory {name} {
    file mkdir $name
    file mkdir $name
}
}
proc removeDirectory {name} {
proc removeDirectory {name} {
    file delete -force $name
    file delete -force $name
}
}
proc viewFile {name} {
proc viewFile {name} {
    global tcl_platform testConfig
    global tcl_platform testConfig
    if {($tcl_platform(platform) == "macintosh") || \
    if {($tcl_platform(platform) == "macintosh") || \
                ($testConfig(unixExecs) == 0)} {
                ($testConfig(unixExecs) == 0)} {
        set f [open $name]
        set f [open $name]
        set data [read -nonewline $f]
        set data [read -nonewline $f]
        close $f
        close $f
        return $data
        return $data
    } else {
    } else {
        exec cat $name
        exec cat $name
    }
    }
}
}
# Locate tcltest executable
# Locate tcltest executable
set tcltest [info nameofexecutable]
set tcltest [info nameofexecutable]
if {$tcltest == "{}"} {
if {$tcltest == "{}"} {
    set tcltest {}
    set tcltest {}
    puts "Unable to find tcltest executable, multiple process tests will fail."
    puts "Unable to find tcltest executable, multiple process tests will fail."
}
}
if {$tcl_platform(os) != "Win32s"} {
if {$tcl_platform(os) != "Win32s"} {
    # Don't even try running another copy of tcltest under win32s, or you
    # Don't even try running another copy of tcltest under win32s, or you
    # get an error dialog about multiple instances.
    # get an error dialog about multiple instances.
    catch {
    catch {
        file delete -force tmp
        file delete -force tmp
        set f [open tmp w]
        set f [open tmp w]
        puts $f {
        puts $f {
            exit
            exit
        }
        }
        close $f
        close $f
        set f [open "|[list $tcltest tmp]" r]
        set f [open "|[list $tcltest tmp]" r]
        close $f
        close $f
        set testConfig(stdio) 1
        set testConfig(stdio) 1
    }
    }
    catch {file delete -force tmp}
    catch {file delete -force tmp}
}
}
if {($tcl_platform(platform) == "windows") && ($testConfig(stdio) == 0)} {
if {($tcl_platform(platform) == "windows") && ($testConfig(stdio) == 0)} {
    puts "(will skip tests that redirect stdio of exec'd 32-bit applications)"
    puts "(will skip tests that redirect stdio of exec'd 32-bit applications)"
}
}
catch {socket} msg
catch {socket} msg
set testConfig(socket) [expr {$msg != "sockets are not available on this system"}]
set testConfig(socket) [expr {$msg != "sockets are not available on this system"}]
if {$testConfig(socket) == 0} {
if {$testConfig(socket) == 0} {
    puts "(will skip tests that use sockets)"
    puts "(will skip tests that use sockets)"
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.