Fix command line parameters processing of TestLog

Change 7b7791a40f for issue 1666 has added functionality
to TestLog by adding extra parameters to the constructor.
The change, however, has patchied only one of the uses of the
class, breaking the other 3 uses of it. This has caused the
log flags to be wrong, and the new functionality introduced
by 7b7791a40f to not work, as expected.

This change fixes the rest of the locations and is adding one
more constructor for the TestLog class targeted for use by Android.

Components: Framework

VK-GL-CTS issue: 1887

Change-Id: I8d52d40ee5dffb120b8a4945b0f865c8f3e7b7dd
diff --git a/external/openglcts/modules/runner/glcTestRunner.cpp b/external/openglcts/modules/runner/glcTestRunner.cpp
index 0ad3c78..fd55b91 100644
--- a/external/openglcts/modules/runner/glcTestRunner.cpp
+++ b/external/openglcts/modules/runner/glcTestRunner.cpp
@@ -48,7 +48,7 @@
 public:
 	RunSession(tcu::Platform& platform, tcu::Archive& archive, const int numArgs, const char* const* args)
 		: m_cmdLine(numArgs, args)
-		, m_log(m_cmdLine.getLogFileName(), m_cmdLine.getLogFlags())
+		, m_log(m_cmdLine.getLogFileName(), (numArgs - 1), (char**)(args + 1), m_cmdLine.getLogFlags())
 		, m_app(platform, archive, m_log, m_cmdLine)
 	{
 	}
diff --git a/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp b/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp
index db95b77..a35bf44 100644
--- a/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp
+++ b/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp
@@ -667,7 +667,7 @@
 	try
 	{
 		tcu::DirArchive			archive					(".");
-		tcu::TestLog			log						(deqpCmdLine.getLogFileName(), deqpCmdLine.getLogFlags());
+		tcu::TestLog			log					(deqpCmdLine.getLogFileName(), (argc - 1), (char **)(argv + 1), deqpCmdLine.getLogFlags());
 		tcu::Platform			platform;
 		tcu::TestContext		testCtx					(platform, archive, log, deqpCmdLine, DE_NULL);
 		vk::SpirvVersion		baselineSpirvVersion	= vk::getBaselineSpirvVersion(cmdLine.getOption<opt::VulkanVersion>());
diff --git a/framework/common/tcuTestLog.cpp b/framework/common/tcuTestLog.cpp
index 277d896..8b9fc2d 100644
--- a/framework/common/tcuTestLog.cpp
+++ b/framework/common/tcuTestLog.cpp
@@ -21,6 +21,7 @@
  * \brief Test Log C++ Wrapper.
  *//*--------------------------------------------------------------------*/
 
+#include "deCommandLine.h"
 #include "tcuTestLog.hpp"
 #include "tcuTextureUtil.hpp"
 #include "tcuSurface.hpp"
@@ -187,6 +188,20 @@
 		throw ResourceError(std::string("Failed to open test log file '") + fileName + "'");
 }
 
+TestLog::TestLog (const char* fileName, const std::string& cmdLine, deUint32 flags)
+{
+
+	deCommandLine* parsedCmdLine = deCommandLine_parse(cmdLine.c_str());
+	if (!parsedCmdLine)
+		throw std::bad_alloc();
+
+	m_log = qpTestLog_createFileLog(fileName, parsedCmdLine->numArgs, parsedCmdLine->args, flags);
+	deCommandLine_destroy(parsedCmdLine);
+
+	if (!m_log)
+		throw ResourceError(std::string("Failed to open test log file '") + fileName + "'");
+}
+
 TestLog::~TestLog (void)
 {
 	qpTestLog_destroy(m_log);
diff --git a/framework/common/tcuTestLog.hpp b/framework/common/tcuTestLog.hpp
index 6ba0524..8323a8b 100644
--- a/framework/common/tcuTestLog.hpp
+++ b/framework/common/tcuTestLog.hpp
@@ -103,6 +103,7 @@
 	typedef LogNumber<deInt64>		Integer;
 
 	explicit			TestLog					(const char* fileName, int argc = 0, char** argv = DE_NULL, deUint32 flags = 0);
+	explicit			TestLog					(const char* fileName, const std::string& cmdLine, deUint32 flags = 0);
 						~TestLog				(void);
 
 	MessageBuilder		operator<<				(const BeginMessageToken&);
diff --git a/framework/platform/android/tcuAndroidTestActivity.cpp b/framework/platform/android/tcuAndroidTestActivity.cpp
index b8cff3c..cfe53cb 100644
--- a/framework/platform/android/tcuAndroidTestActivity.cpp
+++ b/framework/platform/android/tcuAndroidTestActivity.cpp
@@ -38,12 +38,12 @@
 
 // TestThread
 
-TestThread::TestThread (NativeActivity& activity, const CommandLine& cmdLine)
+TestThread::TestThread (NativeActivity& activity, const std::string& cmdLineString, const CommandLine& cmdLine)
 	: RenderThread	(activity)
 	, m_cmdLine		(cmdLine)
 	, m_platform	(activity)
 	, m_archive		(activity.getNativeActivity()->assetManager)
-	, m_log			(m_cmdLine.getLogFileName(), m_cmdLine.getLogFlags())
+	, m_log			(m_cmdLine.getLogFileName(), cmdLineString, m_cmdLine.getLogFlags())
 	, m_app			(m_platform, m_archive, m_log, m_cmdLine)
 	, m_finished	(false)
 {
@@ -87,7 +87,7 @@
 TestActivity::TestActivity (ANativeActivity* activity)
 	: RenderActivity	(activity)
 	, m_cmdLine			(getIntentStringExtra(activity, "cmdLine"))
-	, m_testThread		(*this, m_cmdLine)
+	, m_testThread		(*this, getIntentStringExtra(activity, "cmdLine"), m_cmdLine)
 	, m_started			(false)
 {
 	// Set initial orientation.
diff --git a/framework/platform/android/tcuAndroidTestActivity.hpp b/framework/platform/android/tcuAndroidTestActivity.hpp
index 58c28e6..2962c18 100644
--- a/framework/platform/android/tcuAndroidTestActivity.hpp
+++ b/framework/platform/android/tcuAndroidTestActivity.hpp
@@ -39,7 +39,7 @@
 class TestThread : public RenderThread
 {
 public:
-							TestThread					(NativeActivity& activity, const CommandLine& cmdLine);
+							TestThread					(NativeActivity& activity, const std::string& cmdLineString, const CommandLine& cmdLine);
 							~TestThread					(void);
 
 	void					run							(void);