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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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