Skip to content

Commit edef5b8

Browse files
libretroadminLibretroAdmin
authored andcommitted
menu_displaylist: extend the validation dump to menu_displaylist_ctl
The dump's first pass covers menu_displaylist_build_list; the 271-case ctl switch it hangs off had no coverage at all. A second pass now drives ctl for every dumpable type, each in a forked child built from identical pristine parent state, streaming its rows, return value and final flags back through a pipe - a crashing case names its signal in the dump and the run continues, and no case sees another's side effects. On this build that is 189 clean sections and 2,034 rows of new deterministic coverage, with sixteen headless-crash cases recorded rather than hidden. POSIX only, compiled solely under the validation flag; release builds carry nothing.
1 parent a9dc6ea commit edef5b8

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

menu/menu_displaylist.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7143,6 +7143,10 @@ static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
71437143
}
71447144
#endif
71457145

7146+
#if defined(RETROARCH_VALIDATION_DUMPS) && !defined(_WIN32)
7147+
#include <unistd.h>
7148+
#include <sys/wait.h>
7149+
#endif
71467150
#if defined(RETROARCH_VALIDATION_DUMPS)
71477151
/* Validation dump for the displaylist build path.
71487152
*
@@ -7213,6 +7217,81 @@ void menu_displaylist_validation_dump(rarch_setting_t *list_settings)
72137217
list.list[i].type, (unsigned)list.list[i].entry_idx);
72147218
file_list_deinitialize(&list);
72157219
}
7220+
/* Second pass: menu_displaylist_ctl itself, the 271-case switch
7221+
* the first pass never reached. Each type builds in a forked
7222+
* child from identical pristine parent state, so one crashing or
7223+
* hanging case names itself in the dump without taking the run
7224+
* down, and no case sees another's side effects. POSIX only;
7225+
* the dump is a validation tool and never ships. */
7226+
#if !defined(_WIN32)
7227+
for (t = 0; t <= (unsigned)DISPLAYLIST_PENDING_CLEAR; t++)
7228+
{
7229+
int pfd[2];
7230+
pid_t pid;
7231+
if (t == (unsigned)DISPLAYLIST_INFORMATION_LIST
7232+
|| t == (unsigned)DISPLAYLIST_SYSTEM_INFO
7233+
|| t == (unsigned)DISPLAYLIST_HELP_SCREEN_LIST
7234+
|| (t >= (unsigned)DISPLAYLIST_CORE_CONTENT
7235+
&& t <= (unsigned)DISPLAYLIST_CORE_SYSTEM_FILES))
7236+
{
7237+
filestream_printf(f, "=c= %u skipped\n", t);
7238+
continue;
7239+
}
7240+
filestream_printf(f, "=c= %u ", t);
7241+
filestream_flush(f);
7242+
if (pipe(pfd) != 0)
7243+
break;
7244+
if ((pid = fork()) == 0)
7245+
{
7246+
file_list_t cl;
7247+
menu_displaylist_info_t info;
7248+
FILE *w = fdopen(pfd[1], "w");
7249+
size_t i2;
7250+
bool ret;
7251+
close(pfd[0]);
7252+
memset(&cl, 0, sizeof(cl));
7253+
menu_displaylist_info_init(&info);
7254+
info.list = &cl;
7255+
ret = menu_displaylist_ctl(
7256+
(enum menu_displaylist_ctl_state)t, &info, settings);
7257+
if (w)
7258+
{
7259+
fprintf(w, "ret=%d flags=%08x size=%u\n",
7260+
ret ? 1 : 0, (unsigned)info.flags, (unsigned)cl.size);
7261+
for (i2 = 0; i2 < cl.size; i2++)
7262+
fprintf(w, "%u|%s|%s|%u|%u\n", (unsigned)i2,
7263+
cl.list[i2].path ? cl.list[i2].path : "",
7264+
cl.list[i2].label ? cl.list[i2].label : "",
7265+
cl.list[i2].type, (unsigned)cl.list[i2].entry_idx);
7266+
fflush(w);
7267+
}
7268+
_exit(0);
7269+
}
7270+
else if (pid > 0)
7271+
{
7272+
char buf[512];
7273+
ssize_t r;
7274+
int status = 0;
7275+
close(pfd[1]);
7276+
while ((r = read(pfd[0], buf, sizeof(buf))) > 0)
7277+
filestream_write(f, buf, (size_t)r);
7278+
close(pfd[0]);
7279+
waitpid(pid, &status, 0);
7280+
if (WIFSIGNALED(status))
7281+
filestream_printf(f, "crashed sig=%d\n", WTERMSIG(status));
7282+
else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
7283+
filestream_printf(f, "exit=%d\n",
7284+
WIFEXITED(status) ? WEXITSTATUS(status) : -1);
7285+
filestream_flush(f);
7286+
}
7287+
else
7288+
{
7289+
close(pfd[0]);
7290+
close(pfd[1]);
7291+
break;
7292+
}
7293+
}
7294+
#endif
72167295
menu_st->entries.list_settings = saved_list;
72177296
filestream_close(f);
72187297
}

0 commit comments

Comments
 (0)