[PATCH lkp-tests] lib/job.rb: fix host file not exist

add check host file at: 1. lab repo + tbox_group 2. lkp_src repo + testbox Signed-off-by: Wei Jihui <weijihuiall@163.com> --- lib/job.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/job.rb b/lib/job.rb index 7fc7cb5b..c1df0f5b 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -366,12 +366,16 @@ class Job end def get_hosts_file - testbox_file = "#{ENV['CCI_REPOS']}/lab-#{@job['lab']}/hosts/#{@job['testbox']}" - return testbox_file if File.file?(testbox_file) - + testbox = @job['testbox'] tbox_group = @job['tbox_group'].split(/\.|--/)[0] - tbox_group_file = "#{LKP_SRC}/hosts/#{tbox_group}" - return tbox_group_file if File.file?(tbox_group_file) + lab_repo = "#{ENV['CCI_REPOS']}/lab-#{@job['lab']}" + + ["#{lab_repo}/hosts/#{testbox}", + "#{lab_repo}/hosts/#{tbox_group}", + "#{LKP_SRC}/hosts/#{testbox}", + "#{LKP_SRC}/hosts/#{tbox_group}"].each do |file| + return file if File.file?(file) + end raise ArgumentError, "hosts file not exist: #{tbox_group}, maybe need check testbox field" end -- 2.23.0

On Tue, Mar 23, 2021 at 08:44:46PM +0800, Wei Jihui wrote:
add check host file at: 1. lab repo + tbox_group 2. lkp_src repo + testbox
Signed-off-by: Wei Jihui <weijihuiall@163.com> --- lib/job.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index 7fc7cb5b..c1df0f5b 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -366,12 +366,16 @@ class Job end
def get_hosts_file - testbox_file = "#{ENV['CCI_REPOS']}/lab-#{@job['lab']}/hosts/#{@job['testbox']}" - return testbox_file if File.file?(testbox_file) - + testbox = @job['testbox'] tbox_group = @job['tbox_group'].split(/\.|--/)[0] - tbox_group_file = "#{LKP_SRC}/hosts/#{tbox_group}" - return tbox_group_file if File.file?(tbox_group_file) + lab_repo = "#{ENV['CCI_REPOS']}/lab-#{@job['lab']}" + + ["#{lab_repo}/hosts/#{testbox}", + "#{lab_repo}/hosts/#{tbox_group}", + "#{LKP_SRC}/hosts/#{testbox}", + "#{LKP_SRC}/hosts/#{tbox_group}"].each do |file| + return file if File.file?(file) + end
I have sent a same patch before. Thanks, Ping
raise ArgumentError, "hosts file not exist: #{tbox_group}, maybe need check testbox field" end -- 2.23.0
participants (2)
-
Li Ping
-
Wei Jihui