Introduce CI gating #2

This commit is contained in:
Edjunior Machado 2021-10-04 14:38:18 +02:00
parent f805f0bc57
commit a024dea3e5
8 changed files with 254 additions and 0 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

19
gating.yaml Normal file
View File

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

6
plans/ci.fmf Normal file
View File

@ -0,0 +1,6 @@
summary: CI Gating Plan
discover:
how: fmf
directory: tests
execute:
how: beakerlib

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/cppunit/Sanity/basic-test
# Description: cppunit basic test
# Author: Edjunior Machado <emachado@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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/cppunit/Sanity/basic-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE hello.cpp
.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 <emachado@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: cppunit basic test" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 1h" >> $(METADATA)
@echo "RunFor: cppunit" >> $(METADATA)
@echo "Requires: gcc-c++ cppunit cppunit-devel" >> $(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)

View File

@ -0,0 +1,3 @@
PURPOSE of /tools/cppunit/Sanity/basic-test
Description: cppunit basic test
Author: Edjunior Machado <emachado@redhat.com>

View File

@ -0,0 +1,92 @@
#include <iostream>
#include <cppunit/TestRunner.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/XmlOutputter.h>
using namespace std;
class Math
{
public:
int Addition (int x, int y);
};
int
Math::Addition (int x, int y)
{
return (x + y);
}
class Test:public
CPPUNIT_NS::TestCase
{
CPPUNIT_TEST_SUITE (Test);
CPPUNIT_TEST (testAddition);
CPPUNIT_TEST_SUITE_END ();
public:
void
setUp (void);
void
tearDown (void);
protected:
void
testAddition (void);
private:
Math *
mTestObj;
};
void
Test::testAddition (void)
{
CPPUNIT_ASSERT (5 == mTestObj->Addition (2, 3));
}
void
Test::setUp (void)
{
mTestObj = new Math ();
}
void
Test::tearDown (void)
{
delete mTestObj;
}
CPPUNIT_TEST_SUITE_REGISTRATION (Test);
int
main (int ac, char **av)
{
CPPUNIT_NS::TestResult controller;
CPPUNIT_NS::TestResultCollector result;
controller.addListener (&result);
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener (&progress);
CPPUNIT_NS::TestRunner runner;
runner.
addTest (CPPUNIT_NS::TestFactoryRegistry::getRegistry ().makeTest ());
runner.run (controller);
CPPUNIT_NS::CompilerOutputter compileroutputter (&result, std::cerr);
compileroutputter.write ();
ofstream xmlFileOut ("output.xml");
CPPUNIT_NS::XmlOutputter xmlOut (&result, xmlFileOut);
xmlOut.write ();
return result.wasSuccessful ()? 0 : 1;
}

View File

@ -0,0 +1,14 @@
summary: cppunit basic test
description: ''
contact: Edjunior Machado <emachado@redhat.com>
component:
- cppunit
test: ./runtest.sh
framework: beakerlib
recommend:
- gcc-c++
- cppunit
- cppunit-devel
duration: 1h
extra-summary: /tools/cppunit/Sanity/basic-test
extra-task: /tools/cppunit/Sanity/basic-test

View File

@ -0,0 +1,56 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /tools/cppunit/Sanity/basic-test
# Description: cppunit basic test
# Author: Edjunior Machado <emachado@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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="cppunit"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp hello.cpp $TmpDir"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "g++ -Wall -o hello hello.cpp -lcppunit"
rlAssertExists "hello"
rlRun "./hello > hello.log"
rlRun "cat hello.log"
rlAssertGrep 'Test::testAddition : OK' hello.log
rlRun "cat output.xml"
rlAssertGrep '<Name>Test::testAddition</Name>' output.xml
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd