Skip to content

Commit

Permalink
handle nil line to return something useful (bnc#886843)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Aug 12, 2014
1 parent 36e7c8d commit 9c55d58
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/include/bootloader/routines/misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ def getKernelParamFromLine(line, key)
# "true" to add key without value
# @return [String] new kernel command line
def setKernelParamToLine(line, key, value)
line ||= ""
# FIXME this doesn't work with quotes and spaces
params = Builtins.splitstring(line, " ")
params = Builtins.filter(params) { |p| p != "" }
Expand Down
21 changes: 21 additions & 0 deletions test/boot_common_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,26 @@
expect(Yast::BootCommon.setKernelParamToLine(
line, "verbose", "false")).to eq result_line
end

it "return line with key=value if line is nil" do
line = nil
result_line = "silent=1"
expect(Yast::BootCommon.setKernelParamToLine(
line, "silent", "1")).to eq result_line
end

it "return line with key when value is \"true\" and line is nil" do
line = nil
result_line = "verbose"
expect(Yast::BootCommon.setKernelParamToLine(
line, "verbose", "true")).to eq result_line
end

it "return empty string when value is \"false\" and line is nil" do
line = nil
result_line = ""
expect(Yast::BootCommon.setKernelParamToLine(
line, "verbose", "false")).to eq result_line
end
end
end

0 comments on commit 9c55d58

Please sign in to comment.