| |
@@ -0,0 +1,79 @@
|
| |
+ #!/usr/bin/env bash
|
| |
+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
| |
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
+ #
|
| |
+ # runtest.sh of /tools/flex/Sanity/smoke-check-flex-runs
|
| |
+ # Description: Show your version. Build a one-file project.
|
| |
+ # Author: Vaclav Kadlcik <vkadlcik@redhat.com>
|
| |
+ #
|
| |
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
+ #
|
| |
+ # Copyright (c) 2015 Red Hat, Inc.
|
| |
+ #
|
| |
+ # 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 2 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 http://www.gnu.org/licenses/.
|
| |
+ #
|
| |
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
+
|
| |
+ # Include Beaker environment
|
| |
+ . /usr/bin/rhts-environment.sh || exit 1
|
| |
+ . /usr/share/beakerlib/beakerlib.sh || exit 1
|
| |
+
|
| |
+ PACKAGE="flex"
|
| |
+
|
| |
+ rlJournalStart
|
| |
+ rlPhaseStartSetup
|
| |
+ rlAssertRpm $PACKAGE
|
| |
+ yum -y install flex-devel bison gcc
|
| |
+ rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
| |
+ rlRun "cp count_chars_and_lines.l calc-lexer.l calc-grammar.y expected_calc_output.txt $TmpDir"
|
| |
+ rlRun "pushd $TmpDir"
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlPhaseStartTest 'Show version'
|
| |
+
|
| |
+ rlRun -t -s 'flex -V'
|
| |
+ rlAssertNotGrep '^STDERR:' $rlRun_LOG
|
| |
+ rlAssertGrep '^STDOUT: flex [0-9]' $rlRun_LOG
|
| |
+
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlPhaseStartTest 'Flex works standalone'
|
| |
+
|
| |
+ rlRun 'flex -o count_chars_and_lines.c count_chars_and_lines.l'
|
| |
+ rlRun 'gcc -o count_chars_and_lines count_chars_and_lines.c -lfl'
|
| |
+ rlAssertExists 'count_chars_and_lines'
|
| |
+ rlRun -t -s 'echo -e "nazdar\nbazar" | ./count_chars_and_lines'
|
| |
+ rlAssertNotGrep '^STDERR:' $rlRun_LOG
|
| |
+ rlAssertGrep '^STDOUT: chars: 13$' $rlRun_LOG
|
| |
+ rlAssertGrep '^STDOUT: lines: 2$' $rlRun_LOG
|
| |
+
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlPhaseStartTest 'Flex works with Bison'
|
| |
+
|
| |
+ rlRun 'bison -d calc-grammar.y'
|
| |
+ rlRun 'flex calc-lexer.l'
|
| |
+ rlRun 'gcc -o calc calc-grammar.tab.c lex.yy.c -lfl'
|
| |
+ rlAssertExists 'calc'
|
| |
+ rlRun -t -s 'echo -e "1 + 2 * 3\n1 - 666 / 3\n42" | ./calc'
|
| |
+ rlAssertNotDiffer expected_calc_output.txt $rlRun_LOG
|
| |
+
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlPhaseStartCleanup
|
| |
+ rlRun "popd"
|
| |
+ rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
| |
+ rlPhaseEnd
|
| |
+ rlJournalPrintText
|
| |
+ rlJournalEnd
|
| |
Adds tests according to the CI wiki [0] specifically the standard test interface in the spec [1].
The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Docker, and Classic.
Test logs are stored in the Artifacts directory. Currently tests are not suitable for Atomic but may be updated later to support it.
The following steps are used to execute the tests using the standard test interface:
Atomic
sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS=../atomic.qcow2 TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags atomic tests.yml
Docker
sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_DEBUG=1 TEST_SUBJECTS=docker:docker.io/library/fedora:26 TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags container tests.yml
Classic
sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS="" TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags classic tests.yml
Test Logs: (If you would like a pointer to the complete log, I can include that as well)
Docker
<snip>
01:45:08 TASK [standard-test-beakerlib : Execute beakerlib tests]
01:45:35 changed: [4d7535e553e00d50902be9b8f82c345d47f4621ac998b205fba73c75b68e1f2b] => (item=smoke-check-flex-runs)
01:45:35
01:45:35 TASK [standard-test-beakerlib : Make the master test summary log artifact]
01:45:36 changed: [4d7535e553e00d50902be9b8f82c345d47f4621ac998b205fba73c75b68e1f2b] => (item=smoke-check-flex-runs)
01:45:36
01:45:36 TASK [standard-test-beakerlib : Pull out the logs]
01:45:36 changed: [4d7535e553e00d50902be9b8f82c345d47f4621ac998b205fba73c75b68e1f2b]
01:45:36
01:45:36 TASK [standard-test-beakerlib : Check the results]
01:45:37 changed: [4d7535e553e00d50902be9b8f82c345d47f4621ac998b205fba73c75b68e1f2b]
01:45:37
01:45:37 PLAY RECAP
01:45:37 4d7535e553e00d50902be9b8f82c345d47f4621ac998b205fba73c75b68e1f2b : ok=15 changed=11 unreachable=0 failed=0
01:45:37
01:45:37 ###################################
01:45:37 Test results:
01:45:37 ###################################
01:45:37 PASS smoke-check-flex-runs
01:45:37 ###################################
Classic
<snip>
01:38:41 ==> default: TASK [standard-test-beakerlib : Execute beakerlib tests]
01:39:11 ==> default: changed: [localhost] => (item=smoke-check-flex-runs)
01:39:11 ==> default:
01:39:11 ==> default: TASK [standard-test-beakerlib : Make the master test summary log artifact]
01:39:11 ==> default: changed: [localhost] => (item=smoke-check-flex-runs)
01:39:11 ==> default:
01:39:11 ==> default: TASK [standard-test-beakerlib : Pull out the logs]
01:39:12 ==> default: changed: [localhost]
01:39:12 ==> default:
01:39:12 ==> default: TASK [standard-test-beakerlib : Check the results]
01:39:12 ==> default: changed: [localhost]
01:39:12 ==> default:
01:39:12 ==> default: PLAY RECAP
01:39:12 ==> default: localhost : ok=15 changed=12 unreachable=0 failed=0
01:39:12 ==> default: ++ '[' 0 -ne 0 ']'
01:39:12 ==> default: ++ cat /root/flex/artifacts/test.log
01:39:12 ==> default: PASS smoke-check-flex-runs
01:39:12 ==> default: ++ grep -ve '^PASS' /root/flex/artifacts/test.log
01:39:12 ==> default: PASS: all tests passed.
01:39:12 ==> default: ++ '[' 1 -eq 1 ']'
01:39:12 ==> default: ++ echo 'PASS: all tests passed.'
Tests will be enabled in CI, yet gating is currently disabled, so nothing will change. However eventually gating will be enabled. Tests will run on each dist-git commit, they are not triggered on koji builds and if you are using FMN, it should notify you of failures normally.
The RH QE maintainer contact in case you have questions: mpetlan@redhat.com
The idea is that these tests become yours just as you're maintaining the package, there will of course be people around if you have questions or troubles.
[0] https://fedoraproject.org/wiki/CI
[1] https://fedoraproject.org/wiki/Changes/InvokingTests