File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,6 +102,9 @@ public:
102102 return wasi_config_preopen_dir (ptr.get (), path.c_str (), guest_path.c_str (),
103103 dir_perms, file_perms);
104104 }
105+
106+ // / \brief Returns the underlying C API pointer.
107+ [[nodiscard]] wasi_config_t *capi () { return ptr.get (); }
105108};
106109
107110} // namespace wasmtime
Original file line number Diff line number Diff line change 11#include < gtest/gtest.h>
2+ #include < string_view>
23#include < wasmtime/component.hh>
34#include < wasmtime/store.hh>
45
@@ -20,6 +21,22 @@ TEST(wasip2, smoke) {
2021 auto context = store.context ();
2122
2223 wasmtime::WasiConfig config;
24+
25+ wasi_config_set_stdout_custom (
26+ config.capi (),
27+ [](void *, const unsigned char *buf, size_t len) -> ptrdiff_t {
28+ std::cout << std::string_view{(const char *)(buf), len};
29+ return len;
30+ },
31+ nullptr , nullptr );
32+ wasi_config_set_stderr_custom (
33+ config.capi (),
34+ [](void *, const unsigned char *buf, size_t len) -> ptrdiff_t {
35+ std::cerr << std::string_view{(const char *)(buf), len};
36+ return len;
37+ },
38+ nullptr , nullptr );
39+
2340 context.set_wasi (std::move (config)).unwrap ();
2441 Component component = Component::compile (engine, component_text).unwrap ();
2542
You can’t perform that action at this time.
0 commit comments