-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_test.rb
executable file
·62 lines (46 loc) · 1.38 KB
/
run_test.rb
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
#!/usr/bin/env ruby
require 'json'
load_dir = File.dirname(
File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
)
file = File.read("#{load_dir}/tests_available.json")
tests_available = JSON.parse(file)
load_dir = Dir.pwd if load_dir == '.'
puts "Running tests from #{load_dir}\n\n"
if ARGV.length < 1
exec("make clean > output 2>&1 && make -C #{load_dir}/src/userprog -j 16 check >> output 2>&1")
else
test_ = []
ARGV.each do |arg|
test_a = tests_available[arg.to_s]
test_.push(name: arg, test: test_a) if test_a
end
dir_made = []
test_.each do |t|
dir = t[:test]['dir']
dir = dir.split('/')
test_dir = []
dir.each do |dir_|
if dir_ != 'build'
test_dir.push(dir_)
else
break
end
end
dir = test_dir.join('/')
`make -C #{load_dir}/#{dir}` unless dir_made.include? dir
puts "Running test:\t#{t[:name]}"
test_a = t[:test]
puts "Command:\t#{test_a['command']}"
puts "Dir:\t\t#{test_a['dir']}\n"
`cd #{load_dir}/#{test_a['dir']} && #{test_a['command']}`
exit_code = $?.exitstatus
output_file = "#{load_dir}/#{test_a['dir']}/#{t[:name]}.output"
puts "\n\nOutput:\n\n"
system("cat #{output_file}")
errors_file = "#{load_dir}/#{test_a['dir']}/#{t[:name]}.errors"
puts "\n\nErrors:\n\n"
system("cat #{errors_file}")
puts "\nExit code:\t#{exit_code}\n\n"
end
end