From 3cbe8fc6e3a56850c095502acbd3e8d0a9749642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zachar?= Date: Fri, 3 Jul 2026 10:00:31 +0200 Subject: [PATCH] Use tmt for gating --- .fmf/version | 1 + gating.yaml | 5 +++ plan.fmf | 4 ++ tests/smoke/main.fmf | 5 +++ tests/smoke/pyyaml_dump.py | 3 ++ tests/smoke/pyyaml_load.py | 13 +++++++ tests/smoke/pyyaml_object.py | 16 ++++++++ tests/smoke/pyyaml_parse.py | 9 +++++ tests/smoke/runtest.sh | 74 ++++++++++++++++++++++++++++++++++++ 9 files changed, 130 insertions(+) create mode 100644 .fmf/version create mode 100644 gating.yaml create mode 100644 plan.fmf create mode 100644 tests/smoke/main.fmf create mode 100644 tests/smoke/pyyaml_dump.py create mode 100644 tests/smoke/pyyaml_load.py create mode 100644 tests/smoke/pyyaml_object.py create mode 100644 tests/smoke/pyyaml_parse.py create mode 100755 tests/smoke/runtest.sh 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..16755b7 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,5 @@ +--- !Policy + +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/plan.fmf b/plan.fmf new file mode 100644 index 0000000..0392cd5 --- /dev/null +++ b/plan.fmf @@ -0,0 +1,4 @@ +discover: + how: fmf +execute: + how: tmt diff --git a/tests/smoke/main.fmf b/tests/smoke/main.fmf new file mode 100644 index 0000000..7d9c513 --- /dev/null +++ b/tests/smoke/main.fmf @@ -0,0 +1,5 @@ +test: ./runtest.sh +framework: beakerlib +require: + - python3-pyyaml +duration: 5m diff --git a/tests/smoke/pyyaml_dump.py b/tests/smoke/pyyaml_dump.py new file mode 100644 index 0000000..a6f4a6d --- /dev/null +++ b/tests/smoke/pyyaml_dump.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python +import yaml +print(yaml.dump({'name': 'Silenthand Olleander', 'race': 'Human', 'traits': ['ONE_HAND', 'ONE_EYE']})) diff --git a/tests/smoke/pyyaml_load.py b/tests/smoke/pyyaml_load.py new file mode 100644 index 0000000..6bf48f2 --- /dev/null +++ b/tests/smoke/pyyaml_load.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +import yaml +documents = """ +--- +name: foo +--- +name: bar +--- +name: foobar +""" + +for data in yaml.load_all(documents, Loader=yaml.SafeLoader): + print(data) diff --git a/tests/smoke/pyyaml_object.py b/tests/smoke/pyyaml_object.py new file mode 100644 index 0000000..5a821f5 --- /dev/null +++ b/tests/smoke/pyyaml_object.py @@ -0,0 +1,16 @@ +import yaml +class Hero: + def __init__(self, name, hp, sp): + self.name = name + self.hp = hp + self.sp = sp + def __repr__(self): + return "%s(name=%r, hp=%r, sp=%r)" % ( + self.__class__.__name__, self.name, self.hp, self.sp) + +print(yaml.load(""" +!!python/object:__main__.Hero +name: Welthyr Syxgon +hp: 1200 +sp: 0 +""")) diff --git a/tests/smoke/pyyaml_parse.py b/tests/smoke/pyyaml_parse.py new file mode 100644 index 0000000..3850b78 --- /dev/null +++ b/tests/smoke/pyyaml_parse.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +import yaml +document = """ + a: 1 + b: + c: 3 + d: 4 +""" +print(yaml.dump(yaml.load(document, Loader=yaml.SafeLoader))) diff --git a/tests/smoke/runtest.sh b/tests/smoke/runtest.sh new file mode 100755 index 0000000..72451ed --- /dev/null +++ b/tests/smoke/runtest.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/PyYAML/Sanity/Smoke +# Description: Smoke test for this component +# Author: Stepan Sigut +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 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 + +PYTHON=${PYTHON:-"python3"} + +PATTERN1="{'name': 'foo'} +{'name': 'bar'} +{'name': 'foobar'}" +PATTERN3="name: Silenthand Olleander +race: Human +traits: [ONE_HAND, ONE_EYE]" +PATTERN4="a: 1 +b: {c: 3, d: 4}" +PATTERN5="Hero(name='Welthyr Syxgon', hp=1200, sp=0)" + +set -o pipefail + +rlJournalStart + rlPhaseStartSetup + # export python's MAJOR and MINOR version + rlRun "export $($PYTHON -c \ + 'import sys; print("MAJOR={0} MINOR={1}".format(\ + sys.version_info[0],sys.version_info[1]))')" + rlPhaseEnd + + rlPhaseStartTest "Running pyyaml_load.py" + rlRun -s "$PYTHON pyyaml_load.py" + rlAssertGrep "$PATTERN1" "$rlRun_LOG" + rlPhaseEnd + + rlPhaseStartTest "Running pyyaml_dump.py" + rlRun -s "$PYTHON pyyaml_dump.py" + rlAssertGrep "$PATTERN3" "$rlRun_LOG" + rlPhaseEnd + + rlPhaseStartTest "Running pyyaml_parse.py" + rlRun -s "$PYTHON pyyaml_parse.py" + rlAssertGrep "$PATTERN4" "$rlRun_LOG" + rlPhaseEnd + + rlPhaseStartTest "Running pyyaml_object.py" + rlRun -s "$PYTHON pyyaml_object.py" + rlAssertGrep "$PATTERN5" "$rlRun_LOG" + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd