abitest: test direct message to log channel
Also include some associated handles which should be silently
dropped.
@@ -29,6 +29,8 @@ use rand::Rng;
use std::collections::HashMap;
use std::io::Write;
+const LOG_PORT_NAME: &str = "logging_port";
+
const BACKEND_COUNT: usize = 3;
struct FrontendNode {
grpc_in: oak::ReadHandle,
@@ -56,7 +58,7 @@ impl oak::grpc::OakNode for FrontendNode {
let _ = oak_log::init(
log::Level::Debug,
oak::WriteHandle {
- handle: oak::channel_find("logging_port"),
+ handle: oak::channel_find(LOG_PORT_NAME),
},
);
FrontendNode {
@@ -133,6 +135,7 @@ impl OakABITestServiceNode for FrontendNode {
"ChannelHandleReuse",
FrontendNode::test_channel_handle_reuse,
);
+ tests.insert("DirectLog", FrontendNode::test_direct_log);
tests.insert("BackendRoundtrip", FrontendNode::test_backend_roundtrip);
for (&name, &testfn) in &tests {
@@ -845,6 +848,26 @@ impl FrontendNode {
Ok(())
}
+ fn test_direct_log(&self) -> std::io::Result<()> {
+ // Send a message directly to the logging channel (not via the log facade).
+ // Include some handles which will be ignored.
+ let logging_handle = oak::WriteHandle {
+ handle: oak::channel_find(LOG_PORT_NAME),
+ };
+ expect!(logging_handle.handle != oak::wasm::INVALID_HANDLE);
+ let (out_handle, in_handle) = oak::channel_create().unwrap();
+
+ oak::channel_write(
+ logging_handle,
+ "message sent direct to logging channel".as_bytes(),
+ &[in_handle.handle, out_handle.handle],
+ );
+
+ expect_eq!(OakStatus::OK, oak::channel_close(out_handle.handle));
+ expect_eq!(OakStatus::OK, oak::channel_close(in_handle.handle));
+ Ok(())
+ }
+
fn test_backend_roundtrip(&self) -> std::io::Result<()> {
// Make a collection of new channels for the backend nodes to read from,
// and send the read handles to each backend node.
