-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #461 from yast/s390_finish_client
Copy udev rules before calling bootloader finish client
- Loading branch information
Showing
7 changed files
with
235 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2023] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require_relative "../../test_helper" | ||
require_relative "storage_helpers" | ||
require "dinstaller/helpers" | ||
require "dinstaller/config" | ||
require "dinstaller/security" | ||
require "dinstaller/storage/finisher" | ||
|
||
describe DInstaller::Storage::Finisher do | ||
include DInstaller::RSpec::StorageHelpers | ||
|
||
subject(:storage) { described_class.new(logger, config, security) } | ||
|
||
let(:logger) { Logger.new($stdout, level: :warn) } | ||
let(:config_path) do | ||
File.join(FIXTURES_PATH, "root_dir", "etc", "d-installer.yaml") | ||
end | ||
|
||
let(:destdir) { File.join(FIXTURES_PATH, "target_dir") } | ||
let(:config) { DInstaller::Config.from_file(config_path) } | ||
let(:security) { instance_double(DInstaller::Security, probe: nil, write: nil) } | ||
let(:copy_files) { DInstaller::Storage::Finisher::CopyFilesStep.new(logger) } | ||
let(:progress) { instance_double(DInstaller::Progress, step: nil) } | ||
|
||
describe "#run" do | ||
before do | ||
allow_any_instance_of(described_class::Step).to receive(:run?).and_return(false) | ||
allow(described_class::Step).to receive(:run?).and_return(false) | ||
allow(copy_files.class).to receive(:new).and_return(copy_files) | ||
allow(copy_files).to receive(:run?).and_return(true) | ||
allow(subject).to receive(:progress).and_return(progress) | ||
end | ||
|
||
it "runs the possible steps that must be run" do | ||
expect(subject).to receive(:start_progress).with(1) | ||
expect(subject.progress).to receive(:step) do |label, &block| | ||
expect(label).to eql(copy_files.label) | ||
expect(copy_files).to receive(:run) | ||
block.call | ||
end | ||
|
||
subject.run | ||
end | ||
end | ||
|
||
describe described_class::Step do | ||
subject { described_class.new(logger) } | ||
|
||
describe "#run?" do | ||
it "returns whether the step must be executed or not (default: true)" do | ||
expect(subject.run?).to eql(true) | ||
end | ||
end | ||
end | ||
|
||
describe described_class::CopyFilesStep do | ||
subject { copy_files } | ||
before do | ||
allow(Yast::Installation).to receive(:destdir).and_return(destdir) | ||
allow(subject).to receive(:root_dir).and_return(File.join(FIXTURES_PATH, "root_dir")) | ||
end | ||
|
||
around do |block| | ||
FileUtils.mkdir_p(destdir) | ||
block.call | ||
FileUtils.rm_rf(destdir) | ||
end | ||
|
||
describe "#run" do | ||
let(:rules) do | ||
[ | ||
"41-cio-ignore.rules", "41-dasd-eckd-0.0.0160.rules", | ||
"41-qeth-0.0.0800.rules", "70-persistent-net.rules" | ||
] | ||
end | ||
|
||
it "copies some specific udev rules to the target system when exist" do | ||
subject.run | ||
rules.each do |rule| | ||
expect(File.exist?(File.join(destdir, "/etc/udev/rules.d/#{rule}"))).to eql(true) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe described_class::BootloaderStep do | ||
subject { described_class.new(logger) } | ||
let(:on_s390) { false } | ||
|
||
before do | ||
allow(Yast::Arch).to receive(:s390).and_return(on_s390) | ||
allow_any_instance_of(::Bootloader::FinishClient).to receive(:write) | ||
end | ||
|
||
context "when running on s390x" do | ||
let(:on_s390) { true } | ||
|
||
describe "#run" do | ||
it "runs the cio_ignore_finish client" do | ||
expect(subject).to receive(:wfm_write).with("cio_ignore_finish") | ||
subject.run | ||
end | ||
end | ||
end | ||
|
||
context "when not running on s390x" do | ||
describe "#run" do | ||
it "does not run the cio_ignore_finish client" do | ||
expect(subject).to_not receive(:wfm_write).with("cio_ignore_finish") | ||
subject.run | ||
end | ||
end | ||
end | ||
|
||
it "runs the Bootloader Finish Client" do | ||
expect_any_instance_of(::Bootloader::FinishClient).to receive(:write) | ||
subject.run | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
service/test/fixtures/root_dir/etc/udev/rules.d/41-cio-ignore.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Generated by chzdev | ||
ACTION=="add", SUBSYSTEM=="subsystem", KERNEL=="ccw", RUN{program}+="/bin/sh -c 'echo free 0160,0800-0802 > /proc/cio_ignore'" |
10 changes: 10 additions & 0 deletions
10
service/test/fixtures/root_dir/etc/udev/rules.d/41-dasd-eckd-0.0.0160.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Generated by chzdev | ||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="0.0.0160", DRIVER=="dasd-eckd", GOTO="cfg_dasd_eckd_0.0.0160" | ||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="dasd-eckd", TEST=="[ccw/0.0.0160]", GOTO="cfg_dasd_eckd_0.0.0160" | ||
GOTO="end_dasd_eckd_0.0.0160" | ||
|
||
LABEL="cfg_dasd_eckd_0.0.0160" | ||
ATTR{[ccw/0.0.0160]use_diag}="0" | ||
ATTR{[ccw/0.0.0160]online}="1" | ||
|
||
LABEL="end_dasd_eckd_0.0.0160" |
22 changes: 22 additions & 0 deletions
22
service/test/fixtures/root_dir/etc/udev/rules.d/41-qeth-0.0.0800.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by chzdev | ||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="qeth", GOTO="group_qeth_0.0.0800" | ||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="0.0.0800", DRIVER=="qeth", GOTO="group_qeth_0.0.0800" | ||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="0.0.0801", DRIVER=="qeth", GOTO="group_qeth_0.0.0800" | ||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="0.0.0802", DRIVER=="qeth", GOTO="group_qeth_0.0.0800" | ||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="0.0.0800", DRIVER=="qeth", GOTO="cfg_qeth_0.0.0800" | ||
GOTO="end_qeth_0.0.0800" | ||
|
||
LABEL="group_qeth_0.0.0800" | ||
TEST=="[ccwgroup/0.0.0800]", GOTO="end_qeth_0.0.0800" | ||
TEST!="[ccw/0.0.0800]", GOTO="end_qeth_0.0.0800" | ||
TEST!="[ccw/0.0.0801]", GOTO="end_qeth_0.0.0800" | ||
TEST!="[ccw/0.0.0802]", GOTO="end_qeth_0.0.0800" | ||
ATTR{[drivers/ccwgroup:qeth]group}="0.0.0800,0.0.0801,0.0.0802" | ||
GOTO="end_qeth_0.0.0800" | ||
|
||
LABEL="cfg_qeth_0.0.0800" | ||
ATTR{[ccwgroup/0.0.0800]portno}="0" | ||
ATTR{[ccwgroup/0.0.0800]layer2}="1" | ||
ATTR{[ccwgroup/0.0.0800]online}="1" | ||
|
||
LABEL="end_qeth_0.0.0800" |
8 changes: 8 additions & 0 deletions
8
service/test/fixtures/root_dir/etc/udev/rules.d/70-persistent-net.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This file was automatically generated by the /usr/lib/udev/write_net_rules | ||
# program, run by the persistent-net-generator.rules rules file. | ||
# | ||
# You can modify it, as long as you keep each rule on a single | ||
# line, and change only the value of the NAME= key. | ||
|
||
# S/390 qeth device at 0.0.0800 | ||
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="qeth", ATTR{dev_id}=="0x0", KERNELS=="0.0.0800", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0 |