Skip to content

Commit

Permalink
finish grub2base tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Mar 2, 2016
1 parent 16b556f commit 4fc64d6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib/bootloader/grub2base.rb
Expand Up @@ -83,6 +83,7 @@ def write
grub_default.save
pmbr_setup
@sections.write
@password.write
# TODO: call grub-mkconfig
end

Expand All @@ -106,10 +107,6 @@ def propose
nil
end

def save
@password.write
end

def enable_serial_console(console)
console = SerialConsole.load_from_console_args(console)
raise "Invalid console parameters" unless console
Expand All @@ -123,6 +120,7 @@ def enable_serial_console(console)

def disable_serial_console
grub_default.kernel_params.remove_parameter(serial_console_matcher)
grub_default.serial_console = ""
end

private
Expand Down
41 changes: 41 additions & 0 deletions test/grub2base_test.rb
Expand Up @@ -299,4 +299,45 @@
expect(subject.grub_default.serial_console).to eq "serial --unit=1 --speed=4800 --parity=no --word=8"
end
end

describe "#disable_serial_console" do
it "cleans serial console configuation" do
subject.grub_default.serial_console = "test console"

subject.disable_serial_console

expect(subject.grub_default.serial_console).to be_empty
end

it "removes serial console parameters from kernel command line configuration" do
subject.grub_default.kernel_params.replace("verbose console=ttyS1,4800n1")

subject.disable_serial_console

expect(subject.grub_default.kernel_params.serialize).to eq "verbose"
end
end

describe "#enable_serial_console" do
before do
# fix architecture as serial console device is different on different architectures
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
end

it "sets serial console configuration according to argument" do
subject.grub_default.serial_console = ""

subject.enable_serial_console("serial --unit=1 --speed=4800 --parity=no --word=8")

expect(subject.grub_default.serial_console).to eq "serial --unit=1 --speed=4800 --parity=no --word=8"
end

it "sets serial console parameter to kernel command line configuration according to parameter" do
subject.grub_default.kernel_params.replace("")

subject.enable_serial_console("serial --unit=1 --speed=4800 --parity=no --word=8")

expect(subject.grub_default.kernel_params.serialize).to eq "console=ttyS1,4800n8"
end
end
end

0 comments on commit 4fc64d6

Please sign in to comment.