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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 82 jeremybenn
# Or1ksim expect test functiosn 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 program on Or1ksim with the supplied config_file
29
#
30
#! @param[in] testname    The name of the test
31
#! @param[in] match_list  A list of expected responses
32
#! @param[in] config_file The or1ksim config file to use
33
# !@param[in] progname    The program image to use on Or1ksim
34
# -----------------------------------------------------------------------------
35
proc run_or1ksim { testname match_list config_file progname } {
36
    global verbose
37 95 jeremybenn
    global srcdir
38
    global objdir
39 82 jeremybenn
 
40
    # Construct the filename
41
    if {0 == [string length $config_file]} {
42 95 jeremybenn
        set config_full_file "$srcdir/or1ksim.tests/default.cfg";
43 82 jeremybenn
    } else {
44 95 jeremybenn
        set config_full_file "$srcdir/or1ksim.tests/$config_file";
45 82 jeremybenn
    }
46
 
47 95 jeremybenn
    set prog_full_name "$objdir/test-code-or1k/$progname"
48
    set command_line "$objdir/../sim -f $config_full_file $prog_full_name"
49 82 jeremybenn
 
50
    if { $verbose > 1 } {
51
        send_user "starting $command_line\n"
52
    }
53
 
54
    # Run the program.
55
    eval "spawn $command_line"
56
 
57
    # Try each matchstr in turn, counting the lines for error reporting
58
    set match_line 0;
59
 
60
    foreach matchstr $match_list {
61
 
62
        set match_line [expr {$match_line + 1}];
63
 
64
#       send_user "matching |$matchstr|\n";
65
 
66
        expect {
67
 
68 93 jeremybenn
            $matchstr {
69
                # String to match. Silently accept. Do first, so we can match
70
                # specific warnings or errors if desired
71
            }
72
 
73 82 jeremybenn
            -re "Warning" {
74
                fail "$testname: warning: $expect_out(buffer)";
75
                return
76
            }
77
 
78
            -re "ERROR" {
79
                fail "$testname: error: $expect_out(buffer)";
80
                return
81
            }
82
 
83
            eof {
84
                fail "$testname: hit EOF seeking match line $match_line";
85
                return
86
            }
87
 
88
            timeout {
89 95 jeremybenn
                unresolved "$testname: timeout";
90 82 jeremybenn
                return
91
            }
92
        }
93
    }
94
 
95
    # If we get here we've passed
96
    pass $testname;
97
 
98
}
99
 
100
# Timeout 3 seconds is plenty as default
101
set timeout 3

powered by: WebSVN 2.1.0

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