test(chv-guest): 构建脚本测试夹具跟进 B-09 新契约
- 假 codex 二进制须报出版本号(codex --version 核对) - 假仓库改为真 git 仓库,REPO_COMMIT 取其实测短 hash (旧 test123 非 hex,B-03 格式校验本应拒绝) - 干跑行补 BUILDINFO.json 字样(断言依赖) 另:79ba56b(并行轨)已把 Playwright 改默认开启、单次 virt-customize、补 fonts-noto-cjk,本提交只补测试与干跑 文案,不动构建逻辑
This commit is contained in:
1 parent
79ba56bd51
commit
3b41f864e8
3 files changed
+45
-6
No files matched your search
+1
-1
@@ -201,7 +201,7 @@ fi
|
|||||||
# 产物校验(干跑只打印,不执行校验命令的副作用部分)。
|
# 产物校验(干跑只打印,不执行校验命令的副作用部分)。
|
||||||
if [ "$DRY_RUN" = "1" ]; then
|
if [ "$DRY_RUN" = "1" ]; then
|
||||||
echo "DRY-RUN: test -s $OUT/vmlinux && test -s $OUT/disk.raw"
|
echo "DRY-RUN: test -s $OUT/vmlinux && test -s $OUT/disk.raw"
|
||||||
echo "DRY-RUN: python3 $SCRIPT_DIR/buildinfo.py $OUT $TAG $UBUNTU_VERSION $CODEX_VERSION $REPO_COMMIT <sha256> ${PLAYWRIGHT:-1}"
|
echo "DRY-RUN: python3 $SCRIPT_DIR/buildinfo.py $OUT $TAG $UBUNTU_VERSION $CODEX_VERSION $REPO_COMMIT <sha256> ${PLAYWRIGHT:-1} # 生成 $OUT/BUILDINFO.json 并校验 tag=$TAG"
|
||||||
else
|
else
|
||||||
test -s "$OUT/vmlinux" || { echo "内核产物为空:$OUT/vmlinux" >&2; exit 1; }
|
test -s "$OUT/vmlinux" || { echo "内核产物为空:$OUT/vmlinux" >&2; exit 1; }
|
||||||
test -s "$OUT/disk.raw" || { echo "磁盘产物为空:$OUT/disk.raw" >&2; exit 1; }
|
test -s "$OUT/disk.raw" || { echo "磁盘产物为空:$OUT/disk.raw" >&2; exit 1; }
|
||||||
|
|||||||
@@ -376,12 +376,31 @@ class BuildScriptTest(unittest.TestCase):
|
|||||||
for name in ("codex", "codex-code-mode-host"):
|
for name in ("codex", "codex-code-mode-host"):
|
||||||
p = os.path.join(self.bin_dir, name)
|
p = os.path.join(self.bin_dir, name)
|
||||||
with open(p, "w") as fh:
|
with open(p, "w") as fh:
|
||||||
fh.write("#!/bin/sh\n")
|
# B-09:build.sh 会核对 codex --version 含 CODEX_VERSION,
|
||||||
|
# 假二进制须报出真实版本号。
|
||||||
|
fh.write("#!/bin/sh\necho \"codex-cli 0.164.0-alpha.9\"\n")
|
||||||
os.chmod(p, 0o755)
|
os.chmod(p, 0o755)
|
||||||
self.repo = os.path.join(self.dir, "repo")
|
self.repo = os.path.join(self.dir, "repo")
|
||||||
os.makedirs(os.path.join(self.repo, "cloud"))
|
os.makedirs(os.path.join(self.repo, "cloud"))
|
||||||
with open(os.path.join(self.repo, "host.py"), "w") as fh:
|
with open(os.path.join(self.repo, "host.py"), "w") as fh:
|
||||||
fh.write("# host\n")
|
fh.write("# host\n")
|
||||||
|
# B-09:REPO_COMMIT 须等于仓库 HEAD 短 hash 且工作树干净,
|
||||||
|
# 假仓库须是真 git 仓库。
|
||||||
|
subprocess.run(["git", "init", "-q", self.repo],
|
||||||
|
check=True, capture_output=True)
|
||||||
|
subprocess.run(["git", "-C", self.repo, "config",
|
||||||
|
"user.email", "t@t"], check=True,
|
||||||
|
capture_output=True)
|
||||||
|
subprocess.run(["git", "-C", self.repo, "config",
|
||||||
|
"user.name", "t"], check=True,
|
||||||
|
capture_output=True)
|
||||||
|
subprocess.run(["git", "-C", self.repo, "add", "-A"],
|
||||||
|
check=True, capture_output=True)
|
||||||
|
subprocess.run(["git", "-C", self.repo, "commit", "-qm",
|
||||||
|
"init"], check=True, capture_output=True)
|
||||||
|
self.repo_commit = subprocess.run(
|
||||||
|
["git", "-C", self.repo, "rev-parse", "--short", "HEAD"],
|
||||||
|
check=True, capture_output=True, text=True).stdout.strip()
|
||||||
self.script = str(Path(__file__).resolve().parents[2]
|
self.script = str(Path(__file__).resolve().parents[2]
|
||||||
/ "chv-guest" / "build.sh")
|
/ "chv-guest" / "build.sh")
|
||||||
|
|
||||||
@@ -393,7 +412,7 @@ class BuildScriptTest(unittest.TestCase):
|
|||||||
env.update({"CODEX_BIN_DIR": self.bin_dir,
|
env.update({"CODEX_BIN_DIR": self.bin_dir,
|
||||||
"UBUNTU_VERSION": "24.04",
|
"UBUNTU_VERSION": "24.04",
|
||||||
"CODEX_VERSION": "0.164.0-alpha.9",
|
"CODEX_VERSION": "0.164.0-alpha.9",
|
||||||
"REPO_COMMIT": "test123",
|
"REPO_COMMIT": self.repo_commit,
|
||||||
# feat-chv-secfix(M4):SHA256 必填,
|
# feat-chv-secfix(M4):SHA256 必填,
|
||||||
# 干跑只验“已设”,用 FAKE 占位。
|
# 干跑只验“已设”,用 FAKE 占位。
|
||||||
"UBUNTU_IMAGE_SHA256": "0" * 64,
|
"UBUNTU_IMAGE_SHA256": "0" * 64,
|
||||||
@@ -411,7 +430,8 @@ class BuildScriptTest(unittest.TestCase):
|
|||||||
self.assertIn("virt-customize", r.stdout)
|
self.assertIn("virt-customize", r.stdout)
|
||||||
self.assertIn("virt-get-kernel", r.stdout)
|
self.assertIn("virt-get-kernel", r.stdout)
|
||||||
self.assertIn("BUILDINFO", r.stdout)
|
self.assertIn("BUILDINFO", r.stdout)
|
||||||
self.assertIn("chv-guest-24.04-0.164.0-alpha.9-test123", r.stdout)
|
self.assertIn("chv-guest-24.04-0.164.0-alpha.9-%s"
|
||||||
|
% self.repo_commit, r.stdout)
|
||||||
self.assertFalse(os.path.exists(os.path.join(out_dir, "disk.raw")))
|
self.assertFalse(os.path.exists(os.path.join(out_dir, "disk.raw")))
|
||||||
|
|
||||||
def test_full_mode_without_kvm_fails_fast(self):
|
def test_full_mode_without_kvm_fails_fast(self):
|
||||||
|
|||||||
@@ -529,12 +529,31 @@ class BuildScriptTest(unittest.TestCase):
|
|||||||
for name in ("codex", "codex-code-mode-host"):
|
for name in ("codex", "codex-code-mode-host"):
|
||||||
p = os.path.join(self.bin_dir, name)
|
p = os.path.join(self.bin_dir, name)
|
||||||
with open(p, "w") as fh:
|
with open(p, "w") as fh:
|
||||||
fh.write("#!/bin/sh\n")
|
# B-09:build.sh 会核对 codex --version 含 CODEX_VERSION,
|
||||||
|
# 假二进制须报出真实版本号。
|
||||||
|
fh.write("#!/bin/sh\necho \"codex-cli 0.164.0-alpha.9\"\n")
|
||||||
os.chmod(p, 0o755)
|
os.chmod(p, 0o755)
|
||||||
self.repo = os.path.join(self.dir, "repo")
|
self.repo = os.path.join(self.dir, "repo")
|
||||||
os.makedirs(os.path.join(self.repo, "cloud"))
|
os.makedirs(os.path.join(self.repo, "cloud"))
|
||||||
with open(os.path.join(self.repo, "host.py"), "w") as fh:
|
with open(os.path.join(self.repo, "host.py"), "w") as fh:
|
||||||
fh.write("# host\n")
|
fh.write("# host\n")
|
||||||
|
# B-09:REPO_COMMIT 须等于仓库 HEAD 短 hash 且工作树干净,
|
||||||
|
# 假仓库须是真 git 仓库。
|
||||||
|
subprocess.run(["git", "init", "-q", self.repo],
|
||||||
|
check=True, capture_output=True)
|
||||||
|
subprocess.run(["git", "-C", self.repo, "config",
|
||||||
|
"user.email", "t@t"], check=True,
|
||||||
|
capture_output=True)
|
||||||
|
subprocess.run(["git", "-C", self.repo, "config",
|
||||||
|
"user.name", "t"], check=True,
|
||||||
|
capture_output=True)
|
||||||
|
subprocess.run(["git", "-C", self.repo, "add", "-A"],
|
||||||
|
check=True, capture_output=True)
|
||||||
|
subprocess.run(["git", "-C", self.repo, "commit", "-qm",
|
||||||
|
"init"], check=True, capture_output=True)
|
||||||
|
self.repo_commit = subprocess.run(
|
||||||
|
["git", "-C", self.repo, "rev-parse", "--short", "HEAD"],
|
||||||
|
check=True, capture_output=True, text=True).stdout.strip()
|
||||||
self.script = str(Path(__file__).resolve().parents[2]
|
self.script = str(Path(__file__).resolve().parents[2]
|
||||||
/ "chv-guest" / "build.sh")
|
/ "chv-guest" / "build.sh")
|
||||||
|
|
||||||
@@ -546,7 +565,7 @@ class BuildScriptTest(unittest.TestCase):
|
|||||||
env.update({"CODEX_BIN_DIR": self.bin_dir,
|
env.update({"CODEX_BIN_DIR": self.bin_dir,
|
||||||
"UBUNTU_VERSION": "24.04",
|
"UBUNTU_VERSION": "24.04",
|
||||||
"CODEX_VERSION": "0.164.0-alpha.9",
|
"CODEX_VERSION": "0.164.0-alpha.9",
|
||||||
"REPO_COMMIT": "test123",
|
"REPO_COMMIT": self.repo_commit,
|
||||||
"REPO_DIR": self.repo})
|
"REPO_DIR": self.repo})
|
||||||
if env_extra:
|
if env_extra:
|
||||||
env.update(env_extra)
|
env.update(env_extra)
|
||||||
|
|||||||
Reference in new issue
Block a user