test: simplify platform_init()

PR-URL: https://github.com/libuv/libuv/pull/2755
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This commit is contained in:
Ben Noordhuis 2020-03-27 23:37:51 +01:00
parent fa1da18549
commit 0ed9692a80
5 changed files with 5 additions and 11 deletions

View File

@ -33,8 +33,7 @@ static int maybe_run_test(int argc, char **argv);
int main(int argc, char **argv) { int main(int argc, char **argv) {
if (platform_init(argc, argv)) platform_init(argc, argv);
return EXIT_FAILURE;
switch (argc) { switch (argc) {
case 1: return run_tests(1); case 1: return run_tests(1);

View File

@ -59,9 +59,7 @@ int main(int argc, char **argv) {
} }
#endif #endif
if (platform_init(argc, argv)) platform_init(argc, argv);
return EXIT_FAILURE;
argv = uv_setup_args(argc, argv); argv = uv_setup_args(argc, argv);
switch (argc) { switch (argc) {

View File

@ -67,13 +67,12 @@ void notify_parent_process(void) {
/* Do platform-specific initialization. */ /* Do platform-specific initialization. */
int platform_init(int argc, char **argv) { void platform_init(int argc, char **argv) {
/* Disable stdio output buffering. */ /* Disable stdio output buffering. */
setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0);
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
snprintf(executable_path, sizeof(executable_path), "%s", argv[0]); snprintf(executable_path, sizeof(executable_path), "%s", argv[0]);
return 0;
} }

View File

@ -43,7 +43,7 @@
/* Do platform-specific initialization. */ /* Do platform-specific initialization. */
int platform_init(int argc, char **argv) { void platform_init(int argc, char **argv) {
/* Disable the "application crashed" popup. */ /* Disable the "application crashed" popup. */
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX); SEM_NOOPENFILEERRORBOX);
@ -67,8 +67,6 @@ int platform_init(int argc, char **argv) {
setvbuf(stderr, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0);
strcpy(executable_path, argv[0]); strcpy(executable_path, argv[0]);
return 0;
} }

View File

@ -132,7 +132,7 @@ void print_lines(const char* buffer, size_t size, FILE* stream);
*/ */
/* Do platform-specific initialization. */ /* Do platform-specific initialization. */
int platform_init(int argc, char** argv); void platform_init(int argc, char** argv);
/* Invoke "argv[0] test-name [test-part]". Store process info in *p. Make sure /* Invoke "argv[0] test-name [test-part]". Store process info in *p. Make sure
* that all stdio output of the processes is buffered up. */ * that all stdio output of the processes is buffered up. */