public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob 4cce77a6f2cd4ba291dede436a127bdbaea608c8 2468 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 
#! /usr/bin/env avocado-runner-avocado-classless

# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>

"""
avocado/build.py - Test passt & pasta build targets
"""


import contextlib
import os
import os.path
import shutil
from tempfile import TemporaryDirectory

from avocado_classless.test import assert_raises, test

from tasst.exesite import CmdError, REAL_HOST


@contextlib.contextmanager
def clone_source_tree():
    REAL_HOST.require_cmds('git', 'make')

    with TemporaryDirectory(ignore_cleanup_errors=False) as tmpdir:
        os.chdir('..')
        # Make a temporary copy of the sources
        srcfiles = REAL_HOST.output('git ls-files') \
                            .decode('utf-8').splitlines()
        for src in srcfiles:
            dst = os.path.join(tmpdir, src)
            os.makedirs(os.path.dirname(dst), exist_ok=True)
            shutil.copy(src, dst)
        os.chdir(tmpdir)
        yield tmpdir


def build_target(target, outputs):
    with clone_source_tree():
        for o in outputs:
            assert not os.path.exists(o)
        REAL_HOST.fg(f'make {target} CFLAGS="-Werror"')
        for o in outputs:
            assert os.path.exists(o)
        REAL_HOST.fg('make clean')
        for o in outputs:
            assert not os.path.exists(o)


@test
def test_make_passt():
    build_target('passt', ['passt'])


@test
def test_make_pasta():
    build_target('pasta', ['pasta'])


@test
def test_make_qrap():
    build_target('qrap', ['qrap'])


@test
def test_make_all():
    build_target('all', ['passt', 'pasta', 'qrap'])


@test
def test_make_install_uninstall():
    with clone_source_tree():
        with TemporaryDirectory(ignore_cleanup_errors=False) as prefix:
            bindir = os.path.join(prefix, 'bin')
            mandir = os.path.join(prefix, 'share', 'man')
            exes = ['passt', 'pasta', 'qrap']

            # Install
            REAL_HOST.fg(f'make install CFLAGS="-Werror" prefix={prefix}')

            for t in exes:
                assert os.path.isfile(os.path.join(bindir, t))
                REAL_HOST.fg(f'man -M {mandir} -W passt')

            # Uninstall
            REAL_HOST.fg(f'make uninstall prefix={prefix}')

            for t in exes:
                assert not os.path.exists(os.path.join(bindir, t))
                assert_raises(CmdError, REAL_HOST.fg,
                              f'man -M {mandir} -W passt')

debug log:

solving 4cce77a6 ...
found 4cce77a6 in https://archives.passt.top/passt-dev/20230627025429.2209702-13-david@gibson.dropbear.id.au/

applying [1/1] https://archives.passt.top/passt-dev/20230627025429.2209702-13-david@gibson.dropbear.id.au/
diff --git a/test/avocado/build.py b/test/avocado/build.py
new file mode 100644
index 00000000..4cce77a6

Checking patch test/avocado/build.py...
Applied patch test/avocado/build.py cleanly.

index at:
100644 4cce77a6f2cd4ba291dede436a127bdbaea608c8	test/avocado/build.py

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).