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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [tools/] [tcl/] [rw11/] [tbench.tcl] - Blame information for rev 38

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 wfjm
# $Id: tbench.tcl 702 2015-07-19 17:36:09Z mueller $
2 20 wfjm
#
3 30 wfjm
# Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 20 wfjm
#
5
# This program is free software; you may redistribute and/or modify it under
6
# the terms of the GNU General Public License as published by the Free
7
# Software Foundation, either version 2, or at your option any later version.
8
#
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
# for complete details.
13
#
14
#  Revision History:
15
# Date         Rev Version  Comment
16 31 wfjm
# 2015-05-17   683   2.2    support sub directories and return in tests
17 30 wfjm
# 2015-05-09   676   2.1    use 'rlc log -bare' instead of 'puts'
18 27 wfjm
# 2014-11-30   607   2.0    use new rlink v4 iface
19 20 wfjm
# 2013-04-26   510   1.0    Initial version (extracted from util.tcl)
20
#
21
 
22
package provide rw11 1.0
23
 
24
package require rlink
25
package require rwxxtpp
26
 
27
namespace eval rw11 {
28
 
29
  #
30
  # tbench: driver for tbench scripts
31
  #
32 31 wfjm
  proc tbench {tname} {
33
    set fname $tname
34
    set tbase "."
35
    if {[string match "@*" $tname]} {
36
      set fname [string range $tname 1 end]
37
    }
38
    if {![file exists $fname]} {set tbase "$::env(RETROBASE)/tools/tbench"}
39
 
40 27 wfjm
    rlink::anena 1;             # enable attn notify
41 31 wfjm
    set errcnt [tbench_list $tname $tbase]
42 20 wfjm
    return $errcnt
43
  }
44
 
45
  #
46
  # tbench_file: execute list of tbench steps
47
  #
48 31 wfjm
  proc tbench_list {tname tbase} {
49 20 wfjm
    set errcnt 0
50 31 wfjm
 
51
    set rname  $tname
52
    set islist 0
53
    if {[string match "@*" $tname]} {
54
      set islist 1
55
      set rname [string range $tname 1 end]
56
    }
57
 
58
    set dname [file dirname $rname]
59
    set fname [file tail    $rname]
60
    if {$dname ne "."} {
61
      set tbase [file join $tbase $dname]
62
    }
63
 
64
    if {![file readable "$tbase/$fname"]} {
65 34 wfjm
      puts "-E: file $tbase/$fname not found or readable"
66 31 wfjm
      error "-E: file $tbase/$fname not found or readable"
67
    }
68
 
69
    if {$islist} {
70
      set fh [open "$tbase/$fname"]
71 20 wfjm
      while {[gets $fh line] >= 0} {
72
        if {[string match "#*" $line]} {
73 30 wfjm
          if {[string match "##*" $line]} { rlc log -bare $line }
74 20 wfjm
        } elseif {[string match "@*" $line]} {
75 31 wfjm
          incr errcnt [tbench_list $line $tbase]
76 20 wfjm
        } else {
77 31 wfjm
          incr errcnt [tbench_step $line $tbase]
78 20 wfjm
        }
79
      }
80
      close $fh
81 31 wfjm
 
82 20 wfjm
    } else {
83 31 wfjm
      incr errcnt [tbench_step $fname $tbase]
84 20 wfjm
    }
85 31 wfjm
 
86
    if {$islist} {
87
      rlc log -bare [format "%s: %s" $tname [rutil::errcnt2txt $errcnt]]
88
    }
89 20 wfjm
    return $errcnt
90
  }
91
 
92
  #
93
  # tbench_step: execute single tbench step
94
  #
95 31 wfjm
  proc tbench_step {fname tbase} {
96
    if {![file readable "$tbase/$fname"]} {
97
      error "-E: file $tbase/$fname not found or readable"
98
    }
99
 
100
    # cleanup any remaining temporary procs with names tmpproc_* 
101
    foreach pname [info procs tmpproc_*] { rename $pname "" }
102
 
103 20 wfjm
    rlc errcnt -clear
104 31 wfjm
    set cpu "cpu0"
105
    set ecode [catch "source $tbase/$fname" resmsg]
106 20 wfjm
    set errcnt [rlc errcnt]
107 31 wfjm
 
108
    switch $ecode {
109
 
110
      1  { puts "-E: test execution FAILED with error message:"
111
           if {[info exists errorInfo]} {puts $errorInfo} else {puts $resmsg}
112
           incr errcnt
113
         }
114
      2  { puts "-I: test ended by return: $resmsg"}
115
      default  {
116
           puts "-E: test execution FAILED with catch code $ecode"
117
           incr errcnt
118
         }
119
    }
120
 
121
    # remove temporary procs with names tmpproc_* 
122
    foreach pname [info procs tmpproc_*] { rename $pname "" }
123
 
124 30 wfjm
    rlc log -bare [format "%s: %s" $fname [rutil::errcnt2txt $errcnt]]
125 20 wfjm
    return $errcnt
126
  }
127
 
128
}

powered by: WebSVN 2.1.0

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