File: libaalogparse_init.exp

package info (click to toggle)
apparmor 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,096 kB
  • sloc: ansic: 24,943; python: 24,914; cpp: 9,074; sh: 8,166; yacc: 2,061; makefile: 1,923; lex: 1,215; pascal: 1,147; perl: 1,033; ruby: 365; lisp: 282; exp: 250; java: 212; xml: 159
file content (186 lines) | stat: -rw-r--r-- 4,903 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
proc single-run { src } {

  set path [split $src "/"]
  set filename [lindex $path [expr [llength $path]-1]]

  # extract basename and check extension

  set fname [split $filename "."]

  if {[llength $fname] < 2} {
    fail "Bad filename syntax '$src'"
    return -1
  }
  if {[lindex $fname [expr [llength $fname]-1]] != "single"} {
    fail "Not .single extension '$src'"
    return -1
  }

  # setup filenames

  # $src is the name of the original testfile with absolute path
  # tests/$filename is the name of the original testfile with relative path,
  #                 relative to the testsuite directory
  set test_prg  "$filename"

  set base_name [lindex $fname 0]

  puts "Running $base_name..."

  #generate output directory

  exec mkdir -p ./single.out/out
  set outfile ./single.out/out/$base_name.out
  set refoutfile ./single.out/$base_name.out
  set errfile ./single.out/out/$base_name.err
  set referrfile ./single.out/$base_name.err

  # run the test

  set command "LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:../src/.libs\" $src >$outfile 2>$errfile"
  set result ""
  set oops [catch { set result [exec sh -c $command] } catched]

  if {$oops != 0} {
    fail "test case failed for $base_name: $catched"
    return -1
  }

  # check return code from runprg

  if {$result != ""} {
    warning "Run of $base_name results in '$result'"
    return -1
  }

  if { [ file exists $refoutfile ] == 0 } {
      perror "Missing file $refoutfile" 0
  } else {
      if { [ diff $refoutfile $outfile ] != 1 } {
          puts "Output doesn't match expected data:"
          puts [ exec sh -c "diff -u $refoutfile $outfile || true" ]
          fail $base_name
          return -1
      }
  }

  if { [ file exists $referrfile ] == 0 } {
      perror "Missing file $referrfile" 0
  } else {
      if { [ diff $referrfile $errfile ] != 1 } {
          puts "Output doesn't match expected data:"
          puts [ exec sh -c "diff -u $referrfile $errfile || true" ]
          fail $base_name
          return -1
      }
  }

  # ok, all is fine
  pass $base_name

  return 0
}



proc multi-run { src } {
  set errorOccured 0
  set path [split $src "/"]
  set filename [lindex $path [expr [llength $path]-1]]

  # extract basename and check extension

  set fname [split $filename "."]

  if {[llength $fname] < 2} {
    fail "Bad filename syntax '$src'"
    return -1
  }
  if {[lindex $fname [expr [llength $fname]-1]] != "multi"} {
    fail "Not .multi extension '$src'"
    return -1
  }
  # setup filenames

  # $src is the name of the original testfile with absolute path
  # tests/$filename is the name of the original testfile with relative path,
  #                 relative to the testsuite directory
  set test_prg  "$filename"

  set base_name [lindex $fname 0]

  puts "Running $base_name..."

  set testcases [glob $base_name/*.in ]

  foreach testcase $testcases {
      set testPath [split $testcase "/"]
      set testFilename [lindex $testPath [expr [llength $testPath]-1]]
      set testFname [split $testFilename "."]
      set testBase_name [lindex $testFname 0]
      puts "   ... $testBase_name"

      #generate output directory

      exec mkdir -p ./$base_name/out
      set errfile ./$base_name/out/$testBase_name.err
      set referrfile ./$base_name/$testBase_name.err
      set outfile ./$base_name/out/$testBase_name.out
      set refoutfile ./$base_name/$testBase_name.out

      # run the test

      set command "LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:../src/.libs\" $src $testcase >$outfile 2>$errfile"
      set result ""
      set oops [catch { set result [exec sh -c $command] } catched]

      if {$oops != 0} {
          fail "test case failed for $testBase_name: $catched"
          set errorOccured 0
          continue
      }

      # check return code from runprg

      if {$result != ""} {
          warning "Run of $testBase_name results in '$result'"
          set errorOccured 0
          continue
      }

      if { [ file exists $refoutfile ] == 0 } {
          perror "Missing file $refoutfile" 0
      } else {
          if { [ diff $refoutfile $outfile ] != 1 } {
              puts "Output doesn't match expected data:"
              puts [ exec sh -c "diff -u $refoutfile $outfile || true" ]
              fail $testBase_name
              set errorOccured 0
              continue
          }
      }

      if { [ file exists $referrfile ] == 0 } {
          perror "Missing file $referrfile" 0
      } else {
          if { [ diff $referrfile $errfile ] != 1 } {
              puts "Output doesn't match expected data:"
              puts [ exec sh -c "diff -u $referrfile $errfile || true" ]
              fail $testBase_name
              set errorOccured 0
              continue
          }
      }

      # ok, all is fine
      pass $testBase_name
  }

  if { $errorOccured == 0 } {
      return 0
  } else {
      return -1
  }

}