libcpuid/Sanity/basic-test/test.sh
František Hrdina a50bf8e1b0 Add basic test
2024-07-29 14:56:31 +02:00

36 lines
1.4 KiB
Bash
Executable file

#!/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 "libcpuid"
TestDir=$(pwd)
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "pushd $tmp"
rlIsRHEL && repos="--enablerepo=rhel-CRB --enablerepo=rhel-buildroot"
rlIsCentOS && repos="--enablerepo=crb"
rlIsRHELLike && rlRun "dnf install -y $(rlGetRecommended) $repos"
rlCheckDependencies
rlRun "gcc $TestDir/test_libcpuid.c -o test_libcpuid -I/usr/include/libcpuid -lcpuid"
rlAssertExists "./test_libcpuid"
rlPhaseEnd
rlPhaseStartTest
rlRun "./test_libcpuid &> libcpuid.log"
rlAssertNotGrep "Error getting raw CPU data" libcpuid.log
rlAssertNotGrep "Error identifying CPU" libcpuid.log
rlAssertNotGrep "Error retrieving clock frequency" libcpuid.log
rlAssertNotGrep "Error: Vendor string is empty or NULL." libcpuid.log
rlAssertNotGrep "Error: Model string is empty or NULL" libcpuid.log
rlAssertNotGrep "Error: Number of cores is not greater than 0" libcpuid.log
rlAssertNotGrep "Error: Number of logical CPUs is not greater than 0" libcpuid.log
rlRun "cat libcpuid.log"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd