mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 12:54:29 +01:00
tests/startup_test.c boots the real felucca_init in fresh processes (empty flash, a saved arrangement with RESTORE LAST OFF and ON) and checks rows, bars, END, scenes and flash through the automatic save. It fails without the 0.6.81 fix in main.c and passes with it. Written by @workeffortwaste in #134, whose fix the 0.6.81 one already covered. FUNDING.yml: the Sponsor button is JIANT's author's (Felucca linked in a comment). Co-authored-by: workeffortwaste <49479599+workeffortwaste@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
64 lines
2.7 KiB
C
64 lines
2.7 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only
|
|
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
|
/* Native emulator boot: includes main.c's real felucca_init, not just the storage loader. */
|
|
/* (JIANT 0.6.84) by @workeffortwaste (pull request #134, the ARRANGE power-off bug): it fails without main.c's
|
|
* 0.6.81 fix (felucca_init clearing the arrangement persist_boot had read) and passes with it. */
|
|
#include "../web/emu/felucca_web.c"
|
|
|
|
static int startup_case(int saved, int restore)
|
|
{
|
|
song_index_t want, got;
|
|
persist_t prefs = {0};
|
|
uint32_t i;
|
|
int ok;
|
|
web_nor_erase();
|
|
memset(&want, 0, sizeof want);
|
|
want.magic = SONG_MAGIC;
|
|
want.version = 2;
|
|
want.cur = saved ? 2u : 0u;
|
|
for (i = 0; i < NSONG; i++) chain_defaults(&want.rows[i]);
|
|
if (saved) {
|
|
want.rows[2].count = 2;
|
|
want.rows[2].row[0] = (chain_row_t){0, 3};
|
|
want.rows[2].row[1] = (chain_row_t){1, 7};
|
|
SONG_END(&want.rows[2]) = 3;
|
|
want.scene[2][0] = (scene_t){1, 2, 4, {11, 22, 33, 44}};
|
|
want.rows[0].count = 1;
|
|
want.rows[0].row[0] = (chain_row_t){3, 9};
|
|
if (st_save(OBJ_SONGIDX, &want, sizeof want)) return 1;
|
|
}
|
|
prefs.magic = PERSIST_MAGIC;
|
|
prefs.panel = PANEL_DEFAULT;
|
|
prefs.favorites.factory[15][30] = restore ? PREF_RESTORE_ON : 0;
|
|
if (st_save(OBJ_SETTINGS, &prefs, sizeof prefs)) return 1;
|
|
|
|
web_boot();
|
|
ok = song_cur == want.cur && !memcmp(&chain_config, &want.rows[want.cur], sizeof chain_config);
|
|
ok &= !!(ui_prefs & PREF_RESTORE_ON) == restore;
|
|
ok &= !memcmp(song_idx.scene, want.scene, sizeof want.scene);
|
|
/* Advance beyond the splash and the arrangement's two-second automatic save. */
|
|
for (i = 0; i < 2000u; i++) web_render(128);
|
|
ok &= !memcmp(&chain_config, &want.rows[want.cur], sizeof chain_config);
|
|
if (saved)
|
|
ok &= st_load(OBJ_SONGIDX, &got, sizeof got) == (int)sizeof got && !memcmp(&got, &want, sizeof got);
|
|
else
|
|
ok &= st_load(OBJ_SONGIDX, &got, sizeof got) < 0;
|
|
printf("startup: %s, RESTORE LAST %s: rows, bars, END, scenes and flash %s\n",
|
|
saved ? "saved project 3" : "empty flash", restore ? "ON" : "OFF", ok ? "ok" : "FAIL");
|
|
return !ok;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int mode, status, bad = 0;
|
|
/* Each child starts with fresh static RAM, as a new device instance does. */
|
|
for (mode = 0; mode < 3; mode++) {
|
|
pid_t child = fork();
|
|
if (child < 0) return 2;
|
|
if (!child) exit(startup_case(mode != 0, mode == 2));
|
|
if (waitpid(child, &status, 0) != child || !WIFEXITED(status) || WEXITSTATUS(status)) bad++;
|
|
}
|
|
puts(bad ? "startup test FAILED" : "startup test passed");
|
|
return !!bad;
|
|
}
|