Skip to content

Commit b2d159a

Browse files
committed
test: a case that asserts a replay holds the machine (extensions 218); the lifetime helper waits for a killed controller's lock
1 parent 0a19eff commit b2d159a

3 files changed

Lines changed: 64 additions & 49 deletions

File tree

‎.agents/docs/2026-11-14-ci-and-release-time-cost-design.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,7 @@ openkal-macos 仅在其为空时提供自己的存根,旧版 mcpp 不设该变
209209
| 归档的运行在任何腿运行前要求全部所列程序,另一台机器运行的腿也被要求 | 在腿确定于本机运行后才向环境要求该腿的程序 |
210210
| e2e-cases 以 MSYS 形式导出 `MCPP_BIN_MCPP` | 与 mcpp-unit 相同,以 `cygpath -w` 给出系统自身的拼写 |
211211
| MSVC ABI 的 clang 也运行 libc++ 探测,可能记下不相干的“未回答” | 不对 MSVC ABI 的驱动提出该问题,其 std 模块按 STL 查找 |
212+
213+
**第四次运行(43576630955,含 bench)。** 另有两处与本 PR 改动无关、由负载暴露的用例缺陷:modules/extensions 218 断言无改动的构建被重放,
214+
却不持有 machine(与 1024 同类,移入 extensions-machine 套件);DetachLifetime 的辅助脚本在杀死控制进程后固定等待 0.15 s 再要求其锁,
215+
负载下内核结束该进程晚于此,改为在时限内等到锁被释放。

‎tests/e2e/helpers/check_owned_schedule_lifetime.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,15 @@ def admitted():
305305
controller=int(unit[1]);os.kill(controller,signal.SIGKILL)
306306
reservation=Path(record(attempt/"reservation","mcpp-reservation-pointer-v1")[0])
307307
lock=reservation.with_suffix(".lock")
308-
time.sleep(.15)
308+
# The killed controller's lock is released when the kernel has ended
309+
# it, which a loaded machine does later than a fixed pause.
309310
with lock.open("a+") as handle:
310-
fcntl.lockf(handle,fcntl.LOCK_EX|fcntl.LOCK_NB)
311+
def taken():
312+
try:
313+
fcntl.lockf(handle,fcntl.LOCK_EX|fcntl.LOCK_NB);return True
314+
except BlockingIOError:
315+
return False
316+
until(taken,"the killed controller's reservation lock was not released")
311317
assert alive(writer),"descendant control ended too early"
312318
assert reservation.exists(),"live descendant lost its logical reservation"
313319
obj=case.out/("ordinary.o" if kind=="ordinary" else "module.o")

