Skip to content

Commit

Permalink
Yast::Arch calculates the registration arch
Browse files Browse the repository at this point in the history
* This piece of functionality is moved from ControlProductSpec.
  • Loading branch information
imobachgs committed Oct 18, 2021
1 parent 31f5b13 commit 9c3c39c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
16 changes: 16 additions & 0 deletions library/general/src/modules/Arch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,22 @@ def is_wsl
SCR.Read(path(".target.string"), "/proc/sys/kernel/osrelease").to_s.downcase.include?("-microsoft")
end

# map the Arch.architecture to the arch expected by SCC
REG_ARCH = {
"s390_32" => "s390",
"s390_64" => "s390x",
# ppc64le is the only supported PPC arch, we do not have to distinguish the BE/LE variants
"ppc64" => "ppc64le"
}.freeze
private_constant :REG_ARCH

# Returns the architecture expected by SCC
#
# @return [String] Architecture
def registration_arch
REG_ARCH[architecture] || architecture
end

publish function: :architecture, type: "string ()"
publish function: :i386, type: "boolean ()"
publish function: :sparc32, type: "boolean ()"
Expand Down
39 changes: 39 additions & 0 deletions library/general/test/arch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,43 @@
end
end
end

describe ".registration_arch" do
before do
allow(subject).to receive(:architecture).and_return(arch)
end

context "on 32 bits s390" do
let(:arch) { "s390_32" }

it "returns s390" do
expect(subject.registration_arch).to eq("s390")
end
end

context "on 64 bits s390" do
let(:arch) { "s390_64" }

it "returns s390x" do
expect(subject.registration_arch).to eq("s390x")
end
end

context "on ppc64 architectures" do
let(:arch) { "ppc64" }

it "returns 'ppc64le'" do
expect(subject.registration_arch).to eq("ppc64le")
end
end

context "on others architectures" do
let(:arch) { "x86_64" }

it "returns the underlying architecture" do
expect(subject.registration_arch).to eq("x86_64")
end
end

end
end

0 comments on commit 9c3c39c

Please sign in to comment.