48 lines
1.3 KiB
Bash
48 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_DIR="$(cd "${TEST_DIR}/.." && pwd)"
|
|
|
|
source "${REPO_DIR}/inc/cpu-compat.inc"
|
|
|
|
assert_equal() {
|
|
local expected="${1:?expected value is required}"
|
|
local actual="${2:?actual value is required}"
|
|
local description="${3:?description is required}"
|
|
|
|
if [[ "$actual" != "$expected" ]]; then
|
|
printf 'FAIL: %s\nExpected: %s\nActual: %s\n' \
|
|
"$description" "$expected" "$actual" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
assert_equal \
|
|
"Broadwell-EP" \
|
|
"$(TAPM_CPU_GENERATION_FROM_NAME "Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz")" \
|
|
"identifies Xeon E5 v4"
|
|
|
|
assert_equal \
|
|
"3rd Gen Xeon Scalable (Ice Lake)" \
|
|
"$(TAPM_CPU_GENERATION_FROM_NAME "Intel(R) Xeon(R) Gold 6338 CPU @ 2.00GHz")" \
|
|
"identifies third-generation Xeon Scalable"
|
|
|
|
assert_equal \
|
|
"3rd Gen EPYC (Milan / Zen 3)" \
|
|
"$(TAPM_CPU_GENERATION_FROM_NAME "AMD EPYC 7543 32-Core Processor")" \
|
|
"identifies EPYC Milan"
|
|
|
|
proxclmc_fixture='node-a | 10.0.0.1 | x86-64-v4
|
|
node-b | 10.0.0.2 | x86-64-v3
|
|
|
|
Cluster CPU type: x86-64-v3'
|
|
|
|
expected_rows=$'node-a\03410.0.0.1\034x86-64-v4\nnode-b\03410.0.0.2\034x86-64-v3'
|
|
actual_rows="$(printf '%s\n' "$proxclmc_fixture" | TAPM_PROXCLMC_HOST_ROWS)"
|
|
|
|
assert_equal "$expected_rows" "$actual_rows" "parses ProxCLMC host rows"
|
|
|
|
printf 'CPU compatibility tests passed.\n'
|