From 3889bc54da54ebba9d1f8d761853a749a3d1cbfc Mon Sep 17 00:00:00 2001 From: Zoltan Fridrich Date: Wed, 21 Jul 2021 14:22:43 +0200 Subject: [PATCH] Add gating.yaml and tests Resolves: rhbz#1938758 (check-gitbz workaround, this bz is unrelated) --- gating.yaml | 6 ++++ tests/devel-usability/hello_world.cpp | 45 +++++++++++++++++++++++++++ tests/devel-usability/runtest.sh | 20 ++++++++++++ tests/tests.yml | 13 ++++++++ 4 files changed, 84 insertions(+) create mode 100644 gating.yaml create mode 100644 tests/devel-usability/hello_world.cpp create mode 100755 tests/devel-usability/runtest.sh create mode 100644 tests/tests.yml diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..648918d --- /dev/null +++ b/gating.yaml @@ -0,0 +1,6 @@ +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/tests/devel-usability/hello_world.cpp b/tests/devel-usability/hello_world.cpp new file mode 100644 index 0000000..58b9706 --- /dev/null +++ b/tests/devel-usability/hello_world.cpp @@ -0,0 +1,45 @@ +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include +#include + +#include + +namespace pegtl = tao::pegtl; + +namespace hello +{ + // clang-format off + struct prefix : pegtl::string< 'H', 'e', 'l', 'l', 'o', ',', ' ' > {}; + struct name : pegtl::plus< pegtl::alpha > {}; + struct grammar : pegtl::must< prefix, name, pegtl::one< '!' >, pegtl::eof > {}; + // clang-format on + + template< typename Rule > + struct action : pegtl::nothing + {}; + + template<> + struct action< name > + { + template< typename Input > + static void apply( const Input& in, std::string& v ) + { + v = in.string(); + } + }; + +} // namespace hello + +int main( int argc, char** argv ) +{ + if( argc > 1 ) { + std::string name; + + pegtl::argv_input<> in( argv, 1 ); + pegtl::parse< hello::grammar, hello::action >( in, name ); + + std::cout << "Good bye, " << name << "!" << std::endl; + } +} diff --git a/tests/devel-usability/runtest.sh b/tests/devel-usability/runtest.sh new file mode 100755 index 0000000..746571b --- /dev/null +++ b/tests/devel-usability/runtest.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +TEST_SOURCE=hello_world.cpp +TEST_TARGET="${TEST_SOURCE/\.cpp/}" + +CXXFLAGS="$(rpm --eval '%{build_cxxflags}')" +LDFLAGS="$(rpm --eval '%{build_ldflags}')" + +# build target using distribution-specific flags +g++ -std=c++11 $CXXFLAGS $LDFLAGS -o $TEST_TARGET $TEST_SOURCE + +# test that target exists +test -f ./$TEST_TARGET + +# test that target is executable +test -x ./$TEST_TARGET + +# test that target runs successfully +./$TEST_TARGET "Hello, world!" diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..87392fa --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,13 @@ +--- +- hosts: localhost + tags: + - classic + roles: + - role: standard-test-basic + tests: + - devel-usability + required_packages: + - gcc-c++ + - rpm + - redhat-rpm-config + - PEGTL-devel