#1 Initial commit for downstream tests using standard test interface
Closed 2 months ago by submachine. Opened 6 years ago by rasibley.
rpms/ rasibley/flex flex-tests  into  rawhide

@@ -0,0 +1,63 @@ 

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile 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/.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ export TEST=/tools/flex/Sanity/smoke-check-flex-runs

+ export TESTVERSION=1.0

+ 

+ BUILT_FILES=

+ 

+ FILES=$(METADATA) runtest.sh Makefile PURPOSE count_chars_and_lines.l calc-lexer.l calc-grammar.y expected_calc_output.txt

+ 

+ .PHONY: all install download clean

+ 

+ run: $(FILES) build

+ 	./runtest.sh

+ 

+ build: $(BUILT_FILES)

+ 	test -x runtest.sh || chmod a+x runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

+ include /usr/share/rhts/lib/rhts-make.include

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Vaclav Kadlcik <vkadlcik@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     Show your version. Build a one-file project." >> $(METADATA)

+ 	@echo "Type:            Sanity" >> $(METADATA)

+ 	@echo "TestTime:        15m" >> $(METADATA)

+ 	@echo "RunFor:          flex" >> $(METADATA)

+ 	@echo "Requires:        flex flex-devel bison gcc" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2+" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 	@echo "Releases:        -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

@@ -0,0 +1,3 @@ 

+ PURPOSE of /tools/flex/Sanity/smoke-check-flex-runs

+ Description: Show your version. Build a one-file project.

+ Author: Vaclav Kadlcik <vkadlcik@redhat.com>

@@ -0,0 +1,36 @@ 

+ %{

+ #include <stdio.h>

+ %}

+ 

+ %token NUMBER

+ %token ADD SUB MUL DIV

+ %token EOL

+ 

+ %%

+ 

+ input:

+ 	| input EOL { }

+ 	| input expression EOL { printf("%d\n", $2); }

+ 	;

+ 

+ expression:

+ 	factor

+ 	| expression ADD factor { $$ = $1 + $3; }

+ 	| expression SUB factor { $$ = $1 - $3; }

+ 	;

+ 

+ factor:

+ 	NUMBER

+ 	| factor MUL NUMBER { $$ = $1 * $3; }

+ 	| factor DIV NUMBER { $$ = $1 / $3; }

+ 	;

+ 

+ %%

+ 

+ int main(int argc, char ** argv) {

+ 	yyparse();

+ }

+ 

+ yyerror(char *s) {

+ 	fprintf(stderr, "ERROR: %s\n", s);

+ }

@@ -0,0 +1,14 @@ 

+ %{

+ #include "calc-grammar.tab.h"

+ %}

+ 

+ %%

+ "+"     { return ADD; }

+ "-"     { return SUB; }

+ "*"     { return MUL; }

+ "/"     { return DIV; }

+ [0-9]+  { yylval = atoi(yytext); return NUMBER; }

+ \n      { return EOL; }

+ [ \t]   { /* ignore whitespaces */ }

+ .       { yyerror("unexpected character %c", *yytext); }

+ %%

@@ -0,0 +1,20 @@ 

+ %{

+ #include <stdio.h>

+ 

+ int chars = 0;

+ int lines = 0;

+ %}

+ 

+ %%

+ 

+ \n { lines++; chars++; }

+ .  { chars++; }

+ 

+ %%

+ 

+ int main(int argc, char ** argv) {

+ 	yylex();

+ 	printf("chars: %d\n", chars);

+ 	printf("lines: %d\n", lines);

+ 	return 0;

+ }

@@ -0,0 +1,3 @@ 

+ STDOUT: 7

+ STDOUT: -221

+ STDOUT: 42

@@ -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

file added
+12
@@ -0,0 +1,12 @@ 

+ ---

+ # This first play always runs on the local staging system

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     - container

+     tests:

+     - smoke-check-flex-runs

+     required_packages:

+     - flex

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

Hello, just following up to see if there is any additional information I can provide to help move this along ?

This PR was overlooked. We should have reviewed and included it ~6y ago but it was missed. In the meanwhile it appears that it has been superseded by newer CI (gating.yaml and tests/Sanity). I'm therefore closing this PR.

Pull-Request has been closed by submachine

2 months ago