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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [lib/] [libsim.exp] - Blame information for rev 95

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 93 jeremybenn
# Or1ksim library expect test functions for use with DejaGNU under automake
2
 
3
# Copyright (C) 2010 Embecosm Limited
4
 
5
# Contributor Jeremy Bennett 
6
 
7
# This file is part of OpenRISC 1000 Architectural Simulator.
8
 
9
# This program is free software; you can redistribute it and/or modify it
10
# under the terms of the GNU General Public License as published by the Free
11
# Software Foundation; either version 3 of the License, or (at your option)
12
# any later version.
13
 
14
# This program is distributed in the hope that it will be useful, but WITHOUT
15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17
# more details.
18
 
19
# You should have received a copy of the GNU General Public License along
20
# with this program.  If not, see .  */
21
 
22
# -----------------------------------------------------------------------------
23
# This code is commented throughout for use with Doxygen.
24
# -----------------------------------------------------------------------------
25
 
26
 
27
# -----------------------------------------------------------------------------
28
#! Run a libor1ksim program with the supplied config_file and target program.
29
#
30
#! @param[in] testname    The name of the test
31
#! @param[in] match_list  A list of expected responses
32
#! @param[in] libprog     The libor1ksim program
33
#! @param[in] config      The or1ksim config file to use
34
#! @param[in] or1kprog    The program image to use on libprog
35
#! @param[in] args        Any other arguments
36
# -----------------------------------------------------------------------------
37
proc run_libsim { testname match_list libprog config or1kprog args } {
38
    global verbose
39 95 jeremybenn
    global srcdir
40
    global objdir
41 93 jeremybenn
 
42
    # Construct the config filename or use the default
43
    if {0 == [string length $config]} {
44
        set config "default.cfg";
45
    }
46
 
47 95 jeremybenn
    set libprog_name  "$objdir/test-code/$libprog"
48
    set config_name   "$srcdir/libsim.tests/$config";
49
    set or1kprog_name "$objdir/test-code-or1k/$or1kprog"
50 93 jeremybenn
 
51
    set command_line "$libprog_name $config_name $or1kprog_name $args"
52
 
53
    if { $verbose > 1 } {
54
        send_user "starting $command_line\n"
55
    }
56
 
57
    # Run the program.
58
    eval "spawn $command_line"
59
 
60
    # Try each matchstr in turn, counting the lines for error reporting
61
    set match_line 0;
62
 
63
    foreach matchstr $match_list {
64
 
65
        set match_line [expr {$match_line + 1}];
66
 
67
        if { $verbose > 2 } {
68
            send_user "matching |$matchstr|\n";
69
        }
70
 
71
        expect {
72
 
73
            $matchstr {
74
                # String to match. Silently accept. Do first, so we can match
75
                # specific warnings or errors if desired
76
            }
77
 
78
            -re "Warning" {
79
                fail "$testname: warning: $expect_out(buffer)";
80
                return
81
            }
82
 
83
            -re "ERROR" {
84
                fail "$testname: error: $expect_out(buffer)";
85
                return
86
            }
87
 
88
            eof {
89
                fail "$testname: hit EOF seeking match line $match_line";
90
                return
91
            }
92
 
93
            timeout {
94
                perror "Timeout";
95 95 jeremybenn
                unresolved "$testname: timeout";
96 93 jeremybenn
                return
97
            }
98
        }
99
    }
100
 
101
    # If we get here we've passed
102
    pass $testname;
103
 
104
}
105
 
106
# Timeout 3 seconds is plenty as default
107
set timeout 3

powered by: WebSVN 2.1.0

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