Commit b522147 Add testcases for trace-cmd

5 files Authored and Committed by Ziqian SUN (Zamir) a year ago
Add testcases for trace-cmd

Signed-off-by: Ziqian SUN (Zamir) <zsun@redhat.com>

    
 1 @@ -0,0 +1,44 @@
 2 + About
 3 + 
 4 + Trace-cmd tests according to the CI wiki specifically the standard test interface in the [spec](https://fedoraproject.org/wiki/Changes/InvokingTests).
 5 + 
 6 + The playbook includes Tier1 level test cases that have been tested in classic contexts and is passing reliably.
 7 + 
 8 + The following steps are used to execute the tests using the standard test interface:
 9 + 
10 + Test environment
11 + 
12 + Make sure you have installed packages from the spec
13 + 
14 +     `# dnf install ansible python2-dnf libselinux-python standard-test-roles ansible python2-dnf libselinux-python standard-test-roles`
15 + 
16 + Run tests for Classic
17 + ~~~~
18 +     # export TEST_SUBJECTS=
19 +     # sudo ansible-playbook --tags=classic tests.yml
20 + ~~~~
21 + 
22 + Snip of the example test run for Classic tests:
23 + 
24 + > TASK [standard-test-beakerlib : Run beakerlib tests] *****************************************************************************************************************************************
25 + >
26 + > changed: [localhost] => (item=sanity)
27 + > 
28 + > TASK [standard-test-beakerlib : Make the master tests summary log artifact] ******************************************************************************************************************
29 + >
30 + > changed: [localhost] => (item=sanity)
31 + > 
32 + > TASK [standard-test-beakerlib : Check the results] *******************************************************************************************************************************************
33 + >
34 + > changed: [localhost]
35 + > 
36 + > TASK [standard-test-beakerlib : include_role] ************************************************************************************************************************************************
37 + > 
38 + > TASK [str-common : Pull out the logs from test environment to test runner] *******************************************************************************************************************
39 + >
40 + > changed: [localhost]
41 + > 
42 + > PLAY RECAP ***********************************************************************************************************************************************************************************
43 + > 
44 + > localhost                  : ok=27   changed=16   unreachable=0    failed=0   
45 + > 
 1 @@ -0,0 +1,59 @@
 2 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3 + #
 4 + #   Description: Basic sanity test for trace-cmd
 5 + #   Author: Ziqian SUN (Zamir) <zsun@redhat.com>
 6 + #
 7 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 8 + #
 9 + # Copyright (c) 2018 Red Hat, Inc. All rights reserved.
10 + #
11 + # This program is free software: you can redistribute it and/or modify
12 + # it under the terms of the GNU General Public License as published by
13 + # the Free Software Foundation, either version 3 of the License, or
14 + # (at your option) any later version.
15 + #
16 + # This program is distributed in the hope that it will be useful,
17 + # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 + # GNU General Public License for more details.
20 + #
21 + # You should have received a copy of the GNU General Public License
22 + # along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 + #
24 + #
25 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 + 
27 + export PACKAGE_NAME=trace-cmd
28 + export TEST=/kernel/general/ftrace/tools/trace-cmd/sanity
29 + export TESTVERSION=0.1
30 + 
31 + FILES=$(METADATA) runtest.sh Makefile PURPOSE
32 + 
33 + .PHONY: all install download clean
34 + 
35 + run: $(FILES) build
36 + »       ./runtest.sh
37 + 
38 + build:
39 + »       chmod a+x runtest.sh
40 + 
41 + clean:
42 + »       rm -fr *~ tests-*.rpm
43 + 
44 + include /usr/share/rhts/lib/rhts-make.include
45 + 
46 + $(METADATA): Makefile
47 + »       @echo "Owner:           Ziqian SUN (Zamir) <zsun@redhat.com>" > $(METADATA)
48 + »       @echo "Name:            $(TEST)" >> $(METADATA)
49 + »       @echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)
50 + »       @echo "Path:            $(TEST_DIR)" >> $(METADATA)
51 + »       @echo "Description:     Basic sanity test for trace-cmd" >> $(METADATA)
52 + »       @echo "TestTime:        30m" >> $(METADATA)
53 + »       @echo "RunFor:          trace-cmd" >> $(METADATA)
54 + »       @echo "Requires:        @development" >> $(METADATA)
55 + »       @echo "Priority:        Normal" >> $(METADATA)
56 + »       @echo "License:         GPLv3" >> $(METADATA)
57 + »       @echo "Confidential:    no" >> $(METADATA)
58 + »       @echo "Destructive:     no" >> $(METADATA)
59 + 
60 + »       rhts-lint $(METADATA)
1 @@ -0,0 +1,1 @@
2 + Basic sanity test for trace-cmd
 1 @@ -0,0 +1,58 @@
 2 + #!/bin/bash
 3 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4 + #
 5 + #   Description: Basic sanity test for trace-cmd
 6 + #   Author: Ziqian SUN (Zamir) <zsun@redhat.com>
 7 + #
 8 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 9 + #
