~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/test/lib/llvm.exp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This procedure executes one line of a test case's execution script.
 
2
proc execOneLine { test PRS outcome lineno line } {
 
3
  set status 0
 
4
  set resultmsg ""
 
5
  set retval [ catch { eval exec -keepnewline -- $line } errmsg ]
 
6
  if { $retval != 0 } {
 
7
    set code [lindex $::errorCode 0]
 
8
    set lineno [expr $lineno + 1]
 
9
    if { $PRS != ""} {
 
10
      set PRS " for $PRS"
 
11
    }
 
12
    set errmsg " at line $lineno\nwhile running: $line\n$errmsg"
 
13
    switch "$code" {
 
14
      CHILDSTATUS {
 
15
        set status [lindex $::errorCode 2]
 
16
        if { $status != 0 } {
 
17
          set resultmsg "$test$PRS\nFailed with exit($status)$errmsg"
 
18
        }
 
19
      }
 
20
      CHILDKILLED {
 
21
        set signal [lindex $::errorCode 2]
 
22
        set resultmsg "$test$PRS\nFailed with signal($signal)$errmsg"
 
23
      }
 
24
      CHILDSUSP {
 
25
        set signal [lindex $::errorCode 2]
 
26
        set resultmsg "$test$PRS\nFailed with suspend($signal)$errmsg"
 
27
      }
 
28
      POSIX {
 
29
        set posixNum [lindex $::errorCode 1]
 
30
        set posixMsg [lindex $::errorCode 2]
 
31
        set resultmsg "$test$PRS\nFailed with posix($posixNum,$posixMsg)$errmsg"
 
32
      }
 
33
      NONE {
 
34
        # Any other error such as stderr output of a program, or syntax error in
 
35
        # the RUN line.
 
36
        set resultmsg "$test$PRS\nFailed with unknown error (or has stderr output)$errmsg"
 
37
      }
 
38
      default {
 
39
        set resultmsg "$test$PRS\nFailed with unknown error$errmsg"
 
40
      }
 
41
    }
 
42
  }
 
43
  return $resultmsg
 
44
}
 
45
 
 
46
# This procedure performs variable substitutions on the RUN: lines of a test
 
47
# cases.
 
