Skip to content

Commit

Permalink
Merge 31310c9 into 7b75c28
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 11, 2020
2 parents 7b75c28 + 31310c9 commit d01f6e9
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 2 deletions.
3 changes: 2 additions & 1 deletion library/control/src/modules/ProductFeatures.rb
Expand Up @@ -72,7 +72,8 @@ def main
"base_product_license_directory" => "/usr/share/licenses/product/base/",
"full_system_media_name" => "",
"full_system_download_url" => "",
"save_y2logs" => true
"save_y2logs" => true,
"propose_hibernate" => true
},
"partitioning" => {
"use_flexible_partitioning" => false,
Expand Down
14 changes: 14 additions & 0 deletions library/system/src/modules/Kernel.rb
Expand Up @@ -57,6 +57,7 @@ def main
Yast.import "Popup"
Yast.import "Stage"
Yast.import "FileUtils"
Yast.import "ProductFeatures"

textdomain "base"

Expand Down Expand Up @@ -552,6 +553,19 @@ def InformAboutKernelChange
@inform_about_kernel_change
end

# gets if YaST should propose hibernation aka Kernel resume parameter
# @return [Boolean] true if hibernation should be proposed
def propose_hibernation?
# Do not support s390. (jsc#SLE-6926)
return false unless Arch.i386 || Arch.x86_64
# Do not propose resume on virtuals (jsc#SLE-12280)
return false if Arch.is_kvm || Arch.is_xenU
# For some products it does not make sense to have hibernations (jsc#SLE-12280)
return false unless ProductFeatures.GetBooleanFeature("globals", "propose_hibernation")

true
end

publish function: :AddCmdLine, type: "void (string, string)"
publish function: :GetVgaType, type: "string ()"
publish function: :GetCmdLine, type: "string ()"
Expand Down
57 changes: 57 additions & 0 deletions library/system/test/kernel_test.rb
Expand Up @@ -229,4 +229,61 @@
end
end
end

describe ".propose_hibernation?" do
context "on non-intel architectures" do
before do
allow(Yast::Arch).to receive(:architecture).and_return("s390_64")
end

it "returns false" do
expect(subject.propose_hibernation?).to eq false
end
end

context "on intel architecture" do
before do
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
end

context "on virtual machine" do
before do
allow(Yast::Arch).to receive(:is_kvm).and_return(true)
end

it "returns false" do
expect(subject.propose_hibernation?).to eq false
end
end

context "on real hardware" do
before do
allow(Yast::Arch).to receive(:is_kvm).and_return(false)
allow(Yast::Arch).to receive(:is_xenU).and_return(false)
end

context "when product does not want hibernation proposal" do
before do
allow(Yast::ProductFeatures).to receive(:GetBooleanFeature)
.with("general", "propose_hibernation").and_return(false)
end

it "returns false" do
expect(subject.propose_hibernation?).to eq false
end
end

context "when product wants hibernation proposal" do
before do
allow(Yast::ProductFeatures).to receive(:GetBooleanFeature)
.with("general", "propose_hibernation").and_return(true)
end

it "returns true" do
expect(subject.propose_hibernation?).to eq true
end
end
end
end
end
end
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Nov 11 22:25:45 UTC 2020 - Josef Reidinger <jreidinger@suse.com>

- add methods to decide if hibernation should be proposed
(jsc#SLE-12280)
- 4.3.41

-------------------------------------------------------------------
Fri Nov 6 22:40:12 UTC 2020 - José Iván López González <jlopez@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.3.40
Version: 4.3.41
Release: 0
Summary: YaST2 Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit d01f6e9

Please sign in to comment.