Skip to content

Commit

Permalink
filters/need_kconfig.rb: load kconfigs yaml inside check_all
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Li <[email protected]>
  • Loading branch information
rli9 committed Feb 23, 2023
1 parent cdac705 commit 63cfc2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions filters/need_kconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ def check_all(kernel_kconfigs, needed_kconfigs)
kernel_version = context['rc_tag']
kernel_arch = context['kconfig'].split('-').first

if File.exist? KCONFIGS_YAML
kconfig_constraints = YAML.load_file KCONFIGS_YAML
kconfigs_yaml = KernelTag.kconfigs_yaml
if File.exist? kconfigs_yaml
kconfig_constraints = YAML.load_file kconfigs_yaml
kconfig_constraints = kconfig_constraints.transform_values { |constraints| split_constraints(constraints) }
end

Expand Down
8 changes: 6 additions & 2 deletions lib/kernel_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

require "#{LKP_SRC}/lib/lkp_path"

KCONFIGS_YAML = LKP::Path.src('etc', 'kconfigs.yaml').freeze

class KernelTag
include Comparable
attr_reader :kernel_tag
Expand Down Expand Up @@ -35,6 +33,12 @@ def <=>(other)

numerized_kernel_version1 <=> numerized_kernel_version2
end

class << self
def kconfigs_yaml
LKP::Path.src('etc', 'kconfigs.yaml')
end
end
end

def kernel_match_version?(kernel_version, expected_kernel_versions)
Expand Down
4 changes: 2 additions & 2 deletions spec/filter_need_kconfig_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
f.write("CONFIG_X=y\nCONFIG_Y=200\nCONFIG_Z1=m\nCONFIG_Z2=y\nCONFIG_H=0x1000000")
end

stub_const 'KCONFIGS_YAML', File.join(@tmp_dir, 'kconfigs.yaml')
allow(KernelTag).to receive(:kconfigs_yaml).and_return(File.join(@tmp_dir, 'kconfigs.yaml'))
end

after(:each) do
FileUtils.remove_entry @tmp_dir
end

def generate_kconfigs_yaml(kconfigs_kernel_versions)
File.open(KCONFIGS_YAML, 'w') do |f|
File.open(KernelTag.kconfigs_yaml, 'w') do |f|
f.puts kconfigs_kernel_versions
end
end
Expand Down

0 comments on commit 63cfc2f

Please sign in to comment.