10 + # Copyright (c) 2018 Red Hat, Inc. All rights reserved.
11 + #
12 + # This program is free software: you can redistribute it and/or modify
13 + # it under the terms of the GNU General Public License as published by
14 + # the Free Software Foundation, either version 3 of the License, or
15 + # (at your option) any later version.
16 + #
17 + # This program is distributed in the hope that it will be useful,
18 + # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 + # GNU General Public License for more details.
21 + #
22 + # You should have received a copy of the GNU General Public License
23 + # along with this program.  If not, see <http://www.gnu.org/licenses/>.
24 + #
25 + #
26 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 + 
28 + # Include rhts environment
29 + . /usr/bin/rhts-environment.sh
30 + . /usr/share/beakerlib/beakerlib.sh
31 + 
32 + if ! mount | grep -q debugfs ; then
33 +     mount -t debugfs nodev /sys/kernel/debug
34 + fi
35 + 
36 + trace-cmd reset
37 + rlJournalStart
38 +     for TRACER in $(cat /sys/kernel/debug/tracing/available_tracers) ; do
39 +         rlPhaseStartTest "Enable ${TRACER} using trace-cmd"
40 +             rlRun "trace-cmd start -p ${TRACER}"
41 +             rlAssertEquals "Check current tracer" "$(cat /sys/kernel/debug/tracing/current_tracer)" "${TRACER}"
42 +             rlAssertEquals "Check tracing status" "$(cat /sys/kernel/debug/tracing/tracing_on)" "1"
43 +             rlRun "trace-cmd stop"
44 +             rlAssertEquals "Check tracing status" "$(cat /sys/kernel/debug/tracing/tracing_on)" "0"
45 +             rlRun "trace-cmd reset"
46 +         rlPhaseEnd
47 +         if [[ "${TRACER}" == "function" ]]; then
48 +             rlPhaseStartTest "Test trace-cmd show"
49 +                 rlRun "trace-cmd start -p ${TRACER}"
50 +                 rlRun "trace-cmd show | grep -v '^#' > trace-cmd-show-function.log"
51 +                 rlAssertGreater "At least one line of trace data" $(cat trace-cmd-show-function.log | wc -l) 1
52 +                 rlRun "trace-cmd stop"
53 +                 rlRun "trace-cmd reset"
54 +                 rlFileSubmit trace-cmd-show-function.log
55 +                 rm -f trace-cmd-show-function.log
56 +             rlPhaseEnd
57 +         fi
58 +     done
59 + rlJournalEnd
 1 @@ -0,0 +1,11 @@
 2 + - hosts: localhost
 3 +   tags:
 4 +   - classic
 5 +   roles:
 6 +   - role: standard-test-beakerlib
 7 +     tests:
 8 +     - sanity
 9 +     required_packages:
10 +     - kernel
11 +     - trace-cmd
12 +