‎tests/e2e/modules/extensions.cpp‎

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -108,53 +108,6 @@ E2E extensions{"extensions", [] {
108108
std::println(" skip: no LLVM payload installed — clang leg not run");
109109
};
110110

111-
"218 module extensions graph shape"_test[s::gcc] = [] {
112-
// A no-change build replays; a new import in a .ixx plans again and the edge is real;
113-
// module_extensions changes the graph in the same directory; a dead entry is reported; a
114-
// reserved extension is refused naming the key.
115-
s::project p({{"mcpp.toml", "[package]\nname = \"gshape\"\nversion = \"0.1.0\"\n\n[build]\nmodule_extensions = [\".ixx\"]\n"},
116-
{"src/helper.cppm", "export module gshape.helper;\nimport std;\nexport auto helper() -> int { return 41; }\n"},
117-
{"src/face.ixx", "export module gshape.face;\nimport std;\nexport auto face() -> int { return 1; }\n"},
118-
{"src/main.cpp", "import std;\nimport gshape.face;\nint main(){ std::println(\"{}\", face()); }\n"}});
119-
auto r = p.mcpp({"build"});
120-
expect(fatal(e2e::succeeded(r))) << "first build\n" << s::text(r);
121-
const auto fp_before = printed(p, "Fingerprint");
122-
expect(fatal(!fp_before.empty())) << "could not read the fingerprint";
123-
auto mark = mark_then_wait();
124-
r = p.mcpp({"build"});
125-
expect(fatal(e2e::succeeded(r))) << "no-change build\n" << s::text(r);
126-
expect(fatal(!planned_since(p, mark))) << "fast path did not engage — the rest proves nothing\n" << s::text(r);
127-
128-
mark = mark_then_wait();
129-
p.write("src/face.ixx", "export module gshape.face;\nimport std;\nimport gshape.helper;\nexport auto face() -> int { return helper() + 1; }\n");
130-
r = p.mcpp({"build"});
131-
expect(fatal(e2e::succeeded(r))) << "build after .ixx edit\n" << s::text(r);
132-
expect(fatal(planned_since(p, mark))) << "editing a .ixx did not invalidate the fast path\n" << s::text(r);
133-
expect(fatal(e2e::contains(s::text(p.mcpp({"run"})), "42"))) << "expected 42 (41+1)";
134-
135-
p.write("src/extra.ccm", "export module gshape.extra;\nexport auto extra() -> int { return 2; }\n");
136-
p.write("mcpp.toml", "[package]\nname = \"gshape\"\nversion = \"0.1.0\"\n\n[build]\nmodule_extensions = [\".ixx\", \".ccm\"]\n");
137-
r = p.mcpp({"build"});
138-
expect(fatal(e2e::succeeded(r))) << "build after key change\n" << s::text(r);
139-
const auto fp_after = printed(p, "Fingerprint");
140-
expect(fatal(fp_before == fp_after)) << "module_extensions moved the build directory (" << fp_before << " -> " << fp_after << ")";
141-
// The build directory is named by the configuration's lineage (`Lineage:`), not by the
142-
// whole fingerprint (2026.11.13.1).
143-
const auto lineage = printed(p, "Lineage");
144-
const auto graphs = s::glob(p.at("target"), std::format("*/{}/build.ninja", lineage));
145-
expect(fatal(!graphs.empty() && e2e::matches(s::read_file(graphs.front()), R"(gshape\.extra)")))
146-
<< "the .ccm named by module_extensions is not a module interface of the graph (lineage " << lineage << ")";
147-
148-
p.write("mcpp.toml", "[package]\nname = \"gshape\"\nversion = \"0.1.0\"\n\n[build]\nmodule_extensions = [\".ixx\", \".nosuchext\"]\n");
149-
r = p.mcpp({"build"});
150-
expect(fatal(e2e::succeeded(r))) << "build with a dead entry\n" << s::text(r);
151-
expect(fatal(e2e::contains(s::text(r), "nosuchext"))) << "a module_extensions entry matching nothing was not reported\n" << s::text(r);
152-
p.write("mcpp.toml", "[package]\nname = \"gshape\"\nversion = \"0.1.0\"\n\n[build]\nmodule_extensions = [\".c\"]\n");
153-
r = p.mcpp({"build"});
154-
expect(fatal(failed(r))) << "[build] module_extensions = [\".c\"] was accepted";
155-
expect(fatal(e2e::contains(s::text(r), "module_extensions"))) << "the error does not name the offending key\n" << s::text(r);
156-
};
157-
158111
"236 module extensions default toolchain"_test = [] {
159112
// On this platform's default toolchain a declared .ixx is a module interface: its BMI is
160113
// written and the program runs.
@@ -237,3 +190,55 @@ module_extensions = [".ixx"]
237190
}};
238191

