X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Fdali-test-suite-utils%2Ftest-harness.cpp;h=b42b9f9ba0eb0c23f558adafb46f0002f09605d0;hp=c4a27d19fa7dd2c2d38caf7e79f3035a7a65e20b;hb=8675dfe3cca82e66f9d9b7fc4e227713f7a942d5;hpb=c1f9d7eac8ce290abc671fffab86e987c369c2c1 diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp index c4a27d1..b42b9f9 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ #include #include #include +#include namespace TestHarness { @@ -41,6 +42,20 @@ const char* basename(const char* path) return slash; } +void SuppressLogOutput() +{ + // Close stdout and stderr to suppress the log output + close(STDOUT_FILENO); // File descriptor number for stdout is 1 + close(STDERR_FILENO); // File descriptor number for stderr is 2 + + // The POSIX specification requires that /dev/null must be provided, + // The open function always chooses the lowest unused file descriptor + // It is sufficient for stdout to be writable. + open("/dev/null", O_WRONLY); // Redirect file descriptor number 1 (i.e. stdout) to /dev/null + // When stderr is opened it must be both readable and writable. + open("/dev/null", O_RDWR); // Redirect file descriptor number 2 (i.e. stderr) to /dev/null +} + int32_t RunTestCase( struct ::testcase_s& testCase ) { int32_t result = EXIT_STATUS_TESTCASE_FAILED; @@ -78,8 +93,7 @@ int32_t RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressO { if( suppressOutput ) { - close(STDOUT_FILENO); - close(STDERR_FILENO); + SuppressLogOutput(); } else { @@ -222,8 +236,7 @@ int32_t RunAllInParallel( const char* processName, ::testcase tc_array[], bool int32_t pid = fork(); if( pid == 0 ) // Child process { - close(STDOUT_FILENO); - close(STDERR_FILENO); + SuppressLogOutput(); exit( RunTestCase( tc_array[nextTestCase] ) ); } else if(pid == -1)