fix(sdk/watchdog): 236 收尾 — sigusr1_guard 无日志目录时落 stderr 可观测; test_wd_fw 补 fw-app/裸沉浸/裸非沉浸三用例; hello/files/ncm 随 meow_ui.a(4020227c) 重链 (已热更到卡, watchdog 6373d8e5 待入 M2.89)

This commit is contained in:
MeowOS committed 2026-08-31 19:12:51 +08:00
1 parent 49c31f1901
commit 92086129c5
11 files changed
+33 -10

No files matched your search

Binary file not shown.
Binary file not shown.
+1 -4
View File
@@ -21,7 +21,7 @@
#include <stdint.h>
#include <time.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <poll.h>
#include <linux/input.h>
#ifndef EVIOCGRAB
@@ -147,18 +147,15 @@ static void loop_forward(const char *dev, int fwd)
fflush(stdout);
struct pollfd pfd = { fd, POLLIN, 0 };
unsigned char ev[16];
unsigned long long nread = 0, nwritten = 0;
for (;;) {
int r = poll(&pfd, 1, -1);
if (r < 0) { perror("poll"); break; }
if (pfd.revents & POLLIN) {
ssize_t n = read(fd, ev, sizeof ev);
if (n != 16) { if (n < 0) perror("read"); continue; }
nread++;
print_ev("G", ev);
if (fwd) {
ssize_t w = write(fd, ev, sizeof ev);
nwritten++;
if (w != 16) fprintf(stderr, " write-back failed: %s\n", strerror(errno));
}
}
+1
View File
@@ -92,6 +92,7 @@ int main(void)
setbuf(stdout, NULL); /* 立即冲刷,abort 前也能看到 printf */
setenv("MEOW_UI_DUMP", "/tmp/icon.ppm", 1);
meow_ui_opts o = { FB_W, FB_H };
(void)o;
assert(meow_ui_init(&o) == 0);
assert(meow_ui_width() == FB_W && meow_ui_height() == FB_H);
@@ -358,7 +358,6 @@ static void test_clear_drag_pure(void)
/* mini 状态机:跟手下拉打开(seed 从0 升)→ 松手锚定 */
int seed = 0, p = 0;
int dy = 0;
/* 手指下移 300px:reveal=seed+(tly-drag_y0) */
seed = 0; p = mnp_drag_progress(mnp_drag_reveal(seed, 300, PH), FIX, PH);
CHECK(p > 0 && p < FIX, "mini open-follow: drag 300px -> partial progress");
Binary file not shown.
+25
View File
@@ -24,6 +24,25 @@ static void check(const char *name, int got, int want)
else { g_fail++; printf("FAIL %s: got %d want %d\n", name, got, want); }
}
/* ---- M2.87:SIGUSR1 手势让位(handle_touch 左缘滑动分支)----
* 判定(meow_watchdog.c):`!g_fw_app && immersive` 才发 SIGUSR1(只给裸沉浸 App);
* SDK 框架 App(g_fw_app=1)不发(返回由 SDK on_swipe 处理),防 SIGUSR1 杀死 App。 */
static volatile int g_sigusr1_hits = 0;
static void on_sigusr1(int s) { (void)s; g_sigusr1_hits++; }
/* 经 handle_touch 模拟一次「左缘起点+向右滑」完整手势(press→release),返回 SIGUSR1 命中数。 */
static int sim_swipe_sigusr1(int fw, int immersive)
{
g_fw_app = fw;
g_sigusr1_hits = 0;
last_x = 5; last_y = 300; /* 左缘原点(x<EDGE_W=24) */
unsigned long long now = now_ms();
handle_touch(immersive, getpid(), now - 3000, 1); /* press(过冷却期 + 坐标就绪) */
last_x = 100; /* 向右滑 95px(>SWIPE_DX=50) */
handle_touch(immersive, getpid(), now - 3000, 0); /* release */
return g_sigusr1_hits;
}
/* 在 <base>/<name> 建目录并写 app.json;写失败返回 -1。 */
static int fixture(const char *base, const char *name, const char *appjson)
{
@@ -51,6 +70,7 @@ static int expect_fw(const char *base, const char *name, const char *appjson, in
int main(void)
{
signal(SIGUSR1, on_sigusr1); /* 捕获 handle_touch 可能发出的 SIGUSR1(测命中) */
char dir[] = "/tmp/wdfwXXXXXX";
if (!mkdtemp(dir)) { perror("mkdtemp"); return 2; }
@@ -84,6 +104,11 @@ int main(void)
/* wd_framework_from_pid:自进程 /proc/self/exe 目录无 app.json -> 0,不崩 */
check("from_pid(no app.json)", wd_framework_from_pid(getpid()), 0);
/* ---- M2.87 SIGUSR1 让位判定(仅裸沉浸 App 发 SIGUSR1)---- */
check("sigusr1 fw-app (framework=1) -> 0", sim_swipe_sigusr1(1, 1), 0); /* SDK 框架 App:不发 */
check("sigusr1 bare-immersive -> 1", sim_swipe_sigusr1(0, 1), 1); /* 裸沉浸:发(命中) */
check("sigusr1 bare-nonimmersive -> 0", sim_swipe_sigusr1(0, 0), 0); /* 裸非沉浸:不发 */
/* 清理 */
{
char path[560];
Binary file not shown.
+6 -5
View File
@@ -154,11 +154,12 @@ static void sigusr1_guard(int sig)
{
(void)sig;
if (!g_log_open_tried) { g_log_open_tried = 1; log_open(); }
if (g_log_fd >= 0) {
char line[128];
int n = snprintf(line, sizeof line, "%llu [%s] WARN sigusr1: ignored (guard)\n",
(unsigned long long)meow_ui_time_ms(), g_app_id);
if (n > 0) { ssize_t w = write(g_log_fd, line, (size_t)n); (void)w; }
char line[128];
int n = snprintf(line, sizeof line, "%llu [%s] WARN sigusr1: ignored (guard)\n",
(unsigned long long)meow_ui_time_ms(), g_app_id);
if (n > 0) {
if (g_log_fd >= 0) { ssize_t w = write(g_log_fd, line, (size_t)n); (void)w; }
else { ssize_t w = write(2, line, (size_t)n); (void)w; } /* 无日志目录:写 stderr,护栏可观测 */
}
/* 不 exit、不返回处理:返回交给 on_swipe/SDK。这里仅记录并吞掉。 */
}
Binary file not shown.
Binary file not shown.