From a31bbb3c5a2f1eea4d4a0735320fb64c558a22a0 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 17 Jun 2021 15:30:31 -0700 Subject: [PATCH] gating: Add gating tests This adds some simple gating tests using the installed library. Resolves: rhbz#1972786 --- gating.yaml | 6 ++++++ tests/simple/run_tests.sh | 12 ++++++++++++ tests/simple/test-pycdlib.py | 27 +++++++++++++++++++++++++++ tests/tests.yml | 12 ++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 gating.yaml create mode 100755 tests/simple/run_tests.sh create mode 100644 tests/simple/test-pycdlib.py 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/simple/run_tests.sh b/tests/simple/run_tests.sh new file mode 100755 index 0000000..08f90e5 --- /dev/null +++ b/tests/simple/run_tests.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -eux + +# Make a very simple iso with a volid +xorrisofs -o file.iso -V "test-pycdlib-volid" || exit 1 +python3 ./test-pycdlib.py file.iso "test-pycdlib-volid" || exit 1 + +# Run a couple of the example scripts +python3 /usr/share/doc/python3-pycdlib/examples/create-bootable.py || exit 1 +file eltorito.iso | grep bootable || exit 1 +python3 /usr/share/doc/python3-pycdlib/examples/create-new.py || exit 1 +file new.iso | grep "ISO 9660 CD-ROM" || exit 1 diff --git a/tests/simple/test-pycdlib.py b/tests/simple/test-pycdlib.py new file mode 100644 index 0000000..ed29c96 --- /dev/null +++ b/tests/simple/test-pycdlib.py @@ -0,0 +1,27 @@ +"""Simple test for pycdlib + +Extract the volid from the iso and compare it to the one passed on the cmdline +""" +import os +import sys +import pycdlib +from pycdlib.pycdlibexception import PyCdlibException + +if len(sys.argv) != 3: + print("usage: %s file.iso volid" % (sys.argv[0])) + sys.exit(1) + +try: + iso = pycdlib.PyCdlib() + iso.open(sys.argv[1]) + volid = iso.pvd.volume_identifier.decode("UTF-8").strip() +except PyCdlibException as e: + print("ERROR: Problem reading label from %s: %s" % (self.iso_path, e)) + sys.exit(1) + +print("VOLID: %s" % volid) +if volid != sys.argv[2]: + print("ERROR: %s != %s" % (volid, sys.argv[2])) + sys.exit(1) + +sys.exit(0) diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..661a893 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,12 @@ +--- +- hosts: localhost + tags: + - classic + roles: + - role: standard-test-basic + required_packages: + - python-pycdlib + - xorriso + tests: + - simple: + run: ./run_tests.sh