public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob 9b7da359ffe6f9d137d1ba67c0d0889b040d8b7a 2323 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
 
#! @PYTHON3@

import contextlib
import os.path
import shutil
import subprocess
import tempfile

import exeter

def host_run(cmd, **kwargs):
    return subprocess.run(cmd, shell=True, check=True, encoding='UTF-8', **kwargs)


def host_out(cmd):
    return host_run(cmd, capture_output=True).stdout


@contextlib.contextmanager
def clone_source_tree():
    with tempfile.TemporaryDirectory(ignore_cleanup_errors=False) as tmpdir:
        # Make a temporary copy of the sources
        srcfiles = host_out('git ls-files').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)
        host_run(f'make {target} CFLAGS="-Werror"')
        for o in outputs:
            assert os.path.exists(o)
        host_run('make clean')
        for o in outputs:
            assert not os.path.exists(o)


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


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


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


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


@exeter.test
def test_make_install_uninstall():
    with clone_source_tree():
        with tempfile.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
            host_run(f'make install CFLAGS="-Werror" prefix={prefix}')

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

            # Uninstall
            host_run(f'make uninstall prefix={prefix}')

            for t in exes:
                assert not os.path.exists(os.path.join(bindir, t))
                exeter.assert_raises(subprocess.CalledProcessError,
                                     host_run, f'man -M {mandir} -W passt')


if __name__ == '__main__':
    exeter.main()

debug log:

solving 9b7da359 ...
found 9b7da359 in https://archives.passt.top/passt-dev/20240719065907.3539211-5-david@gibson.dropbear.id.au/

applying [1/1] https://archives.passt.top/passt-dev/20240719065907.3539211-5-david@gibson.dropbear.id.au/
diff --git a/test/build/build.exeter.in b/test/build/build.exeter.in
new file mode 100644
index 00000000..9b7da359

Checking patch test/build/build.exeter.in...
Applied patch test/build/build.exeter.in cleanly.

index at:
100644 9b7da359ffe6f9d137d1ba67c0d0889b040d8b7a	test/build/build.exeter.in

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).