Skip to content

Commit

Permalink
Merge c4f4bb2 into d6db589
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Feb 24, 2020
2 parents d6db589 + c4f4bb2 commit a8cc62d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 31 deletions.
7 changes: 7 additions & 0 deletions package/yast2-tune.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Feb 24 15:10:14 CET 2020 - schubi@suse.de

- Using SysctlConfig class: Handle sysctl entries in different
directories (bsc#1151649).
- 4.2.3

-------------------------------------------------------------------
Tue Nov 26 16:38:08 UTC 2019 - David Diaz <dgonzalez@suse.com>

Expand Down
10 changes: 5 additions & 5 deletions package/yast2-tune.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-tune
Version: 4.2.2
Version: 4.2.3
Release: 0
Summary: YaST2 - Hardware Tuning
License: GPL-2.0-or-later
Expand All @@ -27,12 +27,12 @@ Url: https://github.com/yast/yast-tune
Source0: %{name}-%{version}.tar.bz2

BuildRequires: update-desktop-files
# CFA::Sysctl
BuildRequires: yast2 >= 4.2.25
# CFA::SysctlConfig
BuildRequires: yast2 >= 4.2.67
BuildRequires: yast2-devtools >= 4.2.2

# CFA::Sysctl
Requires: yast2 >= 4.2.25
# # CFA::SysctlConfig
Requires: yast2 >= 4.2.67
Requires: yast2-bootloader
Requires: yast2-ruby-bindings >= 1.0.0

Expand Down
32 changes: 16 additions & 16 deletions src/modules/SystemSettings.rb
Expand Up @@ -10,7 +10,7 @@
# This module manages the System and Kernel settings such as I/O Scheduler type,
# SysRq Keys...
require "yast"
require "cfa/sysctl"
require "cfa/sysctl_config"

module Yast
class SystemSettingsClass < Module
Expand All @@ -24,12 +24,12 @@ def main
Yast.import "Mode"

# Internal Data
@elevator = nil
@enable_sysrq = nil
@kernel_sysrq = nil
@sysctl_file = nil
@sysctl_sysrq = nil
@modified = false
@elevator = nil
@enable_sysrq = nil
@kernel_sysrq = nil
@sysctl_config = nil
@sysctl_sysrq = nil
@modified = false
end

# Known values of the 'elevator' variable
Expand Down Expand Up @@ -185,7 +185,7 @@ def kernel_sysrq
# @return [String] Configuration value; returns an empty string if it's not set.
def sysctl_sysrq
return @sysctl_sysrq if @sysctl_sysrq
@sysctl_sysrq = sysctl_file.kernel_sysrq
@sysctl_sysrq = sysctl_config.kernel_sysrq
log.info("SysRq enabled: #{@sysctl_sysrq}")
@sysctl_sysrq
end
Expand Down Expand Up @@ -329,8 +329,8 @@ def write_sysrq
end

log.info("Saving ENABLE_SYSRQ: #{enable_sysrq}")
sysctl_file.kernel_sysrq = enable_sysrq
sysctl_file.save
sysctl_config.kernel_sysrq = enable_sysrq
sysctl_config.save unless sysctl_config.conflict?
end

# Write IO Scheduler settings
Expand All @@ -351,12 +351,12 @@ def write_scheduler
#
# @note It memoizes the value until {#main} is called.
#
# @return [Yast2::CFA::Sysctl]
def sysctl_file
return @sysctl_file if @sysctl_file
@sysctl_file = CFA::Sysctl.new
@sysctl_file.load
@sysctl_file
# @return [Yast2::CFA::SysctlConfig]
def sysctl_config
return @sysctl_config if @sysctl_config
@sysctl_config = CFA::SysctlConfig.new
@sysctl_config.load
@sysctl_config
end
end

Expand Down
20 changes: 10 additions & 10 deletions test/system_settings_test.rb
Expand Up @@ -10,16 +10,16 @@

subject(:settings) { Yast::SystemSettings }
let(:scheduler) { "cfq" }
let(:sysctl_file) { CFA::Sysctl.new }
let(:sysctl_config) { CFA::SysctlConfig.new }

before do
allow(File).to receive(:exist?).and_return(true)
allow(Yast::Bootloader).to receive(:Read)
allow(Yast::Bootloader).to receive(:kernel_param)
.with(:common, "elevator").and_return(scheduler)
allow(CFA::Sysctl).to receive(:new).and_return(sysctl_file)
allow(sysctl_file).to receive(:load)
allow(sysctl_file).to receive(:save)
allow(CFA::SysctlConfig).to receive(:new).and_return(sysctl_config)
allow(sysctl_config).to receive(:load)
allow(sysctl_config).to receive(:save)
settings.main
end

Expand All @@ -35,7 +35,7 @@
let(:mode) { "normal" }

before do
allow(sysctl_file).to receive(:kernel_sysrq).and_return(sysctl_sysrq)
allow(sysctl_config).to receive(:kernel_sysrq).and_return(sysctl_sysrq)
allow(File).to receive(:read).with(KERNEL_SYSRQ_FILE)
.and_return(kernel_sysrq)
allow(Yast::Bootloader).to receive(:kernel_param)
Expand Down Expand Up @@ -246,7 +246,7 @@
allow(Yast::Mode).to receive(:mode).and_return(mode)
allow(Yast::Bootloader).to receive(:Write)
allow(Yast::SCR).to receive(:Read).and_call_original
allow(sysctl_file).to receive(:kernel_sysrq).and_return(sysctl_sysrq)
allow(sysctl_config).to receive(:kernel_sysrq).and_return(sysctl_sysrq)
end

context "when system settings has been read" do
Expand All @@ -256,7 +256,7 @@
let(:sysctl_sysrq) { "0" }

it "updates sysctl configuration" do
expect(sysctl_file).to receive(:kernel_sysrq=).with(sysctl_sysrq)
expect(sysctl_config).to receive(:kernel_sysrq=).with(sysctl_sysrq)
settings.Write
end
end
Expand All @@ -265,7 +265,7 @@
let(:sysctl_sysrq) { "-1" }

it "does not update sysctl configuration" do
expect(sysctl_file).to_not receive(:kernel_sysrq=)
expect(sysctl_config).to_not receive(:kernel_sysrq=)
settings.Write
end
end
Expand All @@ -287,7 +287,7 @@

context "when system settings hadn't been read" do
it "does not update sysctl configuration" do
expect(sysctl_file).to_not receive(:kernel_sysrq=)
expect(sysctl_config).to_not receive(:kernel_sysrq=)
settings.Write
end
end
Expand Down Expand Up @@ -329,7 +329,7 @@
describe "#SetSysRqKeysEnabled" do
before do
allow(Yast::SCR).to receive(:Read).and_call_original
allow(sysctl_file).to receive(:kernel_sysrq).and_return(sysctl_sysrq)
allow(sysctl_config).to receive(:kernel_sysrq).and_return(sysctl_sysrq)
settings.Read
end

Expand Down

0 comments on commit a8cc62d

Please sign in to comment.