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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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