48
proc substitute { line test tmpFile } {
 
49
  global srcroot objroot srcdir objdir subdir target_triplet
 
50
  global llvmgcc llvmgxx ocamlopt
 
51
  global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir
 
52
  global llvmdsymutil valgrind grep gas bugpoint_topts
 
53
  set path [file join $srcdir $subdir]
 
54
 
 
55
  # Substitute all Tcl variables.
 
56
  set new_line [subst $line ]
 
57
 
 
58
  #replace %% with _#MARKER#_ to make the replacement of %% more predictable
 
59
  regsub -all {%%} $new_line {_#MARKER#_} new_line
 
60
  #replace %llvmgcc_only with actual path to llvmgcc
 
61
  regsub -all {%llvmgcc_only} $new_line "$llvmgcc" new_line
 
62
  #replace %llvmgcc with actual path to llvmgcc
 
63
  regsub -all {%llvmgcc} $new_line "$llvmgcc -emit-llvm -w" new_line
 
64
  #replace %llvmgxx with actual path to llvmg++
 
65
  regsub -all {%llvmgxx} $new_line "$llvmgxx -emit-llvm -w" new_line
 
66
  #replace %compile_cxx with C++ compilation command
 
67
  regsub -all {%compile_cxx} $new_line "$compile_cxx" new_line
 
68
  #replace %compile_c with C compilation command
 
69
  regsub -all {%compile_c} $new_line "$compile_c" new_line
 
70
  #replace %link with C++ link command
 
71
  regsub -all {%link} $new_line "$link" new_line
 
72
  #replace %shlibext with shared library extension
 
73
  regsub -all {%shlibext} $new_line "$shlibext" new_line
 
74
  #replace %ocamlopt with ocaml compiler command
 
75
  regsub -all {%ocamlopt} $new_line "$ocamlopt" new_line
 
76
  #replace %llvmdsymutil with dsymutil command
 
77
  regsub -all {%llvmdsymutil} $new_line "$llvmdsymutil" new_line
 
78
  #replace %llvmlibsdir with configure library directory
 
79
  regsub -all {%llvmlibsdir} $new_line "$llvmlibsdir" new_line
 
80
  #replace %bugpoint_topts with actual bugpoint target options
 
81
  regsub -all {%bugpoint_topts} $new_line "$bugpoint_topts" new_line
 
82
  #replace %p with path to source,
 
83
  regsub -all {%p} $new_line [file join $srcdir $subdir] new_line
 
84
  #replace %s with filename
 
85
  regsub -all {%s} $new_line $test new_line
 
86
  #replace %t with temp filenames
 
87
  regsub -all {%t} $new_line $tmpFile new_line
 
88
  #replace %abs_tmp with absolute temp filenames
 
89
  regsub -all {%abs_tmp} $new_line [file join [pwd] $tmpFile] new_line
 
90
  #replace _#MARKER#_ with %
 
91
  regsub -all {_#MARKER#_} $new_line % new_line
 
92
 
 
93
  #replace grep with GNU grep
 
94
  regsub -all { grep } $new_line " $grep " new_line
 
95
  #replace as with GNU as
 
96
  regsub -all {\| as } $new_line "| $gas " new_line
 
97
 
 
98
  #valgind related stuff
 
99
# regsub -all {bugpoint } $new_line "$valgrind bugpoint " new_line
 
100
  regsub -all {llc } $new_line "$valgrind llc " new_line
 
101
  regsub -all {lli } $new_line "$valgrind lli " new_line
 
102
  regsub -all {llvm-ar } $new_line "$valgrind llvm-ar " new_line
 
103
  regsub -all {llvm-as } $new_line "$valgrind llvm-as " new_line
 
104
  regsub -all {llvm-bcanalyzer } $new_line "$valgrind llvm-bcanalyzer " new_line
 
105
  regsub -all {llvm-dis } $new_line "$valgrind llvm-dis " new_line
 
106
  regsub -all {llvm-extract } $new_line "$valgrind llvm-extract " new_line
 
107
  regsub -all {llvm-ld } $new_line "$valgrind llvm-ld " new_line
 
108
  regsub -all {llvm-link } $new_line "$valgrind llvm-link " new_line
 
109
  regsub -all {llvm-nm } $new_line "$valgrind llvm-nm " new_line
 
110
  regsub -all {llvm-prof } $new_line "$valgrind llvm-prof " new_line
 
111
  regsub -all {llvm-ranlib } $new_line "$valgrind llvm-ranlib " new_line
 
112
  regsub -all {([^a-zA-Z_-])opt } $new_line "\\1$valgrind opt " new_line
 
113
  regsub -all {^opt } $new_line "$valgrind opt " new_line
 
114
  regsub -all {tblgen } $new_line "$valgrind tblgen " new_line
 
115
  regsub -all "not $valgrind " $new_line "$valgrind not " new_line
 
116
 
 
117
  return $new_line
 
118
}
 
119
 
 
120
# This procedure runs the set of tests for the test_source_files array.
 
121
proc RunLLVMTests { test_source_files } {
 
122
  global srcroot objroot srcdir objdir subdir target_triplet
 
123
  set timeout 60
 
124
 
 
125
  set path [file join $objdir $subdir]
 
126
 
 
127
  #Make Output Directory if it does not exist already
 
128
  if { [file exists path] } {
 
129
    cd $path
 
130
  } else {
 
131
    file mkdir $path
 
132
    cd $path
 
133
  }
 
134
 
 
135
  file mkdir Output
 
136
  cd Output
 
137
 
 
138
  foreach test $test_source_files {
 
139
    #Should figure out best way to set the timeout
 
140
    #set timeout 40
 
141
 
 
142
    set filename [file tail $test]
 
143
    verbose "ABOUT TO RUN: $filename" 2
 
144
    set outcome PASS
 
145
    set tmpFile "$filename.tmp"
 
146
 
 
147
    # Mark that it should not be XFAIL for this target.
 
148
    set targetPASS 0
 
149
 
 
150
    #set hasRunline bool to check if testcase has a runline
 
151
    set numLines 0
 
152
 
 
153
    # Open the test file and start reading lines
 
154
    set testFileId [ open $test r]
 
155
    set runline ""
 
156
    set PRNUMS ""
 
157
    foreach line [split [read $testFileId] \n] {
 
158
 
 
159
      # if its the END. line then stop parsing (optimization for big files)
 
160
      if {[regexp {END.[[:space:]]*$} $line match endofscript]} {
 
161
        break
 
162
 
 
163
      # if the line is continued, concatenate and continue the loop
 
164
      } elseif {[regexp {RUN: *(.+)(\\)$} $line match oneline suffix]} {
 
165
        set runline "$runline$oneline "
 
166
 
 
167
      # if its a terminating RUN: line then do substitution on the whole line
 
168
      # and then save the line.
 
169
      } elseif {[regexp {RUN: *(.+)$} $line match oneline suffix]} {
 
170
        set runline "$runline$oneline"
 
171
        set runline [ substitute $runline $test $tmpFile ]
 
172
        set lines($numLines) $runline
 
173
        set numLines [expr $numLines + 1]
 
174
        set runline ""
 
175
 
 
176
      # if its an PR line, save the problem report number
 
177
      } elseif {[regexp {PR([0-9]+)} $line match prnum]} {
 
178
        if {$PRNUMS == ""} {
 
179
          set PRNUMS "PR$prnum"
 
180
        } else {
 
181
          set PRNUMS "$PRNUMS,$prnum"
 
182
        }
 
183
      # if its an XFAIL line, see if we should be XFAILing or not.
 
184
      } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} {
 
185
        set targets
 
186
 
 
187
        #split up target if more then 1 specified
 
188
        foreach target [split $targets ,] {
 
189
          if { $target == "*" } {
 
190
              if {$targetPASS != 1} {
 
191
                 set outcome XFAIL
 
192
              }
 
193
          } elseif { [regexp $target $target_triplet match] } {
 
194
              if {$targetPASS != 1} {
 
195
                 set outcome XFAIL
 
196
              }
 
197
          }
 
198
        }
 
199
      } elseif {[regexp {XTARGET:[ *](.+)} $line match targets]} {
 
200
        set targets
 
201
 
 
202
        #split up target if more then 1 specified
 
203
        foreach target [split $targets ,] {
 
204
          if { [regexp {\*} $target match] } {
 
205
              set targetPASS 1
 
206
              set outcome PASS
 
207
          } elseif { [regexp $target $target_triplet match] } {
 
208
              set targetPASS 1
 
209
              set outcome PASS
 
210
          }
 
211
        }
 
212
      }
 
213
    }
 
214
 
 
215
    # Done reading the script
 
216
    close $testFileId
 
217
 
 
218
 
 
219
    if { $numLines == 0 } {
 
220
      fail "$test: \nDoes not have a RUN line\n"
 
221
    } else {
 
222
      set failed 0
 
223
      for { set i 0 } { $i < $numLines } { set i [ expr $i + 1 ] } {
 
224
        regsub ^.*RUN:(.*) $lines($i) \1 theLine
 
225
        set resultmsg [execOneLine $test $PRNUMS $outcome $i $theLine ]
 
226
        if { $resultmsg != "" } {
 
227
          if { $outcome == "XFAIL" } {
 
228
            xfail "$resultmsg"
 
229
          } else {
 
230
            fail "$resultmsg"
 
231
          }
 
232
          set failed 1
 
233
          break
 
234
        }
 
235
      }
 
236
      if { $failed } {
 
237
        continue
 
238
      } else {
 
239
        if { $PRNUMS != "" } {
 
240
          set PRNUMS " for $PRNUMS"
 
241
        }
 
242
        if { $outcome == "XFAIL" } {
 
243
          xpass "$test$PRNUMS"
 
244
        } else {
 
245
          pass "$test$PRNUMS"
 
246
        }
 
247
      }
 
248
    }
 
249
  }
 
250
}
 
251
 
 
252
# This procedure provides an interface to check the LLVMGCC_LANGS makefile
 
253
# variable to see if llvm-gcc supports compilation of a particular language.
 
254
proc llvm_gcc_supports { lang } {
 
255
  global llvmgcc llvmgcc_langs
 
256
  # validate the language choices and determine the name of the compiler
 
257
  # component responsible for determining if the compiler has been built.
 
258
  switch "$lang" {
 
259
    ada     { set file gnat1 }
 
260
    c       { set file cc1 }
 
261
    c++     { set file cc1plus }
 
262
    objc    { set file cc1obj }
 
263
    obj-c++ { set file cc1objplus }
 
264
    fortran { set file f951 }
 
265
    default { return 0 }
 
266
  }
 
267
  foreach supported_lang [split "$llvmgcc_langs" ,] {
 
268
    if { "$lang" == "$supported_lang" } {
 
269
      # FIXME: Knowing it is configured is not enough. We should do two more
 
270
      # checks here. First, we need to run llvm-gcc -print-prog-name=$file to
 
271
      # get the path to the compiler. If we don't get a path, the language isn't
 
272
      # properly configured or built. If we do get a path, we should check to
 
273
      # make sure that it is executable and perhaps even try executing it.
 
274
      return 1;
 
275
    }
 
276
  }
 
277
  return 0;
 
278
}
 
279
 
 
280
# This procedure provides an interface to check the TARGETS_TO_BUILD makefile
 
281
# variable to see if a particular target has been configured to build. This
 
282
# helps avoid running tests for targets that aren't available.
 
283
proc llvm_supports_target { tgtName } {
 
284
  global TARGETS_TO_BUILD
 
285
  foreach target [split $TARGETS_TO_BUILD] {
 
286
    if { [regexp $tgtName $target match] } {
 
287
      return 1
 
288
    }
 
289
  }
 
290
  return 0
 
291
}
 
292
 
 
293
proc llvm_supports_darwin_and_target { tgtName } {
 
294
  global target_triplet
 
295
  if { [ llvm_supports_target $tgtName ] } {
 
296
    if { [regexp darwin $target_triplet match] } {
 
297
      return 1
 
298
    }
 
299
  }
 
300
  return 0
 
301
}
 
302
 
 
303
# This procedure provides an interface to check the BINDINGS_TO_BUILD makefile
 
304
# variable to see if a particular binding has been configured to build.
 
305
proc llvm_supports_binding { name } {
 
306
  global llvm_bindings
 
307
  foreach item [split $llvm_bindings] {
 
308
    if { [regexp $name $item match] } {
 
309
      return 1
 
310
    }
 
311
  }
 
312
  return 0
 
313
}