main.rs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. use clap::{command, ColorChoice, Parser};
  2. use crown::kernel::boot;
  3. use crown::kernel::boot::Cli as BootCli;
  4. use crown::noun::slab::NounSlab;
  5. use sword::noun::D;
  6. use sword_macros::tas;
  7. use tracing::debug;
  8. static KERNEL_JAM: &[u8] = include_bytes!(concat!(
  9. env!("CARGO_MANIFEST_DIR"),
  10. "/bootstrap/test-ker.jam"
  11. ));
  12. #[derive(Parser, Debug)]
  13. #[command(about = "Tests various poke types for the kernel", author = "zorp", version, color = ColorChoice::Auto)]
  14. struct TestCli {
  15. #[command(flatten)]
  16. boot: BootCli,
  17. #[arg(long, help = "Exit after poke")]
  18. exit: bool,
  19. }
  20. #[tokio::main]
  21. async fn main() -> Result<(), Box<dyn std::error::Error>> {
  22. let cli = TestCli::parse();
  23. debug!("KERNEL_JAM len: {:?}", KERNEL_JAM.to_vec().len());
  24. boot::init_default_tracing(&cli.boot.clone());
  25. let mut test_app = boot::setup(KERNEL_JAM, Some(cli.boot.clone()), &[], "test")?;
  26. let poke = if cli.exit {
  27. D(tas!(b"inc-exit"))
  28. } else {
  29. D(tas!(b"inc"))
  30. };
  31. let mut slab = NounSlab::new();
  32. slab.set_root(poke);
  33. test_app
  34. .add_io_driver(crown::one_punch_driver(
  35. slab,
  36. crown::nockapp::driver::Operation::Poke,
  37. ))
  38. .await;
  39. test_app.add_io_driver(crown::exit_driver()).await;
  40. test_app.run().await.expect("Failed to run app");
  41. Ok(())
  42. }