[why]
If job.yaml is defined:
on_fail:
sleep(tests): 300(runtime)
[how]
By sh_on_fail, it will appear in job.sh:
on_fail()
{
. $LKP_SRC/lib/http.sh
. $LKP_SRC/lib/job.sh
export_top_envexport_top_env
run_test $LKP_SRC/tests/wrapper sleep 500
}
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..370c7899 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_fail(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_fail(job = nil)
+ @script_lines = []
+
+ @programs = available_programs(:workload_elements)
+
+ job ||= (@jobx || @job).clone
+
+ @cur_func = :on_fail
+
+ out_line 'on_fail()'
+ out_line '{'
+ out_line
+ out_line "\t. $LKP_SRC/lib/http.sh"
+ out_line "\t. $LKP_SRC/lib/job.sh"
+ out_line "\t. $LKP_SRC/lib/env.sh"
+ out_line
+ out_line "\texport_top_env"
+ out_line
+ parse_hash [], job['on_fail']
+ out_line "}"
end
end
--
2.23.0