Resolves: RHELMISC-5984 Add tmt based CI test

This commit is contained in:
Mike FABIAN 2024-07-10 16:45:33 +02:00
parent 17c26f681e
commit bb00087b6c
6 changed files with 64 additions and 0 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

5
plans/basic.fmf Normal file
View File

@ -0,0 +1,5 @@
summary: Basic smoke test
discover:
how: fmf
execute:
how: tmt

3
tests/foma-input.txt Normal file
View File

@ -0,0 +1,3 @@
def Animals c a t | d o g ;
regex Animals+ ;
print defined

7
tests/main.fmf Normal file
View File

@ -0,0 +1,7 @@
framework: beakerlib
duration: 10m
require:
- foma
- python3
test: ./runtest.sh

23
tests/runtest.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlAssertRpm python3
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "cp test_foma.py foma-input.txt $tmp"
rlRun "pushd $tmp"
rlPhaseEnd
rlPhaseStartTest
rlRun "python3 test_foma.py -v" \
0 "Running test cases"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd

25
tests/test_foma.py Normal file
View File

@ -0,0 +1,25 @@
import unittest
import sys
import subprocess
class TestFoma(unittest.TestCase):
def test_dummy(self):
self.assertEqual(True, True)
@unittest.expectedFailure
def test_expected_failure(self):
self.assertEqual(False, True)
def test_foma(self):
cp = subprocess.run(['foma -f foma-input.txt'], encoding='UTF-8', text=True, shell=True, capture_output=True)
self.assertEqual(
'defined Animals: 455 bytes. 6 states, 6 arcs, 2 paths.\n'
'471 bytes. 6 states, 8 arcs, Cyclic.\n'
'Animals\t455 bytes. 6 states, 6 arcs, 2 paths.\n',
cp.stdout)
self.assertEqual('', cp.stderr)
self.assertEqual(0, cp.returncode)
if __name__ == "__main__":
unittest.main()