Skip to content

test(cpu-image-test): raster + vector (SVG) image carpet - #1870

Open
Lfan-ke wants to merge 1 commit into
rcore-os:devfrom
Lfan-ke:apps-starry-cpu-image-test
Open

test(cpu-image-test): raster + vector (SVG) image carpet#1870
Lfan-ke wants to merge 1 commit into
rcore-os:devfrom
Lfan-ke:apps-starry-cpu-image-test

Conversation

@Lfan-ke

@Lfan-ke Lfan-ke commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

概述

apps/starry/cpu-image-test:图形 carpet(C 侧纯 CPU),覆盖位图(raster)+ 矢量(SVG)。每断言都是逐像素 byte-exact / PSNR 界 / 闭式对 golden 硬断言,不是"解码了"。stb_image 解位图、nanosvg 光栅化 SVG、ffmpeg(仅 prebuild)桥接 WebP/GIF;仅 SHA-256/PSNR/diff+golden 自写。静态链接无运行时依赖。

Cells 与断言(host 真跑绿, 三门 fail==0 && total==EXPECTED==pass, mutation-tested)

cell 断言
image_raster 7 格式 zoo: PNG/BMP/TGA/PPM 解码 byte-exact 共享 RGB SHA(4 解码器位级收敛)+PGM+JPEG PSNR 37.9dB+合成 round-trip+GIF palette+magic/header
image_formats 主流{png/bmp/tga/ppm/pgm/jpeg/webp/gif}编解码矩阵+magic+header
image_svg 合成 SVG 圆/矩形/线性渐变/even-odd 逐像素闭式+尺度不变(1x vs 2x ink 4.005x)+真 3DBenchy vs nanosvg golden SHA
image_realassets 真 PNG dimensions/channels+8x8 块签名 SHA; ASSET_DIR 缺 honest-skip

共 115 断言(有资产)/72(闭式独立模式)。大图片在 git submodule(Lfan-ke/hw4os-s5d1t2 media 分支, git-LFS)经 ASSET_DIR 引用,仓库只放 carpet 代码+golden(避污染主仓)。WebP 无 stb codec(ffmpeg 桥)、GIF encode 走 ffmpeg palette - 已文档化不静默跳过。

特殊声明:素材仅用于 OS 功能完整性 & 正确性验证,不作他用!有事请找:@Lfan-ke

复用 stb_image v2.30+nanosvg 单头(官方 github)+ffmpeg librsvg 不造解码器/光栅器。

关键文件: carpetsprebuild.sh

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本 PR 新增 apps/starry/cpu-image-test,目标是在四个架构的 StarryOS rootfs 中构建并运行基于 stb/nanosvg 的图像 carpet。它是新增 app-facing 能力,已按 feature-development 指引作为共享的测试/根文件系统工作流审查;不涉及 Starry syscall/Linux ABI,故 syscall 指引不适用。

发现 1 个阻塞问题:第三方单头文件未随 PR 提交,导致 prebuild.sh 无法编译任何 cell;详见行内评论。

影响范围:变更隔离在新 app 目录,但该目录经 app runner 修改 QEMU rootfs,因而当前无法交付其宣称的四架构图像测试能力。

验证:review_pr_helper.py prepare-review 已确认工作区 HEAD 为 4a754b83443d6d3d6c1c00ee4a9ea90880086391bash -n prebuild.shsh -n run_all.sh 和配置检查通过;最小 GCC 复现 image_raster.c:27: fatal error: third_party/stb_image.h: No such file or directory。未运行完整 QEMU:该确定性编译失败在启动前已阻断流程。

CI:当前 head 的组织 CI 共 71 个 check(success=26、skipped=35、cancelled=9、failure=1)。失败的 CI workflow 未运行此 app;现有 Test starry * qemu 执行的是 starry test qemu,而 starry-apps.yml 仅 schedule/workflow_dispatch,未覆盖本 PR 的 starry app qemu -t cpu-image-test。因此通过的通用 CI 不能替代本 app 的运行验证,且该问题由本 PR 缺失文件直接造成。

既有 review/行内讨论均为空。base 搜索仅发现不相同的既有 stb 使用;开放 PR 检索没有发现同一 cpu-image-test 实现。修复后请提交所有 pinned 依赖(保留许可证)或提供带 hash 校验的确定性下载,并在当前 head 实跑至少一个文档化的 app QEMU 命令。

Powered by gpt-5.6-terra

Comment thread apps/starry/cpu-image-test/prebuild.sh Outdated
local bin="$1" cell
for cell in image_raster image_formats image_svg image_realassets; do
echo "prebuild: cross-compile $cell for $arch (bundles stb/nanosvg; self-written SHA-256 + goldens)"
GCC -O2 -std=c11 -static -I"$CAR" "$CAR/$cell.c" -o "$bin/$cell" -lm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

