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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 wfjm
# $Id: tbench.tcl 683 2015-05-17 21:54:35Z 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
      error "-E: file $tbase/$fname not found or readable"
66
    }
67
 
68
    if {$islist} {
69
      set fh [open "$tbase/$fname"]
70 20 wfjm
      while {[gets $fh line] >= 0} {
71
        if {[string match "#*" $line]} {
72 30 wfjm
          if {[string match "##*" $line]} { rlc log -bare $line }
73 20 wfjm
        } elseif {[string match "@*" $line]} {
74 31 wfjm
          incr errcnt [tbench_list $line $tbase]
75 20 wfjm
        } else {
76 31 wfjm
          incr errcnt [tbench_step $line $tbase]
77 20 wfjm
        }
78
      }
79
      close $fh
80 31 wfjm
 
81 20 wfjm
    } else {
82 31 wfjm
      incr errcnt [tbench_step $fname $tbase]
83 20 wfjm
    }
84 31 wfjm
 
85
    if {$islist} {
86
      rlc log -bare [format "%s: %s" $tname [rutil::errcnt2txt $errcnt]]
87
    }
88 20 wfjm
    return $errcnt
89
  }
90
 
91
  #
92
  # tbench_step: execute single tbench step
93
  #
94 31 wfjm
  proc tbench_step {fname tbase} {
95
    if {![file readable "$tbase/$fname"]} {
96
      error "-E: file $tbase/$fname not found or readable"
97
    }
98
 
99
    # cleanup any remaining temporary procs with names tmpproc_* 
100
    foreach pname [info procs tmpproc_*] { rename $pname "" }
101
 
102 20 wfjm
    rlc errcnt -clear
103 31 wfjm
    set cpu "cpu0"
104
    set ecode [catch "source $tbase/$fname" resmsg]
105 20 wfjm
    set errcnt [rlc errcnt]
106 31 wfjm
 
107
    switch $ecode {
108
 
109
      1  { puts "-E: test execution FAILED with error message:"
110
           if {[info exists errorInfo]} {puts $errorInfo} else {puts $resmsg}
111
           incr errcnt
112
         }
113
      2  { puts "-I: test ended by return: $resmsg"}
114
      default  {
115
           puts "-E: test execution FAILED with catch code $ecode"
116
           incr errcnt
117
         }
118
    }
119
 
120
    # remove temporary procs with names tmpproc_* 
121
    foreach pname [info procs tmpproc_*] { rename $pname "" }
122
 
123 30 wfjm
    rlc log -bare [format "%s: %s" $fname [rutil::errcnt2txt $errcnt]]
124 20 wfjm
    return $errcnt
125
  }
126
 
127
}

powered by: WebSVN 2.1.0

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