forked from cki-project/tests-beaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable CPU Idle Test (x86_64 only) test to kpet-db (#982)
Signed-off-by: Vector Li <[email protected]>
- Loading branch information
Showing
8 changed files
with
544 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. All rights reserved. | ||
# | ||
# This copyrighted material is made available to anyone wishing | ||
# to use, modify, copy, or redistribute it subject to the terms | ||
# and conditions of the GNU General Public License version 2. | ||
# | ||
# This program is distributed in the hope that it will be | ||
# useful, but WITHOUT ANY WARRANTY; without even the implied | ||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
# PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public | ||
# License along with this program; if not, write to the Free | ||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
# Boston, MA 02110-1301, USA. | ||
# | ||
|
||
source /usr/bin/rhts_environment.sh | ||
source /usr/share/beakerlib/beakerlib.sh | ||
|
||
BKRM_RC_ANY="0-255" # To assist rlRun() to support any return code | ||
|
||
# | ||
# Result code definitions | ||
# | ||
BKRM_PASS=0 # should go to rlPass() | ||
BKRM_FAIL=1 # should go to rlFail() | ||
BKRM_UNSUPPORTED=2 # should go to rlSkip() | ||
BKRM_FATAL=3 # should go to rlAbort() | ||
|
||
# | ||
# A simple wrapper function to report result | ||
# | ||
function rlReportResult | ||
{ | ||
typeset rc=${1?"*** result code"} | ||
shift | ||
typeset argv="$*" | ||
case $rc in | ||
$BKRM_PASS) rlPass $argv ;; | ||
$BKRM_FAIL) rlFail "$g_reason_fail #$argv#" ;; | ||
$BKRM_UNSUPPORTED) rlSkip "$g_reason_unsupported #$argv#" ;; | ||
$BKRM_FATAL) rlAbort "$g_reason_fatal #$argv#" ;; | ||
*) ;; | ||
esac | ||
} | ||
|
||
# | ||
# Set reason for according to result code, once function rlReportResult() is | ||
# invoked, the related reason will be used when calling rlLog() | ||
# | ||
function rlSetReason | ||
{ | ||
typeset rc=${1?"*** result code"} | ||
shift | ||
case $rc in | ||
$BKRM_FAIL) g_reason_fail="$@" ;; | ||
$BKRM_UNSUPPORTED) g_reason_unsupported="$@" ;; | ||
$BKRM_FATAL) g_reason_fatal="$@" ;; | ||
*) ;; | ||
esac | ||
} | ||
|
||
# | ||
# A simple wrapper function to skip a test because beakerlib doesn't support | ||
# such an important feature, right here we just leverage 'rhts'. Note we | ||
# don't call function report_result() as it directly invoke command | ||
# rhts-report-result actually | ||
# | ||
function rlSkip | ||
{ | ||
rlLog "Skipping test because $*" | ||
rhts-report-result $TEST SKIP $OUTPUTFILE | ||
|
||
# | ||
# As we want result="Skip" status="Completed" for all scenarios, right here | ||
# we always exit 0, otherwise the test will skip/abort | ||
# | ||
exit 0 | ||
} | ||
|
||
# | ||
# A simple wrapper function to skip a test | ||
# | ||
function rlAbort | ||
{ | ||
rlLog "Aborting test because $*" | ||
rhts-report-result "$TEST" ABORTED "$OUTPUTFILE" | ||
rhts-abort -t recipe | ||
exit 1 | ||
} | ||
|
||
# | ||
# A simple wrapper function to change working directory | ||
# | ||
function rlCd | ||
{ | ||
rlRun "pushd $(pwd)" | ||
rlRun "cd $1" | ||
} | ||
|
||
# | ||
# A simple wrapper function to return to original working directory | ||
# | ||
function rlPd | ||
{ | ||
rlRun "popd" | ||
} | ||
|
||
# | ||
# A simple wrapper function to invoke startup(), runtest() and cleanup() | ||
# | ||
function main | ||
{ | ||
typeset hook_startup=${1:-"startup"} | ||
typeset hook_runtest=${2:-"runtest"} | ||
typeset hook_cleanup=${3:-"cleanup"} | ||
typeset -i rc=0 | ||
|
||
rlJournalStart | ||
|
||
rlPhaseStartSetup | ||
$hook_startup | ||
typeset -i rc1=$? | ||
(( rc += rc1 )) | ||
rlReportResult $rc1 "$hook_startup()" | ||
rlPhaseEnd | ||
|
||
if (( rc == 0 )); then | ||
rlPhaseStartTest | ||
$hook_runtest | ||
typeset -i rc2=$? | ||
(( rc += rc2 )) | ||
rlReportResult $rc2 "$hook_runtest()" | ||
rlPhaseEnd | ||
fi | ||
|
||
rlPhaseStartCleanup | ||
$hook_cleanup | ||
typeset -i rc3=$? | ||
(( rc += rc3 )) | ||
rlReportResult $rc3 "$hook_cleanup()" | ||
rlPhaseEnd | ||
|
||
rlJournalEnd | ||
|
||
return $rc | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. All rights reserved. | ||
# | ||
# This copyrighted material is made available to anyone wishing | ||
# to use, modify, copy, or redistribute it subject to the terms | ||
# and conditions of the GNU General Public License version 2. | ||
# | ||
# This program is distributed in the hope that it will be | ||
# useful, but WITHOUT ANY WARRANTY; without even the implied | ||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
# PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public | ||
# License along with this program; if not, write to the Free | ||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
# Boston, MA 02110-1301, USA. | ||
# | ||
|
||
source ${CDIR%/cpu/driver}/cpu/common/libbkrm.sh | ||
|
||
TMPDIR=${TMPDIR:-"/tmp"} | ||
MSR_TOOLS_SRC_URL="https://github.com/intel/msr-tools.git" | ||
MSR_TOOLS_DST_DIR="$TMPDIR/msr-tools" | ||
|
||
function msr_tools_setup | ||
{ | ||
typeset script=${1:-"$TMPDIR/msr_tools_setup.sh"} | ||
|
||
cat > $script << EOF | ||
#!/bin/bash | ||
[[ -f /usr/sbin/rdmsr ]] && exit 0 | ||
[[ -f /usr/local/bin/rdmsr ]] && exit 0 | ||
src_url=$MSR_TOOLS_SRC_URL | ||
dst_dir=$MSR_TOOLS_DST_DIR | ||
rm -rf \$dst_dir | ||
git clone \$src_url \$dst_dir || exit 1 | ||
cd \$dst_dir | ||
sed -i 's%^LT_INIT%#LT_INIT%g' configure.ac || exit 1 | ||
./autogen.sh || exit 1 | ||
make || exit 1 | ||
make install || exit 1 | ||
exit 0 | ||
EOF | ||
|
||
rlRun "chmod +x $script" $BKRM_RC_ANY | ||
rlRun "cat -n $script" $BKRM_RC_ANY | ||
rlRun "bash $script" || return $BKRM_FATAL | ||
|
||
return $BKRM_PASS | ||
} | ||
|
||
function msr_tools_cleanup | ||
{ | ||
typeset dst_dir=$MSR_TOOLS_DST_DIR | ||
[[ ! -d $dst_dir ]] && return $BKRM_PASS | ||
|
||
rlCd "$dst_dir" | ||
rlRun "make uninstall" $BKRM_RC_ANY | ||
rlPd | ||
|
||
return $BKRM_PASS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. All rights reserved. | ||
# | ||
# This copyrighted material is made available to anyone wishing | ||
# to use, modify, copy, or redistribute it subject to the terms | ||
# and conditions of the GNU General Public License version 2. | ||
# | ||
# This program is distributed in the hope that it will be | ||
# useful, but WITHOUT ANY WARRANTY; without even the implied | ||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
# PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public | ||
# License along with this program; if not, write to the Free | ||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
# Boston, MA 02110-1301, USA. | ||
# | ||
|
||
export TEST=/kernel/cpu/idle | ||
export TESTVERSION=1.0 | ||
|
||
BUILT_FILES= runtest | ||
|
||
FILES=$(METADATA) runtest.sh Makefile README.md | ||
|
||
.PHONY: all install download clean | ||
|
||
run: $(FILES) build | ||
./runtest | ||
|
||
runtest: runtest.sh | ||
cp $< $@ && chmod +x $@ | ||
|
||
build: $(BUILT_FILES) | ||
|
||
clean: | ||
|
||
clobber: clean | ||
rm -f *~ $(BUILT_FILES) | ||
cl: clobber | ||
|
||
include /usr/share/rhts/lib/rhts-make.include | ||
|
||
$(METADATA): Makefile | ||
@echo "Owner: David Arcari <[email protected]>" > $(METADATA) | ||
@echo "Name: $(TEST)" >> $(METADATA) | ||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA) | ||
@echo "Path: $(TEST_DIR)" >> $(METADATA) | ||
@echo "Description: cpu idle power testing" >> $(METADATA) | ||
@echo "Type: Functional" >> $(METADATA) | ||
@echo "TestTime: 30m" >> $(METADATA) | ||
@echo "RunFor: kernel" >> $(METADATA) | ||
@echo "Requires: msr-tools" >> $(METADATA) | ||
@echo "Requires: git" >> $(METADATA) | ||
@echo "Requires: autoconf" >> $(METADATA) | ||
@echo "Requires: automake" >> $(METADATA) | ||
@echo "Requires: make" >> $(METADATA) | ||
@echo "Requires: gcc" >> $(METADATA) | ||
@echo "Requires: bc" >> $(METADATA) | ||
@echo "Requires: python2-lxml" >> $(METADATA) | ||
@echo "Requires: python3-lxml" >> $(METADATA) | ||
@echo "RepoRequires: cpu/common" >> $(METADATA) | ||
@echo "Priority: Normal" >> $(METADATA) | ||
@echo "License: GPLv2 or above" >> $(METADATA) | ||
@echo "Confidential: no" >> $(METADATA) | ||
@echo "Destructive: no" >> $(METADATA) | ||
|
||
rhts-lint $(METADATA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
PURPOSE of /kernel/cpu/idle | ||
|
||
DESCRIPTION: Simple test which verifies cpu idle power. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# cpu idle power test suite | ||
It provides cpu idle power test. | ||
Test Maintainer: [David Arcari](mailto:[email protected]) | ||
|
||
## How to run it | ||
|
||
### Dependencies | ||
Please refer to the top-level README.md for common dependencies. Test-specific | ||
dependencies will automatically be installed when executing 'make run'. | ||
|
||
### Execute the test | ||
```bash | ||
$ make run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. All rights reserved. | ||
# | ||
# This copyrighted material is made available to anyone wishing | ||
# to use, modify, copy, or redistribute it subject to the terms | ||
# and conditions of the GNU General Public License version 2. | ||
# | ||
# This program is distributed in the hope that it will be | ||
# useful, but WITHOUT ANY WARRANTY; without even the implied | ||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
# PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public | ||
# License along with this program; if not, write to the Free | ||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
# Boston, MA 02110-1301, USA. | ||
# | ||
|
||
FILE=$(readlink -f ${BASH_SOURCE}) | ||
NAME=$(basename $FILE) | ||
CDIR=$(dirname $FILE) | ||
TEST=${TEST:-"$0"} | ||
TMPDIR=/var/tmp/$(date +"%Y%m%d%H%M%S") | ||
|
||
source ${CDIR%/cpu/idle}/cpu/common/libbkrm.sh | ||
source ${CDIR%/cpu/idle}/cpu/common/libutil.sh | ||
|
||
function runtest | ||
{ | ||
rlRun "bash $CDIR/utils/idle-power-test.sh $CDIR/utils/busy.sh" || \ | ||
return $BKRM_FAIL | ||
return $BKRM_PASS | ||
} | ||
|
||
function startup | ||
{ | ||
if [[ ! -d $TMPDIR ]]; then | ||
rlRun "mkdir -p -m 0755 $TMPDIR" || return $BKRM_FAIL | ||
fi | ||
|
||
# setup msr tools as package 'msr-tools' is not installed by default | ||
msr_tools_setup || return $? | ||
if (( $? != 0 )); then | ||
rlSetReason $BKRM_FATAL "fail to setup msr tools" | ||
return $BKRM_FATAL | ||
fi | ||
|
||
# check this test is supported by CPU | ||
rlRun "rdmsr 0x606" || rlSkip "su access is not available" | ||
if (( $? != 0 )); then | ||
rlSetReason $BKRM_UNSUPPORTED \ | ||
"su access is not available" | ||
return $BKRM_UNSUPPORTED | ||
fi | ||
|
||
return $BKRM_PASS | ||
} | ||
|
||
function cleanup | ||
{ | ||
msr_tools_cleanup || return $BKRM_FAIL | ||
rlRun "rm -rf $TMPDIR" $BKRM_RC_ANY | ||
return $BKRM_PASS | ||
} | ||
|
||
main | ||
exit $? |
Oops, something went wrong.