严重:这里编译的四个源文件均 #include "third_party/...",但当前 PR 的 Git tree 中既没有 programs/carpets/third_party/,也没有这四个 README 声明会随程序提交的 pinned headers。因而 app runner 执行到本行时 GCC 会立即因缺少 stb_image.h(随后还有 nanosvg headers)失败,overlay 和任何 QEMU cell 都无法生成。请将有许可证说明的固定版本 headers 提交进来,或在编译前提供带完整性校验的确定性下载步骤,并在修复后的 head 上实际运行一条文档化的 cargo xtask starry app qemu -t cpu-image-test --arch ...

@Lfan-ke
Lfan-ke force-pushed the apps-starry-cpu-image-test branch from 4a754b8 to c7f441e Compare August 4, 2026 22:58

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本 PR 新增 apps/starry/cpu-image-test,计划在四个架构的 StarryOS rootfs 中构建并运行基于 stb/nanosvg 的图像测试。它是新增的 app/rootfs 测试工作流,feature-development.md 适用;不涉及 Starry syscall/Linux ABI,syscall 指引不适用。

发现两个阻塞问题:第三方单头文件没有随 PR 提交,导致预构建无法编译任何 cell;另外 README 和提交信息宣称的 WebP ffmpeg bridge 实际既未转换也未由任何 cell 断言。二者使宣称的四架构图像测试能力当前不可交付,影响虽隔离在新 app 目录,但会直接阻断其 rootfs/QEMU 工作流。

验证:review_pr_helper.py prepare-review 已确认工作区为 c7f441e7139889f595368d5a19ab25834d982475bash -n prebuild.shsh -n run_all.sh、所有新增 TOML 解析和 git diff --check 通过。直接执行 GCC 语法检查在 image_raster.c:27 复现 fatal error: third_party/stb_image.h: No such file or directory。完整 QEMU 未运行:该确定性编译失败发生在启动前,无法按文档完成 app 准备。修复后请在当前 head 至少实跑一条文档化的 cargo xtask starry app qemu -t cpu-image-test --arch ... 命令。

CI:已查询组织 rcore-os/tgoskits 的当前 head check-runs(71 个);常规 CI 有成功项目,但本 PR 新增的 app 未由该轮 CI 的 starry app qemu -t cpu-image-test 路径实际覆盖,不能替代上述 app 运行验证。未将 classic commit-status 的空状态误判为 CI 通过。

既有评论:上一轮在旧 head 的缺失 headers 评论在当前 head 仍成立,且已通过本地编译复现;没有其他需要处理的 PR discussion。重复/重叠分析:base 仅有不相同的 stb 使用,开放 PR 检索没有发现同一 cpu-image-test 实现。

审核清单已完成;阻塞项为两条行内问题。修复后请补齐依赖/完整性信息、使 WebP 覆盖可失败,并提供当前 head 的实际 app QEMU 运行证据。

Powered by gpt-5.6-terra

Comment thread apps/starry/cpu-image-test/prebuild.sh Outdated
local bin="$1" cell
for cell in image_raster image_formats image_svg image_realassets; do
echo "prebuild: cross-compile $cell for $arch (bundles stb/nanosvg; self-written SHA-256 + goldens)"
GCC -O2 -std=c11 -static -I"$CAR" "$CAR/$cell.c" -o "$bin/$cell" -lm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

严重(构建阻断):这里会编译四个均包含 third_party/... 的源文件,但当前 PR 没有提交 programs/carpets/third_party/ 或 README 声明的四个 pinned headers。执行到本行时 GCC 会先因缺少 stb_image.h 失败,overlay 无法生成,四个架构的 QEMU case 也无法启动。请提交保留许可证说明的固定版本 headers,或在编译前提供带完整性校验的确定性下载步骤;修复后请在当前 head 实跑至少一条文档化的 cargo xtask starry app qemu -t cpu-image-test --arch ... 命令。

Comment thread apps/starry/cpu-image-test/prebuild.sh Outdated
mkdir -p "$bin/assets"
if [[ -n "$src" && -d "$src" ]]; then
echo "prebuild: staging images from $src -> /opt/cpu-image-test/assets"
for f in fmt_ref.png fmt.bmp fmt.tga fmt.ppm fmt.pgm fmt.jpg fmt.webp \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

严重(覆盖声明不成立):此处仅把 fmt.webp 拷入 overlay,后续 ffmpeg 只生成 GIF;四个 cell 也没有读取或比较该 WebP。README/提交信息所称的“通过 ffmpeg bridge 覆盖 WebP decode”因此不会在坏 WebP 或转换缺失时失败,属于未被 runner 实际执行的功能声明。请在 prebuild 中确定性地将 WebP 转成 PPM,并在 cell 中对转换结果做像素/黄金断言;或者从文档和覆盖范围中移除 WebP。

@Lfan-ke
Lfan-ke force-pushed the apps-starry-cpu-image-test branch 2 times, most recently from 8f7568f to b91beab Compare August 6, 2026 15:06
Image carpet (C-side, pure CPU) covering both raster and vector. Every assertion is a
per-pixel byte-exact / PSNR-bounded / closed-form check against a golden - no smoke.
stb_image decodes bitmaps, nanosvg rasterizes SVG; only SHA-256 / PSNR / diff + goldens are
self-written. Cells cross-compile on the host (musl-cross toolchain, no gcc-under-qemu) and
link static, no runtime image-lib dependency. The stb/nanosvg single-headers are gitignored
(repo third_party/), so prebuild fetches them from pinned upstream commits with SHA-256
verification.

