File: test_beiboot.py

package info (click to toggle)
cockpit 337-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 36,232 kB
  • sloc: javascript: 47,090; python: 38,766; ansic: 35,470; xml: 6,048; sh: 3,413; makefile: 614
file content (28 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (2)
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
import sys

import pytest

from cockpit._vendor import ferny
from cockpit._vendor.bei import bootloader
from cockpit.beipack import BridgeBeibootHelper
from cockpit.peer import Peer
from cockpit.router import Router


class BeibootPeer(Peer):
    async def do_connect_transport(self) -> None:
        helper = BridgeBeibootHelper(self)
        agent = ferny.InteractionAgent([helper])
        transport = await self.spawn([sys.executable, '-iq'], env=[], stderr=agent)
        transport.write(bootloader.make_bootloader(helper.steps, gadgets=ferny.BEIBOOT_GADGETS).encode())
        await agent.communicate()


@pytest.mark.asyncio
async def test_bridge_beiboot():
    # Try to beiboot a copy of the bridge and read its init message
    peer = BeibootPeer(Router([]))
    init_msg = await peer.start()
    assert init_msg['version'] == 1
    assert 'packages' not in init_msg
    peer.close()