239192
} // namespace
193+
194+
// The cases that hold the machine (P7.1): a suite of their own, which the runner runs with no
195+
// other test beside it. 218 asserts a replay: an install into the shared home by a program beside
196+
// it changes the runtime's description, and the build then plans again (design 2026-11-14 §5.2 E).
197+
E2E extensions_machine{"extensions-machine", resource{"machine"}, [] {
198+
"218 module extensions graph shape"_test[s::gcc] = [] {
199+
// A no-change build replays; a new import in a .ixx plans again and the edge is real;
200+
// module_extensions changes the graph in the same directory; a dead entry is reported; a
201+
// reserved extension is refused naming the key.
202+
s::project p({{"mcpp.toml", "[package]\nname = \"gshape\"\nversion = \"0.1.0\"\n\n[build]\nmodule_extensions = [\".ixx\"]\n"},
203+
{"src/helper.cppm", "export module gshape.helper;\nimport std;\nexport auto helper() -> int { return 41; }\n"},
204+
{"src/face.ixx", "export module gshape.face;\nimport std;\nexport auto face() -> int { return 1; }\n"},
205+
{"src/main.cpp", "import std;\nimport gshape.face;\nint main(){ std::println(\"{}\", face()); }\n"}});
206+
auto r = p.mcpp({"build"});
207+
expect(fatal(e2e::succeeded(r))) << "first build\n" << s::text(r);
208+
const auto fp_before = printed(p, "Fingerprint");
209+
expect(fatal(!fp_before.empty())) << "could not read the fingerprint";
210+
auto mark = mark_then_wait();
211+
r = p.mcpp({"build"});
212+
expect(fatal(e2e::succeeded(r))) << "no-change build\n" << s::text(r);
213+
expect(fatal(!planned_since(p, mark))) << "fast path did not engage — the rest proves nothing\n" << s::text(r);
214+
215+
mark = mark_then_wait();
216+
p.write("src/face.ixx", "export module gshape.face;\nimport std;\nimport gshape.helper;\nexport auto face() -> int { return helper() + 1; }\n");
217+
r = p.mcpp({"build"});
218+
expect(fatal(e2e::succeeded(r))) << "build after .ixx edit\n" << s::text(r);
219+
expect(fatal(planned_since(p, mark))) << "editing a .ixx did not invalidate the fast path\n" << s::text(r);
220+
expect(fatal(e2e::contains(s::text(p.mcpp({"run"})), "42"))) << "expected 42 (41+1)";
221+
222+
p.write("src/extra.ccm", "export module gshape.extra;\nexport auto extra() -> int { return 2; }\n");
223+
p.write("mcpp.toml", "[package]\nname = \"gshape\"\nversion = \"0.1.0\"\n\n[build]\nmodule_extensions = [\".ixx\", \".ccm\"]\n");
224+
r = p.mcpp({"build"});
225+
expect(fatal(e2e::succeeded(r))) << "build after key change\n" << s::text(r);
226+
const auto fp_after = printed(p, "Fingerprint");
227+
expect(fatal(fp_before == fp_after)) << "module_extensions moved the build directory (" << fp_before << " -> " << fp_after << ")";
228+
// The build directory is named by the configuration's lineage (`Lineage:`), not by the
229+
// whole fingerprint (2026.11.13.1).
230+
const auto lineage = printed(p, "Lineage");
231+
const auto graphs = s::glob(p.at("target"), std::format("*/{}/build.ninja", lineage));
232+
expect(fatal(!graphs.empty() && e2e::matches(s::read_file(graphs.front()), R"(gshape\.extra)")))
233+
<< "the .ccm named by module_extensions is not a module interface of the graph (lineage " << lineage << ")";
234+
235+
p.write("mcpp.toml", "[package]\nname = \"gshape\"\nversion = \"0.1.0\"\n\n[build]\nmodule_extensions = [\".ixx\", \".nosuchext\"]\n");
236+
r = p.mcpp({"build"});
237+
expect(fatal(e2e::succeeded(r))) << "build with a dead entry\n" << s::text(r);
238+
expect(fatal(e2e::contains(s::text(r), "nosuchext"))) << "a module_extensions entry matching nothing was not reported\n" << s::text(r);
239+
p.write("mcpp.toml", "[package]\nname = \"gshape\"\nversion = \"0.1.0\"\n\n[build]\nmodule_extensions = [\".c\"]\n");
240+
r = p.mcpp({"build"});
241+
expect(fatal(failed(r))) << "[build] module_extensions = [\".c\"] was accepted";
242+
expect(fatal(e2e::contains(s::text(r), "module_extensions"))) << "the error does not name the offending key\n" << s::text(r);
243+
};
244+
}};

0 commit comments

Comments
 (0)