forked from fengguang/lkp-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneed_kconfig.rb
executable file
·69 lines (59 loc) · 1.92 KB
/
need_kconfig.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
63
64
65
66
67
68
69
#!/usr/bin/env ruby
def read_kconfig_lines
return nil unless self['kernel']
kconfig_file = File.expand_path '../.config', kernel
return nil unless File.exist? kconfig_file
File.read kconfig_file
end
def check_kconfig(kconfig_lines, line)
case line
when /^(CONFIG_[A-Z0-9_])+=n/
name = $1
kconfig_lines.index("# #{name} is not set") ||
kconfig_lines !~ /^#{name}=[ym]/
when /^(CONFIG_[A-Z0-9_]+=[ym])/, /^(CONFIG_[A-Z0-9_]+)/, /^(CONFIG_[A-Z0-9_]+=[0-9]+)/
kconfig_lines =~ /^#{$1}/
else
$stderr.puts "unknown kconfig option: #{line}"
true
end
end
def check_all(kconfig_lines)
$___.each do |e|
next if check_kconfig(kconfig_lines, e)
# need_kconfig
raise Job::ParamError, "kconfig not satisfied: #{e}" unless __FILE__ =~ /suggest_kconfig/
puts "suggest kconfig: #{e}"
end
end
def check_arch_constraints
model = self['model']
rootfs = self['rootfs']
kconfig = self['kconfig']
case model
when /^qemu-system-x86_64/
case rootfs
when /-x86_64/
# Check kconfig to find mismatches earlier, in cases
# when the exact kernel is still not available:
# - commit=BASE|HEAD|CYCLIC_BASE|CYCLIC_HEAD late binding
# - know exact commit, however yet to compile the kernel
raise Job::ParamError, "32bit kernel cannot run 64bit rootfs: '#{kconfig}' '#{rootfs}'" if kconfig =~ /^i386-/
$___ << 'CONFIG_X86_64=y'
when /-i386/
$___ << 'CONFIG_IA32_EMULATION=y' if kconfig =~ /^x86_64-/
end
when /^qemu-system-i386/
case rootfs
when /-x86_64/
raise Job::ParamError, "32bit QEMU cannot run 64bit rootfs: '#{model}' '#{rootfs}'"
when /-i386/
raise Job::ParamError, "32bit QEMU cannot run 64bit kernel: '#{model}' '#{kconfig}'" if kconfig =~ /^x86_64-/
$___ << 'CONFIG_X86_32=y'
end
end
end
$___ = Array(___)
check_arch_constraints
kconfig_lines = read_kconfig_lines
check_all(kconfig_lines) if kconfig_lines