v1.0.15: shell is now build input (.zip), launch self-check for incomplete packages and devices without Metal 3, graphics translation on its own thread, save with the pause menu open, wide-iPhone item tooltip and Chronicle rewards fixes

This commit is contained in:
jhaizhou
2026-10-15 04:32:15 +08:00
parent 7ff4e36710
commit b94670c795
26 changed files with 721 additions and 248 deletions
+39
View File
@@ -26,6 +26,7 @@ ssize_t pwrite(int, const void *, size_t, off_t);
struct dm_flags g_flag; uint64_t g_t0_ns; uint64_t now_ns(void) { return 0; } // 日志时间戳与读路径的桩(写路径不用) | stubs for log timestamps and the read path (not used by the write path)
void dm_prof_add(int id, uint64_t ns, uint64_t b) { (void)id; (void)ns; (void)b; } void dm_guest_write_prepare(void *a, size_t n) { (void)a; (void)n; }
void dm_fs_save_poison(int e);
extern int g_nfail, g_lasterr; // 前端通知计数(t_fs_stub.c 的强实现替掉 hle_fs.c 的弱实现) | front-end notification count (the strong implementation in t_fs_stub.c replaces the weak one in hle_fs.c)
static int g_mode, g_calls; // 0 照常写;1 一律返回 0;2 第一次只写 3 字节 | 0 write normally; 1 always return 0; 2 write only 3 bytes the first time
static ssize_t fake_pwrite(int fd, const void *buf, size_t n, off_t off) {
@@ -143,6 +144,44 @@ int main(void) {
snprintf(p, sizeof p, "%s/a", work); CHECK(same(p, "new"), "工作目录 a 回到已提交版 new");
snprintf(p, sizeof p, "%s/b", work); CHECK(same(p, "7"), "工作目录 b = 已提交的 7");
printf("⑥ 写失败收场不退出(DM_TEST_FS_FAILAT)\n");
unsetenv("DM_TEST_FS_FAIL");
// ⑥a 提交被拒后重新克隆失败:不退出、工作目录不动、已提交版不变;下次提交照样拒绝并重新克隆成功;再下一个事务照常提交
// 6a Recloning after a refused commit fails: do not exit, the work directory is untouched and the committed version unchanged; the next commit is refused again and the reclone succeeds; the transaction after that commits normally
setenv("DM_TEST_FS_FAILAT", "reclone:1", 1);
CHECK(write_save("save:/a", "bad") == RES_OK, "写 a=bad");
dm_fs_save_poison(ENOSPC); int nf0 = g_nfail;
CHECK(h_fs_Commit("save") == RES_FAIL && g_nfail == nf0 + 1, "本事务被拒(重新克隆注入失败),进程还在,前端通知 1 次");
snprintf(p, sizeof p, "%s/a", save); CHECK(same(p, "new"), "已提交目录 a 仍是 new");
snprintf(p, sizeof p, "%s/a", work); CHECK(same(p, "bad"), "工作目录没删(a 还是 bad)");
CHECK(h_fs_Commit("save") == RES_FAIL && g_nfail == nf0 + 2, "仍是已污染:下一次提交照样拒绝");
snprintf(p, sizeof p, "%s/a", work); CHECK(same(p, "new"), "这次重新克隆成了:工作目录 a 回到 new");
snprintf(p, sizeof p, "%s.re", work); CHECK(access(p, F_OK) != 0, "没有 .re 残留");
CHECK(write_save("save:/a", "good") == RES_OK && h_fs_Commit("save") == RES_OK, "下一个事务写 a=good,提交成功");
snprintf(p, sizeof p, "%s/a", save); CHECK(same(p, "good"), "已提交 a = good");
// ⑥b 改名后写客体名失败、回退也失败:不退出;文件在事务存档里 → 本事务提交被拒、已提交版不变;重新克隆后照常
// 6b Writing the guest name after a rename fails and the rollback fails too: do not exit; the file is in a transactional save, so this transaction's commit is refused and the committed version is unchanged; after recloning everything works
setenv("DM_TEST_FS_FAILAT", "guestname:1,renameback:1", 1);
h_fs_CreateFile("save:/c", 0); CHECK(write_save("save:/c", "c") == RES_OK, "写 c");
CHECK(h_fs_RenameFile("save:/c", "save:/d") != RES_OK, "改名 c → d 返回失败(两步都注入失败),进程还在");
nf0 = g_nfail; CHECK(h_fs_Commit("save") == RES_FAIL && g_nfail == nf0 + 1, "本事务提交被拒");
snprintf(p, sizeof p, "%s/c", save); CHECK(access(p, F_OK) != 0, "已提交目录没有 c");
snprintf(p, sizeof p, "%s/d", save); CHECK(access(p, F_OK) != 0, "已提交目录没有 d");
snprintf(p, sizeof p, "%s/a", save); CHECK(same(p, "good"), "已提交 a 仍是 good");
CHECK(write_save("save:/a", "ok2") == RES_OK && h_fs_Commit("save") == RES_OK, "下一个事务照常提交");
// ⑥c 挂载时克隆工作目录失败:不退出,改成只读挂载已提交目录——读得到、写不进、提交是空操作、已提交版不变、前端通知 1 次;下次正常挂载照旧
// 6c Cloning the work directory at mount fails: do not exit; mount the committed directory read-only instead. Reads work, writes fail, commits are no-ops, the committed version is unchanged, and the front end is notified once; the next normal mount works as before
setenv("DM_TEST_FS_FAILAT", "mountclone:1", 1); g_nmnt = 0; nf0 = g_nfail;
snprintf(p, sizeof p, "rm -rf '%s'", work); system(p);
CHECK(h_fs_MountSave("save", NULL) == RES_OK && g_nfail == nf0 + 1, "挂载返回成功、前端通知 1 次(实际 %d 次)", g_nfail - nf0);
CHECK(read_fs("save:/a", got, sizeof got) && !strcmp(got, "ok2"), "只读挂载下读得到已提交的 a=ok2(读到 %s)", got);
CHECK(write_save("save:/a", "zzz") != RES_OK, "写不进去");
CHECK(h_fs_Commit("save") == RES_OK, "提交是空操作");
snprintf(p, sizeof p, "%s/a", save); CHECK(same(p, "ok2"), "已提交 a 仍是 ok2");
unsetenv("DM_TEST_FS_FAILAT"); g_nmnt = 0;
CHECK(h_fs_MountSave("save", NULL) == RES_OK && write_save("save:/a", "ok3") == RES_OK && h_fs_Commit("save") == RES_OK, "去掉注入重新挂载:事务式照常,写 a=ok3 提交成功");
snprintf(p, sizeof p, "%s/a", save); CHECK(same(p, "ok3"), "已提交 a = ok3");
// 语言开关改写设置文件(settings_lang_apply):期望值按规则手算——只在「与开关不符」时把 Language / VoiceLanguage 改成 0(英文)或 8(简中),别的键和别的语言不动
// Language switch rewriting the settings file (settings_lang_apply): expected values computed by hand from the rule -- only when it "does not match the switch" are Language / VoiceLanguage changed to 0 (English) or 8 (Simplified Chinese); other keys and other languages are untouched
{ extern int g_t_lang; char sd[1200], sf[1300], gotj[512]; snprintf(sd, sizeof sd, "%s/langt", root); mkdir(sd, 0755); snprintf(sf, sizeof sf, "%s/Settings", sd); mkdir(sf, 0755); snprintf(sf, sizeof sf, "%s/Settings/Settings.json", sd);