diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..f37b84e --- /dev/null +++ b/tests/README.md @@ -0,0 +1,44 @@ +About + +Trace-cmd tests according to the CI wiki specifically the standard test interface in the [spec](https://fedoraproject.org/wiki/Changes/InvokingTests). + +The playbook includes Tier1 level test cases that have been tested in classic contexts and is passing reliably. + +The following steps are used to execute the tests using the standard test interface: + +Test environment + +Make sure you have installed packages from the spec + + `# dnf install ansible python2-dnf libselinux-python standard-test-roles ansible python2-dnf libselinux-python standard-test-roles` + +Run tests for Classic +~~~~ + # export TEST_SUBJECTS= + # sudo ansible-playbook --tags=classic tests.yml +~~~~ + +Snip of the example test run for Classic tests: + +> TASK [standard-test-beakerlib : Run beakerlib tests] ***************************************************************************************************************************************** +> +> changed: [localhost] => (item=sanity) +> +> TASK [standard-test-beakerlib : Make the master tests summary log artifact] ****************************************************************************************************************** +> +> changed: [localhost] => (item=sanity) +> +> TASK [standard-test-beakerlib : Check the results] ******************************************************************************************************************************************* +> +> changed: [localhost] +> +> TASK [standard-test-beakerlib : include_role] ************************************************************************************************************************************************ +> +> TASK [str-common : Pull out the logs from test environment to test runner] ******************************************************************************************************************* +> +> changed: [localhost] +> +> PLAY RECAP *********************************************************************************************************************************************************************************** +> +> localhost : ok=27 changed=16 unreachable=0 failed=0 +> diff --git a/tests/sanity/Makefile b/tests/sanity/Makefile new file mode 100644 index 0000000..4772acf --- /dev/null +++ b/tests/sanity/Makefile @@ -0,0 +1,59 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: Basic sanity test for trace-cmd +# Author: Ziqian SUN (Zamir) +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2018 Red Hat, Inc. All rights reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# 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, see . +# +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export PACKAGE_NAME=trace-cmd +export TEST=/kernel/general/ftrace/tools/trace-cmd/sanity +export TESTVERSION=0.1 + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: + chmod a+x runtest.sh + +clean: + rm -fr *~ tests-*.rpm + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Ziqian SUN (Zamir) " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Basic sanity test for trace-cmd" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: trace-cmd" >> $(METADATA) + @echo "Requires: @development" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv3" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/sanity/PURPOSE b/tests/sanity/PURPOSE new file mode 100644 index 0000000..ac1e2e4 --- /dev/null +++ b/tests/sanity/PURPOSE @@ -0,0 +1 @@ +Basic sanity test for trace-cmd diff --git a/tests/sanity/runtest.sh b/tests/sanity/runtest.sh new file mode 100755 index 0000000..1198f22 --- /dev/null +++ b/tests/sanity/runtest.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: Basic sanity test for trace-cmd +# Author: Ziqian SUN (Zamir) +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2018 Red Hat, Inc. All rights reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# 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, see . +# +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/bin/rhts-environment.sh +. /usr/share/beakerlib/beakerlib.sh + +if ! mount | grep -q debugfs ; then + mount -t debugfs nodev /sys/kernel/debug +fi + +trace-cmd reset +rlJournalStart + for TRACER in $(cat /sys/kernel/debug/tracing/available_tracers) ; do + rlPhaseStartTest "Enable ${TRACER} using trace-cmd" + rlRun "trace-cmd start -p ${TRACER}" + rlAssertEquals "Check current tracer" "$(cat /sys/kernel/debug/tracing/current_tracer)" "${TRACER}" + rlAssertEquals "Check tracing status" "$(cat /sys/kernel/debug/tracing/tracing_on)" "1" + rlRun "trace-cmd stop" + rlAssertEquals "Check tracing status" "$(cat /sys/kernel/debug/tracing/tracing_on)" "0" + rlRun "trace-cmd reset" + rlPhaseEnd + if [[ "${TRACER}" == "function" ]]; then + rlPhaseStartTest "Test trace-cmd show" + rlRun "trace-cmd start -p ${TRACER}" + rlWatchdog "trace-cmd show | grep -v '^#' > trace-cmd-show-function.log" 5 INT + rlAssertGreater "At least one line of trace data" $(cat trace-cmd-show-function.log | wc -l) 1 + rlRun "trace-cmd stop" + rlRun "trace-cmd reset" + rlFileSubmit trace-cmd-show-function.log + rm -f trace-cmd-show-function.log + rlPhaseEnd + fi + done +rlJournalEnd diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..e244be9 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,11 @@ +- hosts: localhost + tags: + - classic + roles: + - role: standard-test-beakerlib + tests: + - sanity + required_packages: + - kernel + - trace-cmd +