Cells (three-gate fail==0 && total==EXPECTED==pass, mutation-tested):
- image_raster (41): the same image in a 6-format zoo - PNG/BMP/TGA/PPM decode BYTE-EXACT
  to one shared RGB SHA (four decoders converge bit-for-bit), PGM gray SHA, JPEG PSNR
  (37.9 dB, bound >35), a synthetic in-memory encode->decode byte-exact round-trip, GIF
  palette byte-exact, magic bytes + stbi_info headers.
- image_formats (37): mainstream raster set {png,bmp,tga,ppm,pgm,jpeg,gif} - encode a
  synthetic pattern to each format, decode, assert lossless byte-exact / lossy PSNR +
  format magic + header fields. GIF is emitted by a deterministic pure-Python writer in
  prebuild (no ffmpeg); the leg hard-fails if the staged pal.gif is absent.
- image_svg (27): synthetic SVGs with analytically-known output asserted per-pixel -
  <circle>/<rect>/<linearGradient>/even-odd-vs-nonzero closed form; scale invariance
  (1x vs 2x ink ratio 4.005x); the real 3DBenchy SVG vs a calibrated nanosvg golden SHA.
- image_realassets (11): real PNGs - exact dimensions/channels + an 8x8-block signature
  SHA vs golden. Hard-fails if the media submodule (ASSET_DIR) is absent - the real rasters
  are required on-target, never a vacuous skip.

Large test images live in a git submodule (Lfan-ke/hw4os-s5d1t2 media branch, git-LFS)
via ASSET_DIR; only carpet code + golden references are committed here. WebP is not decoded
by any cell (stb has no WebP codec) and is not claimed as covered.

Signed-off-by: 林晨/禾可 <chengkelfan@qq.com>
Signed-off-by: Leo Cheng <chengkelfan@qq.com>
@Lfan-ke
Lfan-ke force-pushed the apps-starry-cpu-image-test branch from b91beab to a99a559 Compare August 6, 2026 16:00

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本 PR 新增 apps/starry/cpu-image-test,通过预构建生成四个图像测试 cell、将资源注入 StarryOS rootfs,并以 QEMU 配置运行。它属于新增 app/rootfs 工作流,已按 feature-development.md 的共享功能要求审查;未涉及 Starry syscall/Linux ABI,因此 syscall 指引不适用。

阻塞问题:rootfs 一致性检查失败被吞掉,详见行内评论。该问题位于每个文档化 QEMU 入口都会执行的 prebuild.sh,因此并非隔离的诊断细节:损坏或无法检查的 rootfs 仍会继续 resize 与写入 overlay,使失败不可诊断并可能继续写入坏镜像。

影响范围:代码改动本身隔离在新 app 目录,但会修改 QEMU rootfs,影响该目录声明的四架构运行流程。上轮“未提交 header”和 WebP 覆盖声明问题已在当前 head 分别通过 pinned 下载+SHA 校验、以及移除 WebP 覆盖声明解决;当前没有其他未解决的旧评论。

验证:review_pr_helper.py prepare-review 已确认工作区为 a99a55932e906f9ea84352866b2a6dd5e4ef1670;helper 自测、bash -n prebuild.shsh -n run_all.sh、新增 TOML 解析和 git diff --check 均通过。受控复现中 e2fsck -f -y 对无效镜像返回 8,而当前 || true 将其变为 0,证明后续步骤会继续。未完成完整 QEMU:当前环境缺少本 app 所需的 musl 交叉编译器和 QEMU;组织当前 head 的 6 个 check 均为 skipped/cancelled,未覆盖 starry app qemu -t cpu-image-test,不能替代该运行验证。

重复/重叠分析:dev 中未发现等价的 cpu-image-test 实现;检索到的开放 PR #1875 是 Python imaging carpet,属于相邻但不同的实现和运行面,不构成重复。修复 e2fsck 错误处理后,请在当前 head 至少运行一条 README 中的 app QEMU 命令并提供可观察的 guest 通过结果。

Powered by gpt-5.6-terra

command -v resize2fs >/dev/null 2>&1 || { echo "prebuild: resize2fs required (e2fsprogs)" >&2; exit 1; }
local before after; before=$(stat -c %s "$base_rootfs")
truncate -s "$ROOTFS_SIZE" "$base_rootfs"
e2fsck -f -y "$base_rootfs" >/dev/null 2>&1 || true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

严重(文件系统完整性):这里无条件吞掉 e2fsck -f -y 的退出码后继续 resize2fse2fsck 的 4/8 分别表示仍有未修复错误或操作错误;此时继续扩容并注入 overlay 会把损坏/不可检查的 rootfs 当作有效输入,导致本 app 的失败不可诊断,甚至进一步写入坏镜像。请仅接受 0/1(干净或已修复),对 4/8 及其他错误保留输出并立即退出,不要继续 resize/注入。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant