[main] Add a 'testrun' command line option for Github actions

This commit is contained in:
ejurgensen 2023-08-31 17:08:19 +02:00
parent 3f6c7405ed
commit a9e21dcbfd

View File

@ -477,19 +477,20 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int option; int option;
char *configfile; char *configfile = CONFFILE;
bool background; bool background = true;
bool mdns_no_rsp; bool testrun = false;
bool mdns_no_daap; bool mdns_no_rsp = false;
bool mdns_no_cname; bool mdns_no_daap = false;
bool mdns_no_web; bool mdns_no_cname = false;
bool mdns_no_mpd; bool mdns_no_web = false;
int loglevel; bool mdns_no_mpd = false;
char *logdomains; int loglevel = -1;
char *logfile; char *logdomains = NULL;
char *ffid; char *logfile = NULL;
char *pidfile; char *ffid = NULL;
char *webroot; char *pidfile = PIDFILE;
char *webroot = WEB_ROOT;
char **buildopts; char **buildopts;
const char *av_version; const char *av_version;
const char *gcry_version; const char *gcry_version;
@ -511,6 +512,7 @@ main(int argc, char **argv)
{ "pidfile", 1, NULL, 'P' }, { "pidfile", 1, NULL, 'P' },
{ "version", 0, NULL, 'v' }, { "version", 0, NULL, 'v' },
{ "webroot", 1, NULL, 'w' }, { "webroot", 1, NULL, 'w' },
{ "testrun", 0, NULL, 't' }, // Used for CI, not documented to user
{ "mdns-no-rsp", 0, NULL, 512 }, { "mdns-no-rsp", 0, NULL, 512 },
{ "mdns-no-daap", 0, NULL, 513 }, { "mdns-no-daap", 0, NULL, 513 },
@ -520,20 +522,7 @@ main(int argc, char **argv)
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
configfile = CONFFILE; while ((option = getopt_long(argc, argv, "D:d:c:P:ftb:vw:", option_map, NULL)) != -1)
pidfile = PIDFILE;
webroot = WEB_ROOT;
loglevel = -1;
logdomains = NULL;
logfile = NULL;
background = true;
ffid = NULL;
mdns_no_rsp = false;
mdns_no_daap = false;
mdns_no_cname = false;
mdns_no_web = false;
while ((option = getopt_long(argc, argv, "D:d:c:P:fb:vw:", option_map, NULL)) != -1)
{ {
switch (option) switch (option)
{ {
@ -553,6 +542,10 @@ main(int argc, char **argv)
mdns_no_web = true; mdns_no_web = true;
break; break;
case 't':
testrun = true;
break;
case 'b': case 'b':
ffid = optarg; ffid = optarg;
break; break;
@ -821,7 +814,6 @@ main(int argc, char **argv)
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto mpd_fail; goto mpd_fail;
} }
mdns_no_mpd = false;
#else #else
mdns_no_mpd = true; mdns_no_mpd = true;
#endif #endif
@ -903,7 +895,8 @@ main(int argc, char **argv)
event_add(sig_event, NULL); event_add(sig_event, NULL);
/* Run the loop */ /* Run the loop */
event_base_dispatch(evbase_main); if (!testrun)
event_base_dispatch(evbase_main);
DPRINTF(E_LOG, L_MAIN, "Stopping gracefully\n"); DPRINTF(E_LOG, L_MAIN, "Stopping gracefully\n");
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;