mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-07 08:07:20 +02:00
Fix up logging in the tests to use our macros
This commit is contained in:
parent
6793d0d436
commit
3ae26596bc
@ -48,13 +48,11 @@ static int verify_gamemode_initial(void)
|
|||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
if ((status = gamemode_query_status()) != 0 && status != -1) {
|
if ((status = gamemode_query_status()) != 0 && status != -1) {
|
||||||
fprintf(
|
LOG_ERROR("gamemode is currently active, tests require gamemode to start deactivated!\n");
|
||||||
stderr,
|
|
||||||
"ERROR: gamemode is currently active, tests require gamemode to start deactivated!\n");
|
|
||||||
status = -1;
|
status = -1;
|
||||||
} else if (status == -1) {
|
} else if (status == -1) {
|
||||||
fprintf(stderr, "ERROR: gamemode_query_status failed: %s!\n", gamemode_error_string());
|
LOG_ERROR("gamemode_query_status failed: %s!\n", gamemode_error_string());
|
||||||
fprintf(stderr, "ERROR: is gamemode installed correctly?\n");
|
LOG_ERROR("is gamemode installed correctly?\n");
|
||||||
status = -1;
|
status = -1;
|
||||||
} else {
|
} else {
|
||||||
status = 0;
|
status = 0;
|
||||||
@ -70,13 +68,11 @@ static int verify_active_and_registered(void)
|
|||||||
|
|
||||||
if (status != 2) {
|
if (status != 2) {
|
||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
fprintf(stderr, "ERROR: gamemode_query_status failed: %s\n", gamemode_error_string());
|
LOG_ERROR("gamemode_query_status failed: %s\n", gamemode_error_string());
|
||||||
} else if (status == 1) {
|
} else if (status == 1) {
|
||||||
fprintf(stderr,
|
LOG_ERROR("gamemode was active but did not have this process registered\n");
|
||||||
"ERROR: gamemode was active but did not have this process registered\n");
|
|
||||||
}
|
}
|
||||||
fprintf(stderr,
|
LOG_ERROR("gamemode failed to activate correctly when requested (expected 2)!\n");
|
||||||
"ERROR: gamemode failed to activate correctly when requested (expected 2)!\n");
|
|
||||||
status = -1;
|
status = -1;
|
||||||
} else {
|
} else {
|
||||||
status = 0;
|
status = 0;
|
||||||
@ -92,9 +88,9 @@ static int verify_deactivated(void)
|
|||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
fprintf(stderr, "ERROR: gamemode_query_status failed: %s\n", gamemode_error_string());
|
LOG_ERROR("gamemode_query_status failed: %s\n", gamemode_error_string());
|
||||||
}
|
}
|
||||||
fprintf(stderr, "ERROR: gamemode failed to deactivate when requested (expected 0)!\n");
|
LOG_ERROR("gamemode failed to deactivate when requested (expected 0)!\n");
|
||||||
status = -1;
|
status = -1;
|
||||||
} else {
|
} else {
|
||||||
status = 0;
|
status = 0;
|
||||||
@ -110,11 +106,9 @@ static int verify_other_client_connected(void)
|
|||||||
|
|
||||||
if (status != 1) {
|
if (status != 1) {
|
||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
fprintf(stderr, "ERROR: gamemode_query_status failed: %s\n", gamemode_error_string());
|
LOG_ERROR("gamemode_query_status failed: %s\n", gamemode_error_string());
|
||||||
}
|
}
|
||||||
fprintf(
|
LOG_ERROR("gamemode_query_status failed to return other client connected (expected 1)!\n");
|
||||||
stderr,
|
|
||||||
"ERROR: gamemode_query_status failed to return other client connected (expected 1)!\n");
|
|
||||||
status = -1;
|
status = -1;
|
||||||
} else {
|
} else {
|
||||||
status = 0;
|
status = 0;
|
||||||
@ -128,7 +122,7 @@ static int verify_other_client_connected(void)
|
|||||||
*/
|
*/
|
||||||
static int run_basic_client_tests(void)
|
static int run_basic_client_tests(void)
|
||||||
{
|
{
|
||||||
fprintf(stdout, " *basic client tests*\n");
|
LOG_MSG(" *basic client tests*\n");
|
||||||
|
|
||||||
/* First verify that gamemode is not currently active on the system
|
/* First verify that gamemode is not currently active on the system
|
||||||
* As well as it being currently installed and queryable
|
* As well as it being currently installed and queryable
|
||||||
@ -138,7 +132,7 @@ static int run_basic_client_tests(void)
|
|||||||
|
|
||||||
/* Verify that gamemode_request_start correctly start gamemode */
|
/* Verify that gamemode_request_start correctly start gamemode */
|
||||||
if (gamemode_request_start() != 0) {
|
if (gamemode_request_start() != 0) {
|
||||||
fprintf(stderr, "ERROR: gamemode_request_start failed: %s\n", gamemode_error_string());
|
LOG_ERROR("gamemode_request_start failed: %s\n", gamemode_error_string());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +142,7 @@ static int run_basic_client_tests(void)
|
|||||||
|
|
||||||
/* Verify that gamemode_request_end corrently de-registers gamemode */
|
/* Verify that gamemode_request_end corrently de-registers gamemode */
|
||||||
if (gamemode_request_end() != 0) {
|
if (gamemode_request_end() != 0) {
|
||||||
fprintf(stderr, "ERROR: gamemode_request_end failed: %s!\n", gamemode_error_string());
|
LOG_ERROR("gamemode_request_end failed: %s!\n", gamemode_error_string());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +150,7 @@ static int run_basic_client_tests(void)
|
|||||||
if (verify_deactivated() != 0)
|
if (verify_deactivated() != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
fprintf(stdout, " *passed*\n");
|
LOG_MSG(" *passed*\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -169,12 +163,12 @@ static int run_dual_client_tests(void)
|
|||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
/* Try running some process interop tests */
|
/* Try running some process interop tests */
|
||||||
fprintf(stdout, " *dual clients tests*\n");
|
LOG_MSG(" *dual clients tests*\n");
|
||||||
|
|
||||||
/* Get the current path to this binary */
|
/* Get the current path to this binary */
|
||||||
char mypath[PATH_MAX];
|
char mypath[PATH_MAX];
|
||||||
if (readlink("/proc/self/exe", mypath, PATH_MAX) == -1) {
|
if (readlink("/proc/self/exe", mypath, PATH_MAX) == -1) {
|
||||||
fprintf(stderr, "ERROR: could not read current exe path: %s\n", strerror(errno));
|
LOG_ERROR("could not read current exe path: %s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,10 +177,7 @@ static int run_dual_client_tests(void)
|
|||||||
if (child == 0) {
|
if (child == 0) {
|
||||||
/* Relaunch self with -r (request and wait for signal) */
|
/* Relaunch self with -r (request and wait for signal) */
|
||||||
if (execl(mypath, mypath, "-r", (char *)NULL) == -1) {
|
if (execl(mypath, mypath, "-r", (char *)NULL) == -1) {
|
||||||
fprintf(stderr,
|
LOG_ERROR("failed to re-launch self (%s) with execv: %s\n", mypath, strerror(errno));
|
||||||
"ERROR: failed to re-launch self (%s) with execv: %s\n",
|
|
||||||
mypath,
|
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,7 +194,7 @@ static int run_dual_client_tests(void)
|
|||||||
|
|
||||||
/* Verify that gamemode_request_start correctly start gamemode */
|
/* Verify that gamemode_request_start correctly start gamemode */
|
||||||
if (gamemode_request_start() != 0) {
|
if (gamemode_request_start() != 0) {
|
||||||
fprintf(stderr, "ERROR: gamemode_request_start failed: %s\n", gamemode_error_string());
|
LOG_ERROR("gamemode_request_start failed: %s\n", gamemode_error_string());
|
||||||
status = -1;
|
status = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +204,7 @@ static int run_dual_client_tests(void)
|
|||||||
|
|
||||||
/* Request end of gamemode (de-register ourselves) */
|
/* Request end of gamemode (de-register ourselves) */
|
||||||
if (gamemode_request_end() != 0) {
|
if (gamemode_request_end() != 0) {
|
||||||
fprintf(stderr, "ERROR: gamemode_request_end failed: %s!\n", gamemode_error_string());
|
LOG_ERROR("gamemode_request_end failed: %s!\n", gamemode_error_string());
|
||||||
status = -1;
|
status = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,9 +214,7 @@ static int run_dual_client_tests(void)
|
|||||||
|
|
||||||
/* Send SIGINT to child to wake it up*/
|
/* Send SIGINT to child to wake it up*/
|
||||||
if (kill(child, SIGINT) == -1) {
|
if (kill(child, SIGINT) == -1) {
|
||||||
fprintf(stderr,
|
LOG_ERROR("failed to send continue signal to other client: %s\n", strerror(errno));
|
||||||
"ERROR: failed to send continue signal to other client: %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
status = -1;
|
status = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +224,7 @@ static int run_dual_client_tests(void)
|
|||||||
// Wait for the child to finish up
|
// Wait for the child to finish up
|
||||||
int wstatus;
|
int wstatus;
|
||||||
while (waitpid(child, &wstatus, WNOHANG) == 0) {
|
while (waitpid(child, &wstatus, WNOHANG) == 0) {
|
||||||
fprintf(stdout, " Waiting for child to quit...\n");
|
LOG_MSG(" Waiting for child to quit...\n");
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +233,7 @@ static int run_dual_client_tests(void)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
fprintf(stdout, " *passed*\n");
|
LOG_MSG(" *passed*\n");
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -258,7 +247,7 @@ static int run_dual_client_tests(void)
|
|||||||
int game_mode_run_client_tests()
|
int game_mode_run_client_tests()
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
fprintf(stdout, "Running tests...\n");
|
LOG_MSG("Running tests...\n");
|
||||||
|
|
||||||
/* Run the basic tests */
|
/* Run the basic tests */
|
||||||
if (run_basic_client_tests() != 0)
|
if (run_basic_client_tests() != 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user