diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..ce3cdc1 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,19 @@ +--- !Policy +product_versions: + - fedora-* +decision_context: bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} +--- !Policy +product_versions: + - rhel-8 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} diff --git a/plans/ci.fmf b/plans/ci.fmf new file mode 100644 index 0000000..1ad2c12 --- /dev/null +++ b/plans/ci.fmf @@ -0,0 +1,6 @@ +summary: CI Gating Plan +discover: + how: fmf + directory: tests +execute: + how: beakerlib diff --git a/tests/Sanity/basic-test/Makefile b/tests/Sanity/basic-test/Makefile new file mode 100644 index 0000000..9a64167 --- /dev/null +++ b/tests/Sanity/basic-test/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/bison/Sanity/basic-test +# Description: bison basic test +# Author: Edjunior Machado +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 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/bison/Sanity/basic-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE calc.y + +.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: Edjunior Machado " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: bison basic test" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 1h" >> $(METADATA) + @echo "RunFor: bison" >> $(METADATA) + @echo "Requires: bison gcc" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5 -RHEL6" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Sanity/basic-test/PURPOSE b/tests/Sanity/basic-test/PURPOSE new file mode 100644 index 0000000..fe778df --- /dev/null +++ b/tests/Sanity/basic-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/bison/Sanity/basic-test +Description: bison basic test +Author: Edjunior Machado diff --git a/tests/Sanity/basic-test/calc.y b/tests/Sanity/basic-test/calc.y new file mode 100644 index 0000000..f1fac0b --- /dev/null +++ b/tests/Sanity/basic-test/calc.y @@ -0,0 +1,100 @@ +%code top { + #include + #include /* isdigit. */ + #include /* printf. */ + #include /* abort. */ + #include /* strcmp. */ + + int yylex (void); + void yyerror (char const *); +} + +/* Generate YYSTYPE from the types used in %token and %type. */ +%define api.value.type union +%token NUM "number" +%type expr term fact + +/* Generate the parser description file (calc.output). */ +%verbose + +/* Nice error messages with details. */ +%define parse.error verbose + +/* Enable run-time traces (yydebug). */ +%define parse.trace + +/* Formatting semantic values in debug traces. */ +%printer { fprintf (yyo, "%g", $$); } ; + +%% /* The grammar follows. */ +input: + %empty +| input line +; + +line: + '\n' +| expr '\n' { printf ("%.10g\n", $1); } +| error '\n' { yyerrok; } +; + +expr: + expr '+' term { $$ = $1 + $3; } +| expr '-' term { $$ = $1 - $3; } +| term +; + +term: + term '*' fact { $$ = $1 * $3; } +| term '/' fact { $$ = $1 / $3; } +| fact +; + +fact: + "number" +| '(' expr ')' { $$ = $2; } +; + +%% + +int +yylex (void) +{ + int c; + + /* Ignore white space, get first nonwhite character. */ + while ((c = getchar ()) == ' ' || c == '\t') + continue; + + if (c == EOF) + return 0; + + /* Char starts a number => parse the number. */ + if (c == '.' || isdigit (c)) + { + ungetc (c, stdin); + if (scanf ("%lf", &yylval.NUM) != 1) + abort (); + return NUM; + } + + /* Any other character is a token by itself. */ + return c; +} + +/* Called by yyparse on error. */ +void +yyerror (char const *s) +{ + fprintf (stderr, "%s\n", s); +} + +int +main (int argc, char const* argv[]) +{ + /* Enable parse traces on option -p. */ + for (int i = 1; i < argc; ++i) + if (!strcmp (argv[i], "-p")) + yydebug = 1; + return yyparse (); +} diff --git a/tests/Sanity/basic-test/main.fmf b/tests/Sanity/basic-test/main.fmf new file mode 100644 index 0000000..9efa915 --- /dev/null +++ b/tests/Sanity/basic-test/main.fmf @@ -0,0 +1,14 @@ +summary: bison basic test +description: '' +contact: +- Edjunior Machado +component: +- bison +test: ./runtest.sh +framework: beakerlib +recommend: +- bison +- gcc +duration: 1h +extra-summary: /tools/bison/Sanity/basic-test +extra-task: /tools/bison/Sanity/basic-test diff --git a/tests/Sanity/basic-test/runtest.sh b/tests/Sanity/basic-test/runtest.sh new file mode 100755 index 0000000..be397d7 --- /dev/null +++ b/tests/Sanity/basic-test/runtest.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/bison/Sanity/basic-test +# Description: bison basic test +# Author: Edjunior Machado +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 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/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="bison" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp calc.y $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + # calc.y from http://git.savannah.gnu.org/cgit/bison.git/tree/examples/c/calc?h=v3.7.5 + rlRun -c "bison --defines --xml --graph=calc.gv -o calc.c calc.y" + + rlAssertExists "calc.c" + rlAssertGrep "int yylex (void);" calc.c + rlAssertExists "calc.h" + rlAssertGrep "int yyparse (void);" calc.h + + rlRun -c "gcc -std=c99 -o calc calc.c" + rlAssertExists "calc" + + rlAssertEquals "Testing if './calc <<< 1+2*3' is equal '7'" $(./calc <<< 1+2*3) 7 + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd