Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Aug 14, 2015
1 parent 4d21c43 commit 1f38254
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/lib/installation/cio_ignore.rb
Expand Up @@ -16,9 +16,7 @@ def reset
if Yast::Mode.autoinst
@enabled = Yast::AutoinstConfig.cio_ignore
else
if File.exist?("/proc/sysinfo") &&
(File.readlines("/proc/sysinfo").grep(/Control Program: KVM\/Linux/).any? ||
File.readlines("/proc/sysinfo").grep(/Control Program: z\/VM/).any?)
if is_kvm? || is_zvm?
# cio_ignore does not make sense for KVM or z/VM (fate#317861)
@enabled = false
else
Expand All @@ -27,6 +25,19 @@ def reset
end
end
end

private

def is_kvm?
File.exist?("/proc/sysinfo") &&
File.readlines("/proc/sysinfo").grep(/Control Program: KVM\/Linux/).any?
end

def is_zvm?
File.exist?("/proc/sysinfo") &&
File.readlines("/proc/sysinfo").grep(/Control Program: z\/VM/).any?
end

end

class CIOIgnoreProposal
Expand Down
8 changes: 8 additions & 0 deletions test/cio_ignore_test.rb
Expand Up @@ -20,6 +20,14 @@
::Installation::CIOIgnore.instance.reset
expect(::Installation::CIOIgnore.instance.enabled).to eq(true)
end

it "take unexpected value from AutoinstConfig.cio_ignore" do

This comment has been minimized.

Copy link
@ancorgs

ancorgs Aug 14, 2015

Contributor

No, I didn't explain myself correctly here.

I didn't mean to create a new it block. I was just saying that in the test titled "take AutoYaST cio_ignore setting if it is enabled" nothing guarantees that the false value in expect(...).to eq(false) is actually coming from AutoinstConfig. But if you use a weird value instead of false, then you can be sure it's not coming from anywhere else, so you can really assure the predicate "take AutoYaST cio_ignore setting".

Not sure if I explained better now or even worst. 😉

allow(Yast::Mode).to receive(:autoinst).and_return(true)
allow(Yast::AutoinstConfig).to receive(:cio_ignore).and_return("autoinst_value")
::Installation::CIOIgnore.instance.reset
expect(::Installation::CIOIgnore.instance.enabled).to eq("autoinst_value")
end

end
end

Expand Down

0 comments on commit 1f38254

Please sign in to comment.