OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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
            -re "Warning" {
70
                fail "$testname: warning: $expect_out(buffer)";
71
                return
72
            }
73
 
74
            -re "ERROR" {
75
                fail "$testname: error: $expect_out(buffer)";
76
                return
77
            }
78
 
79
            $matchstr {
80
                # String to match. Silently accept
81
            }
82
 
83
            eof {
84
                fail "$testname: hit EOF seeking match line $match_line";
85
                return
86
            }
87
 
88
            timeout {
89
                perror "Timeout";
90
                fail "$testname: timeout";
91
                return
92
            }
93
        }
94
    }
95
 
96
    # If we get here we've passed
97
    pass $testname;
98
 
99
}
100
 
101
# Timeout 3 seconds is plenty as default
102
set timeout 3

powered by: WebSVN 2.1.0

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