Skip to content

Commit 3f08a50

Browse files
committed
test(e2e): 237's green half must not depend on a host C runtime
⚠️ 本机绿 CI 红,方向与平时相反:这次是**本机有** runner 没有的东西。 原来的绿色一半是「加上 `allow_host_libs = true` 必须能构建」。落回宿主需要宿主 真有一份 C 运行时,而 runner 上 `crt1.o` / `crti.o` / `libm` 一个都没有 —— 那半个断言实际在断言运行机器的属性,不是 mcpp 的行为。 换成不依赖机器的对照:**同一个 home、同一批载荷、同一个工程,只给 SubOS 补上 `subos_info` 块**,必须构建成功。这同时更强 —— 它证明第 1 部分里的失败确实只是 降级,而不是这个环境本来就编不出东西。 绑定哪个 glibc 也不能猜:向真实 home 的 `subos_info.runtime` 要,取不到才回落到 目录扫描。装了两个 glibc 载荷的机器上,`ls | head -1` 会按字母序挑中工具链没有 针对它打过补丁的那个,让对照因为与被控变量无关的原因失败。
1 parent bc77d50 commit 3f08a50

1 file changed

Lines changed: 46 additions & 18 deletions

File tree

tests/e2e/237_default_subos_without_info.sh

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,55 @@ if [ "$rc" != 0 ]; then
117117
fi
118118
echo " absence: no fixup error (exit $rc)"
119119

120-
# ── 2. ...and with the host runtime allowed, it must BUILD ─────────────────
121-
# The green half. Without it, part 1 could be satisfied by mcpp failing for
122-
# some accepted reason on every platform, which is not what "the build is
123-
# unaffected" means.
120+
# ── 2. THE CONTROL: describe the same SubOS, change nothing else ───────────
121+
# The green half. Without it, part 1 could be satisfied by mcpp failing for some
122+
# accepted reason on every platform, which is not what "the build is unaffected"
123+
# means. This is also what proves the degradation in part 1 is a degradation and
124+
# not a broken toolchain: same home, same payloads, same project — one JSON
125+
# block is the entire difference.
124126
#
125-
# ⚠️ THIS IS WHAT WAS BROKEN. In the reported sandbox, `allow_host_libs = true`
126-
# did NOT help: the fixup gate fired before the hermeticity policy was ever
127-
# consulted, so the one escape hatch mcpp documents for this exact situation
128-
# was unreachable. Absence must cost hermeticity and nothing else.
129-
cat >> mcpp.toml <<'EOF'
130-
131-
[build]
132-
allow_host_libs = true
133-
EOF
127+
# ⚠️ NOT `allow_host_libs = true`. That was the first version and it FAILED ON
128+
# CI while passing here: falling back to the host needs a host C runtime, and
129+
# the runners have no `crt1.o` / `libm` to fall back TO. The green half must not
130+
# depend on a fact about the machine — binding to the payload glibc does not.
131+
# ⚠️ ASK THE REAL HOME WHICH GLIBC IT USES, do not take the first directory.
132+
# A machine with two glibc payloads installed has one the toolchain was patched
133+
# against and one it was not, and `ls | head -1` picks by alphabetical order —
134+
# which would make this control fail for a reason that has nothing to do with
135+
# what it is controlling for.
136+
GLIBC_DIR="$MCPP_HOME/registry/data/xpkgs/xim-x-glibc"
137+
GLIBC_VER="$(python3 - "$REAL_HOME/registry/subos/default/.xlings.json" <<'PY'
138+
import json, sys
139+
try:
140+
rt = json.load(open(sys.argv[1], encoding="utf-8"))["subos_info"]["runtime"]
141+
print(rt.split("@", 1)[1] if "@" in rt else "")
142+
except Exception:
143+
print("")
144+
PY
145+
)"
146+
[ -n "$GLIBC_VER" ] && [ -d "$GLIBC_DIR/$GLIBC_VER" ] \
147+
|| GLIBC_VER="$(ls "$GLIBC_DIR" 2>/dev/null | head -1)"
148+
[ -n "$GLIBC_VER" ] || { echo "SKIP: no glibc payload to bind to"; exit 0; }
149+
python3 - "$MCPP_HOME/registry/subos/default/.xlings.json" "$GLIBC_VER" <<'PY'
150+
import json, sys
151+
path, ver = sys.argv[1], sys.argv[2]
152+
json.dump({"workspace": {},
153+
"subos_info": {"schema_version": 1, "runtime": "glibc@" + ver,
154+
"host_glibc": ver, "envs": {}}},
155+
open(path, "w", encoding="utf-8"))
156+
PY
134157
rm -rf target
135-
"$MCPP" build > allow.log 2>&1 || {
136-
echo "FAIL: even with allow_host_libs, an undescribed default SubOS blocks"
137-
echo " the build. That is the escape hatch being unreachable."
138-
tail -20 allow.log | sed 's/^/ /'
158+
"$MCPP" build > described.log 2>&1 || {
159+
echo "FAIL: the SAME home builds nothing even once the SubOS describes"
160+
echo " itself (runtime glibc@$GLIBC_VER), so part 1 above proved"
161+
echo " nothing — this environment cannot build either way."
162+
tail -20 described.log | sed 's/^/ /'
139163
exit 1; }
140-
echo " absence + allow_host_libs: builds"
164+
echo " described (glibc@$GLIBC_VER): builds"
165+
166+
# ...and restore the absent state for part 3, so the install path is exercised
167+
# against the condition this test is about.
168+
printf '{"workspace":{}}' > "$MCPP_HOME/registry/subos/default/.xlings.json"
141169

142170
# ── 3. `mcpp toolchain install` survives it too ─────────────────────────────
143171
# The path the fix could most easily have BROKEN: it carries no RuntimeBinding

0 commit comments

Comments
 (0)