Exemple #1
0
class SerialConnection:
    def __init__(self, executable, args):
        if get_global_config().pretend:
            self.cheribsd = FakeSerialSpawn(executable, args)
        else:
            print_command([executable, *args])
            self.cheribsd = CheriBSDInstance(
                CompilationTargets.CHERIBSD_RISCV_HYBRID,
                executable,
                args,
                logfile=sys.stdout,
                encoding="utf-8",
                timeout=60)
        assert isinstance(self.cheribsd, CheriBSDSpawnMixin)

    def interact(self):
        # interact() prints all input+output -> disable logfile
        self.cheribsd.logfile = None
        self.cheribsd.logfile_read = None
        self.cheribsd.logfile_send = None
        self.show_help_message()
        self.cheribsd.interact()

    @abstractmethod
    def show_help_message(self):
        ...
 def __init__(self, executable, args):
     if get_global_config().pretend:
         self.cheribsd = FakeSerialSpawn(executable, args)
     else:
         print_command([executable, *args])
         self.cheribsd = CheriBSDInstance(CompilationTargets.CHERIBSD_RISCV_HYBRID, executable, args,
                                          logfile=sys.stdout, encoding="utf-8", timeout=60)
     assert isinstance(self.cheribsd, CheriBSDSpawnMixin)
def get_board_ip_address(console: boot_cheribsd.CheriBSDInstance, args):
    assert not args.use_qemu_instead_of_fpga
    ifc = get_network_iface(args)
    console.sendline('ifconfig {}'.format(ifc))
    idx = console.expect([
        re.compile("inet (.+) netmask "),
        # error cases:
        pexpect.TIMEOUT, "interface " + ifc + " does not exist"], timeout=10)
    if idx == 0:
        print(console.match)
        return console.match.group(1)
    console.expect_prompt()
def do_network_off(console: boot_cheribsd.CheriBSDInstance, args):
    ifc = get_network_iface(args)
    console.run('/sbin/ifconfig {} down'.format(ifc))
    #    console.run('killall dhclient')
    # Note: If we devctl disable le0, we can't enable it anymore
    if not args.use_qemu_instead_of_fpga:
        console.sendline('/usr/sbin/devctl disable {}'.format(ifc))
        console.expect(['{}: detached'.format(ifc),
                        "Failed to disable {}: Device not configured".format(ifc)
                        ])
Exemple #5
0
 def default_setup_tests(qemu: boot_cheribsd.CheriBSDInstance, args: argparse.Namespace):
     # Also link the build directory in the target under the host path. This should allow more tests to pass,
     # i.e. the libc++ filesystem tests, etc.
     if should_mount_builddir:
         assert args.build_dir
         # the host path might be too long and trigger the shell to emit a continuation line which really confuses
         # the pexpect logic.
         qemu.run("mkdir -p '{}'".format(Path(args.build_dir).parent))
         qemu.checked_run("ln -sf /build '{}'".format(args.build_dir), timeout=60)
         boot_cheribsd.success("Mounted build directory using host path")
     if should_mount_srcdir:
         assert args.source_dir
         # the host path might be too long and trigger the shell to emit a continuation line which really confuses
         # the pexpect logic.
         qemu.run("mkdir -p '{}'".format(Path(args.source_dir).parent))
         qemu.checked_run("ln -sf /source '{}'".format(args.source_dir), timeout=60)
         boot_cheribsd.success("Mounted source directory using host path")
     # Finally call the custom test setup function
     if test_setup_function:
         test_setup_function(qemu, args)
def do_runbench(console: boot_cheribsd.CheriBSDInstance, tgtdir, script, scriptargs,
                failstr="FAILED RUNNING BENCHMARKS", timeout=None, pre_cmd=None, *, args):
    if timeout is None:
        timeout = args.timeout

    badcmd = "/this/command/does/not/exist"
    runbenchcmd = './{} {} || {}'.format(script, scriptargs, badcmd)
    console.sendline()
    console.expect_prompt()
    console.run('cd {} && ls -la'.format(tgtdir))
    if args.lazy_binding:
        console.run('unset LD_CHERI_BIND_NOW')
        console.run('unset LD_BIND_NOW')
    else:
        # Ensure that we don't use lazy binding for CheriABI since MIPS doesn't support it
        # This can skew the results since we have faster startup on CHERI but slower runtime
        # due to trampolines
        console.run('export LD_CHERI_BIND_NOW=1')
        console.run('export LD_BIND_NOW=1')

    if pre_cmd:
        console.run(pre_cmd)
    # Log the current environment:
    console.run("env")
    console.sendline(runbenchcmd)
    panicstr = "KDB: enter: "

    expects = ["DONE RUNNING BENCHMARKS", ": Command not found.", badcmd + ": not found", failstr, panicstr]
    idx = console.expect(expects, timeout=timeout)
    if idx != 0:
        print("Failed to run benchmark")
    if expects[idx] == panicstr:
        print("Panic!  Extracting backtrace...")
        console.sendline("bt")
def do_network_on(console: boot_cheribsd.CheriBSDInstance, args, timeout=300):
    ifc = get_network_iface(args)
    # Note: If we devctl disable le0, we can't enable it anymore
    if not args.use_qemu_instead_of_fpga:
        console.run('/usr/sbin/devctl enable {}'.format(ifc),
                    expected_output='{}: bpf attached'.format(ifc))
    console.run('/sbin/ifconfig {} up'.format(ifc))
    if ifc != "le0":
        # apparently the le0 driver doesn't print this message
        console.expect_exact(['{}: link state changed to UP'.format(ifc)])
    # Send a newline to ensure a prompt:
    console.sendline()
    console.expect_prompt()
    # No longer needed? console.run('/sbin/ifconfig {} polling'.format(ifc))
    console.sendline('/sbin/dhclient {}'.format(ifc))
    console.expect(["bound to .* -- renewal in .*\\."], timeout=timeout)
    console.expect_prompt()