Files
MeowOS-For-R3P2/font/test_budget.c
T
MeowOS c0f7a95719 feat(font+sys): 字库内存纪律(agent-215)+sysui接管launcher监管(agent-216)
215: meow_font.c 流式分块解码(gbk峰值40→23.5MB, 逐字节校验一致) + 多字体槽5→4+16MB驻留预算; 量化: gbk稳态驻留17.3MB vs common 4.2MB(OOM主因); meow_font.a→67113c03 meow_ui.a→223d5401
216: bootmenu让位(sysui在则start launcher让位, 不在则exec兜底) + S70预置launcher.conf enabled=1(+旧设备升级迁移); launcher崩溃可自动拉起; bootmenu 4441822d / S70 e435affc / S90 e0ace111
216注: S70早启动与选单共存为真机重点观察项
2026-08-31 13:28:07 +08:00

40 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* test_budget.c — 宿主校验 meow_font_config_multifont 的「打包面内存预算」:
* slot0=common(≈4.2MiB)+ 给 CJK 类别装 gbk(≈16.6MiB)→ 合计 > MEOW_MULTIFONT_MEM_BUDGET
* → gbk 应被拒绝(distinct=1,truncated=1),防止大字库 + 多字体双驻留 OOM。
* 用法:gcc -I. test_budget.c meow_font.c -lz -o test_budget
* ./test_budget <common.png> <common.idx> <gbk.png> <gbk.idx>
*/
#include "meow_font.h"
#include <stdio.h>
#include <string.h>
static int g_fail = 0;
#define CHECK(cond, msg) do { \
if (!(cond)) { g_fail++; fprintf(stderr, "FAIL: %s\n", msg); } \
else printf("ok : %s\n", msg); \
} while (0)
int main(int argc, char **argv) {
if (argc < 5) { fprintf(stderr, "usage: %s <common.png> <common.idx> <gbk.png> <gbk.idx>\n", argv[0]); return 2; }
int r = meow_font_load(argv[1], argv[2]); /* slot0 = common */
CHECK(r == 0, "load slot0 common");
meow_font_class_cfg cfg[MEOW_FCLS_COUNT];
memset(cfg, 0, sizeof cfg);
cfg[MEOW_FCLS_CJK].png = argv[3]; /* CJK 类别 → gbk 大字库 */
cfg[MEOW_FCLS_CJK].idx = argv[4];
int distinct = 0, truncated = 0;
r = meow_font_config_multifont(1, argv[1], argv[2], cfg, &distinct, &truncated);
CHECK(r == 0, "config_multifont ok");
printf(" distinct=%d truncated=%d\n", distinct, truncated);
/* slot0 common 4.2MiB + gbk 16.6MiB = 20.8MiB > 16MiB 预算 → gbk 被拒 → distinct 仅全局 */
CHECK(distinct == 1, "distinct==1 (gbk rejected by MEM_BUDGET)");
CHECK(truncated == 1, "truncated==1 (budget exceeded -> class fell back to global)");
/* gbk 槽应未驻留:distinct==1(仅全局 common)即证明 gbk 未被 commit;
* 注意 common 4k 亦含「中」,故不能以 has_glyph(中)==0 断言——改以「common 仍在」佐证。 */
CHECK(meow_font_has_glyph('A') == 1, "has_glyph(A)==1 (common still there)");
meow_font_unload();
printf("\nRESULT: %s\n", g_fail ? "FAIL" : "PASS");
return g_fail ? 1 : 0;
}