Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
openkal-macos 0.15.1 与 openkal-windows 0.13.3,以 `KAL_SPAWN_ONE_STRING` 启动命令解释器的 image 在 okrun
下得到该标志的语义;三个包仍为同一版本、同一归档。openkal-musl 随 openkal-windows 0.13.3 与 openkal-ld 0.1.1
移动,openkal-llvm-runtime 随 openkal-musl 移动。测试成员 `openkal`、`openkal-musl`、`openkal-tools` 随之移动。
- **mcpplibs.os 0.2.0。** mcpp 的操作系统层所承载的内容进入 os:`exec`(本进程成为另一个程序)、
一个管道按写入顺序承载输出与错误输出、追加写与持久化、卷的容量、`place` 与 `exchange`、属主、
处理器数与可用内存、有界读取输入、发往错误流的输出、保留中断的原始模式,以及 Windows 的事实。
基于 openkal 0.17.1(openkal-linux 0.18.2、openkal-macos 0.15.1、openkal-windows 0.13.3);ok image
形态基于 openkal-llvm-runtime 0.16.3 与 openkal-tools 0.1.1。测试成员 `os` 移到 0.2.0,并观察两个输出
经一个管道按序到达。

### Changed

Expand Down
12 changes: 12 additions & 0 deletions pkgs/o/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ package = {

xpm = {
linux = {
["0.2.0"] = {
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz",
sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e",
},
["0.1.2"] = {
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz",
sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34",
Expand All @@ -43,6 +47,10 @@ package = {
},
},
macosx = {
["0.2.0"] = {
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz",
sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e",
},
["0.1.2"] = {
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz",
sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34",
Expand All @@ -60,6 +68,10 @@ package = {
},
},
windows = {
["0.2.0"] = {
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz",
sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e",
},
["0.1.2"] = {
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz",
sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34",
Expand Down
5 changes: 3 additions & 2 deletions tests/examples/os/mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# mcpplibs.os test project: the library over this system's openkal
# implementation, on every runner --- a program started and read, a file
# published, a list of directories split, and the platform the build is for.
# published, a list of directories split, the platform the build is for, and a
# program's two outputs on one pipe.
[package]
name = "os-tests"
version = "0.1.0"

[dependencies.mcpplibs]
os = "0.1.2"
os = "0.2.0"

[indices]
mcpplibs = { path = "../../.." }
19 changes: 19 additions & 0 deletions tests/examples/os/tests/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ int main(int argc, char** argv) {
(void)os::stdio::write_output("echoed");
return 0;
}
if (argc > 1 && std::string_view(argv[1]) == "--both") {
(void)os::stdio::write_output("out ");
(void)os::stdio::write_error("err");
return 0;
}
int failures = 0;
auto check = [&](bool ok, std::string_view what) { if (!ok) { ++failures; std::println(std::cerr, "FAIL: {}", what); } };

Expand Down Expand Up @@ -39,6 +44,20 @@ int main(int argc, char** argv) {
o.args.push_back("--echo");
auto r = os::process::run(o);
check(r && r->status.success() && r->out == "echoed", "a started program's output is read");

// 0.2.0: one pipe carries the output and the error output in the order written.
o.args.back() = "--both";
o.out = os::process::stdio::pipe;
o.err = os::process::stdio::output;
std::string merged;
auto p = os::process::process::spawn(o);
if (p) {
for (;;) { auto c = p->read_output(); if (!c || c->empty()) break; merged += *c; }
auto st = p->wait();
check(st && st->success() && merged == "out err", "both outputs arrive on one pipe in order");
} else {
check(false, "a program with both outputs on one pipe starts");
}
}
// 0.1.2: a symbol of the program resolves as the loader resolves it.
if (os::library::supported())
Expand Down
Loading