#! /usr/bin/env python3 # # SPDX-License-Identifier: GPL-2.0-or-later # # PASST - Plug A Simple Socket Transport # for qemu/UNIX domain socket mode # # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # # test/build/build.sh - Test build and install targets # # Copyright Red Hat # Author: David Gibson import contextlib import os from pathlib import Path import tempfile from typing import Iterable, Iterator import exeter import tasst.cmdsite # For convenience sh = tasst.cmdsite.BUILD_HOST.sh @contextlib.contextmanager def clone_sources() -> Iterator[str]: os.chdir('..') # Move from test/ to repo base with tempfile.TemporaryDirectory(ignore_cleanup_errors=False) as tmpdir: sh(f"cp --parents $(git ls-files) {tmpdir}") os.chdir(tmpdir) yield tmpdir def test_make(target: str, outputs: Iterable[str]) -> None: outpaths = [Path(o) for o in outputs] with clone_sources(): for o in outpaths: assert not o.exists(), f"{o} existed before make" sh(f'make {target} CFLAGS="-Werror"') for o in outpaths: assert o.exists(), f"{o} wasn't made" sh('make clean') for o in outpaths: assert not o.exists(), f"{o} existed after make clean" exeter.register('make_passt', test_make, 'passt', ['passt']) exeter.register('make_pasta', test_make, 'pasta', ['pasta']) exeter.register('make_qrap', test_make, 'qrap', ['qrap']) exeter.register('make_all', test_make, 'all', ['passt', 'pasta', 'qrap']) @exeter.test def test_install_uninstall() -> None: with clone_sources(): with tempfile.TemporaryDirectory(ignore_cleanup_errors=False) \ as prefix: bindir = Path(prefix) / 'bin' mandir = Path(prefix) / 'share/man' progs = ['passt', 'pasta', 'qrap'] # Install sh(f'make install CFLAGS="-Werror" prefix={prefix}') for prog in progs: exe = bindir / prog assert exe.is_file(), f"{exe} does not exist as a regular file" sh(f'man -M {mandir} -W {prog}') # Uninstall sh(f'make uninstall prefix={prefix}') for prog in progs: exe = bindir / prog assert not exe.exists(), f"{exe} exists after uninstall" sh(f'! man -M {mandir} -W {prog}') if __name__ == '__main__': exeter.main()