diff --git a/Sanity/binding-test/libcpuid_info.py b/Sanity/binding-test/libcpuid_info.py new file mode 100644 index 0000000..8d02ef0 --- /dev/null +++ b/Sanity/binding-test/libcpuid_info.py @@ -0,0 +1,16 @@ +import json +import sys +from libcpuid.info import CPUInfo + +out_filename = sys.argv[1] + +cpu_info = CPUInfo.from_current_cpu() +to_output = { + "vendor_str": cpu_info.vendor_str, + "ext_family": cpu_info.ext_family, + "ext_model": cpu_info.ext_model, + "stepping": cpu_info.stepping +} + +with open(out_filename, "w") as out_file: + json.dump(to_output, out_file) diff --git a/Sanity/binding-test/main.fmf b/Sanity/binding-test/main.fmf new file mode 100644 index 0000000..9bac339 --- /dev/null +++ b/Sanity/binding-test/main.fmf @@ -0,0 +1,21 @@ +summary: Python bindings sanity test +contact: Pavol Žáčik +component: + - libcpuid +require: + - python3-libcpuid + - jq +test: ./test.sh +framework: beakerlib +duration: 5m +enabled: true +tag: + - Tier1 +tier: '1' +adjust: + - enabled: false + when: distro < rhel-10 + continue: false + - enabled: false + when: distro < centos-stream-10 + continue: false diff --git a/Sanity/binding-test/test.sh b/Sanity/binding-test/test.sh new file mode 100755 index 0000000..ec97cbb --- /dev/null +++ b/Sanity/binding-test/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm "python3-libcpuid" + script=$(pwd)/libcpuid_info.py + rlRun "tmp=$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd $tmp" + script_outfile=libcpuid_info.json + lscpu_outfile=lscpu.out + rlPhaseEnd + + rlPhaseStartTest + rlRun "python3 $script $script_outfile" + rlRun "lscpu > $lscpu_outfile" + + rlRun "libcpuid_vendor=$(cat $script_outfile | jq -r .vendor_str)" + rlRun "libcpuid_family=$(cat $script_outfile | jq .ext_family)" + rlRun "libcpuid_model=$(cat $script_outfile | jq .ext_model)" + rlRun "libcpuid_stepping=$(cat $script_outfile | jq .stepping)" + + rlRun "lscpu_vendor=$(sed -n 's/^Vendor ID:\s*//p' $lscpu_outfile)" + rlRun "lscpu_family=$(sed -n 's/^CPU family:\s*//p' $lscpu_outfile)" + rlRun "lscpu_model=$(sed -n 's/^Model:\s*//p' $lscpu_outfile)" + rlRun "lscpu_stepping=$(sed -n 's/^Stepping:\s*//p' $lscpu_outfile)" + + rlAssertEquals "Check equality of CPU vendor" "$libcpuid_vendor" "$lscpu_vendor" + rlAssertEquals "Check equality of CPU family" "$libcpuid_family" "$lscpu_family" + rlAssertEquals "Check equality of CPU model" "$libcpuid_model" "$lscpu_model" + rlAssertEquals "Check equality of CPU stepping" "$libcpuid_stepping" "$lscpu_stepping" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd