From: Hu Xuejiao <1034502035(a)qq.com>
[why]
If job.yaml is defined:
on_fail:
sleep(tests): 300(runtime)
[how]
By on_fail(sh_on_state), it will appear in job.sh:
on_fail()
{
. $LKP_SRC/lib/job.sh
. $LKP_SRC/lib/env.sh
run_test $LKP_SRC/tests/wrapper sleep 300
}
Signed-off-by: Hu XueJiao <1034502035(a)qq.com>
---
lib/job2sh.rb | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/lib/job2sh.rb b/lib/job2sh.rb
index 7e6a5d7c..9c8b578d 100755
--- a/lib/job2sh.rb
+++ b/lib/job2sh.rb
@@ -142,7 +142,7 @@ class Job2sh < Job
end
def parse_one(ancestors, key, val, pass)
- if ['pp', 'define_files', 'monitors'].include?(key)
+ if ['pp', 'define_files', 'monitors', 'on_fail'].include?(key)
return false
end
tabs = indent(ancestors)
@@ -266,11 +266,13 @@ class Job2sh < Job
sh_run_job(job)
local_script_lines += @script_lines
-
sh_extract_stats(job)
local_script_lines += @script_lines
sh_define_files()
+ local_script_lines += @script_lines
+
+ sh_on_state(job)
out_line '"$@"'
@@ -358,6 +360,28 @@ class Job2sh < Job
out_line "\tchmod +x $LKP_SRC/#{file}"
end
end
- out_line '}'
+ out_line "}\n\n"
+ end
+
+ def sh_on_state(job = nil)
+ @script_lines = []
+
+ @programs = available_programs(:workload_elements)
+
+ job ||= (@jobx || @job).clone
+
+ if job.include?('on_fail')
+
+ @cur_func = :run_job
+
+ out_line 'on_fail()'
+ out_line '{'
+ out_line
+ out_line "\t. $LKP_SRC/lib/job.sh"
+ out_line "\t. $LKP_SRC/lib/env.sh"
+ out_line
+ parse_hash [], job['on_fail']
+ out_line "}\n\n"
+ end
end
end
--
2.23.0