From 11dff731b74d46c5135098073bc47c0b6a43dfbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Fri, 15 Sep 2023 13:59:41 +0200 Subject: [PATCH] tests: Move functions from kata_arch script here MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can use this a lot as part of our CI, but right now I'm just moving those here with the intent to use later on in this series. Fixes: #7974 -- part 0 Signed-off-by: Fabiano FidĂȘncio --- tests/common.bash | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/common.bash b/tests/common.bash index fc0ed0a7f9..fc5eac5cb4 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -413,3 +413,42 @@ function install_cri_tools() { sudo tar -xvf "${tarball_name}" -C /usr/local/bin rm -f "${tarball_name}" } + +# Convert architecture to the name used by golang +function arch_to_golang() { + local arch="$(uname -m)" + + case "${arch}" in + aarch64) echo "arm64";; + ppc64le) echo "${arch}";; + x86_64) echo "amd64";; + s390x) echo "s390x";; + *) die "unsupported architecture: ${arch}";; + esac +} + +# Convert architecture to the name used by rust +function arch_to_rust() { + local -r arch="$(uname -m)" + + case "${arch}" in + aarch64) echo "${arch}";; + ppc64le) echo "powerpc64le";; + x86_64) echo "${arch}";; + s390x) echo "${arch}";; + *) die "unsupported architecture: ${arch}";; + esac +} + +# Convert architecture to the name used by the Linux kernel build system +function arch_to_kernel() { + local -r arch="$(uname -m)" + + case "${arch}" in + aarch64) echo "arm64";; + ppc64le) echo "powerpc";; + x86_64) echo "${arch}";; + s390x) echo "s390x";; + *) die "unsupported architecture: ${arch}";; + esac +}