Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
nspin committed Mar 20, 2024
1 parent 938fb57 commit c6e634d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
10 changes: 5 additions & 5 deletions crates/examples/root-task/serial-device/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ fn main(bootinfo: &sel4::BootInfoPtr) -> sel4::Result<Never> {

irq_notification_cap.wait();

let c = serial_device.get_char().unwrap();

serial_device.put_char(b'[');
serial_device.put_char(c);
serial_device.put_char(b']');
while let Some(c) = serial_device.get_char() {
serial_device.put_char(b'[');
serial_device.put_char(c);
serial_device.put_char(b']');
}
}
}

Expand Down
16 changes: 14 additions & 2 deletions hacking/nix/scope/world/instances/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,27 @@ in rec {
};
});

serial-device = maybe (haveFullRuntime && hostPlatform.isAarch) (mkInstance {
serial-device = maybe (haveFullRuntime && hostPlatform.isAarch) (lib.fix (self: mkInstance {
rootTask = mkTask {
rootCrate = crates.serial-device;
release = false;
};
extraPlatformArgs = lib.optionalAttrs canSimulate {
canAutomateSimply = true;
};
});
} // lib.optionalAttrs canSimulate rec {
automate =
let
py = buildPackages.python3.withPackages (pkgs: [
pkgs.pexpect
]);
in
writeScript "automate" ''
#!${buildPackages.runtimeShell}
set -eu
${py}/bin/python3 ${./test-automation-scripts/serial-device.py} ${self.simulate}
'';
}));

spawn-thread = maybe haveFullRuntime (mkInstance {
rootTask = mkTask {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright 2023, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#

import sys
import time
import argparse
import pexpect

def main():
parser = argparse.ArgumentParser()
parser.add_argument('simulate')
args = parser.parse_args()
run(args)

def run(args):
child = pexpect.spawn(args.simulate, encoding='utf-8')
child.logfile = sys.stdout
child.expect('echo> ', timeout=10)
time.sleep(5)
child.sendline('xxx')
child.expect('[x][x][x]', timeout=10)
print()

if __name__ == '__main__':
main()

0 comments on commit c6e634d

Please sign in to comment.