public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
91f59036421cec3e8e030da6d3da0f3505f48646 blob 1248 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
 
#! /usr/bin/env python3
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# TASST - Test A Simple Socket Transport
#
# test/tasst/pasta.py - Helpers for seeting up pasta instances
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>

import contextlib
import os
from typing import Iterator

import tunbridge


@contextlib.contextmanager
def pasta(host: tunbridge.Site, guest: tunbridge.Site, *opts: str) \
        -> Iterator[tunbridge.site.SiteProcess]:
    if tunbridge.unshare.parent(guest) is not host:
        raise ValueError("pasta guest must be a namespace under host site")

    # This implies guest is a namespace site
    assert isinstance(guest, tunbridge.unshare.NsenterSite)

    exe = os.environ['PASTA']

    with host.tempdir() as piddir:
        pidfile = os.path.join(piddir, 'pasta.pid')
        cmd = [exe, '-f', '-P', pidfile] + list(opts) + [f'{guest.pid}']
        with host.bg(*cmd, stop=True) as pasta:
            # Wait for the PID file to be written
            pidstr = None
            while not pidstr:
                pidstr = host.readfile(pidfile, check=False)
            pid = int(pidstr)
            print(f'pasta started, host: {host}, guest: {guest}, pid: {pid}')
            yield pasta
debug log:

solving 91f59036 ...
found 91f59036 in https://archives.passt.top/passt-dev/20251002075708.461931-4-david@gibson.dropbear.id.au/

applying [1/1] https://archives.passt.top/passt-dev/20251002075708.461931-4-david@gibson.dropbear.id.au/
diff --git a/test/tasst/pasta.py b/test/tasst/pasta.py
new file mode 100644
index 00000000..91f59036

Checking patch test/tasst/pasta.py...
Applied patch test/tasst/pasta.py cleanly.

index at:
100644 91f59036421cec3e8e030da6d3da0f3505f48646	test/tasst/pasta.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).