From bdc61bb8db321a8d788aa739b889354540a49ee0 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 24 Nov 2021 09:34:05 -0500 Subject: Remove test-proxy (#2027) * #include an absolute path didn't work - because paths were taken to always be relative. * Use 'Process' to communicate with an command line tool. * Remove slang-win-stream * Tidy up windows ProcessUtil. * First version of BufferedReadStream. * Windows working IPC for steams. * Test proxy count option. * Split Process/ProcessUtil. Process is platform dependant. ProcessUtil are functions that are platform independent. * First implementation of Unix Process interface. * Unix process compiles on cygwin. * Fix typo in unix process. * Separate unix pipe stream error of invalid access, from pipe availability. * Fix in standard line extraction. * Make fd non blocking. * Fix issues with Windows Process streams. * Added UnixPipe. * Some fixes around UnixPipeStream. * Make a unix stream closed explicit. * Hack to debug linux process/stream. * Revert to old linux pipe handling. * Pass executable path for unit tests. Split out CommandLine into own source. * Small improvements in process/command line. * Check process behavior with crash. * Make stderr and stdout unbuffered for crash testing. * Only turn disable buffering in crash test. * Disable crash test on CI. * Fix crash on clang/linux. * Enable crash test. Remove _appendBuffer as can use StreamUtil functionality. * Added inital processing for http headers. * Small improvements to HttpHeader. * First pass HTTPPacketConnection working on windows. * Enable other Process communication tests. * Update comments. * WIP JSON RPC. * Add terminate to Process. Made JSONRPC a Util. * Small tidy up around HTTPPacketConnection. * Improve process termination options. * WIP for test-server. * Add diagnostics error handling to test-server. * Improved JSON support. Parsing/creating JSON-RPC messages. * WIP JSONRPC parsing. * First pass RttiInfo support. * WIP converting between JSON/native types. * Project files. * Split out RttiUtil. Made RttiInfo constuction thread safe. * WIP RTTI<->JSON. * Add diagnostics to JSON<->native conversions. * Make RttiInfo for structs globals. Avoids problem around derived types (like pointers), being able to cause an abort. * Add pointer support to RTTI. Fixed some compilation issues on linux. * Add fixed array support. * Added Rtti unit test. * Add rtti unit test. * Split out quoted/unquoted key handling. Fix bugs in JSON value/container. Added JSON native test. * Make default array allocator use malloc/free. Remove the new[] handler (doesn't work on visuals studio). * Fix for linux warning. * Remove some test code. * Fix issues on x86 win. * Fix warning on aarch64. * Fix some bugs in JSON parsing/handling. Make Rtti work copy/dtor/ctor struct types. * Testing JSON<->native with fixed array. Make makeArrayView explicit if it's just a single value. Added array type. * Fix getting arrayView. * Improve JSON diagnostic name. * First pass refactor using Rtti for JSON RPC. * First pass of test server using RTTI/JSON-RPC. * Added JSONRPCConnection. * Fix some naming issues. * First pass of test-server working. * Added unit test support for JSON-RPC test server. * Fix compilation issues on linux around template handling. * Typo fix. * Fix a bug around SourceLoc lookup with JSONContainer. * Set the console type to console for ISlangWriters. * Small improvements to test-server. * Small improvements in test-server. * Small fix. * Remove test-proxy. Make test-process a process that can be used to unit test 'Process'. Adding mechanism to control spawning that will create a new process for every test. * Ability to remove source manager for JSONValue. --- tools/slang-test/slang-test-main.cpp | 69 +++++++++--------------------------- 1 file changed, 17 insertions(+), 52 deletions(-) (limited to 'tools/slang-test/slang-test-main.cpp') diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 000ee462c..9648b2ed1 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -655,8 +655,15 @@ Result spawnAndWaitProxy(TestContext* context, const String& testPath, const Com return res; } -static Result _executeRPC(TestContext* context, const UnownedStringSlice& method, const RttiInfo* rttiInfo, const void* args, ExecuteResult& outRes) +static Result _executeRPC(TestContext* context, SpawnType spawnType, const UnownedStringSlice& method, const RttiInfo* rttiInfo, const void* args, ExecuteResult& outRes) { + // If we are 'fully isolated', we cannot share a test server. + // So tear down the RPC connection if there is one currently. + if (spawnType == SpawnType::UseFullyIsolatedTestServer) + { + context->destroyRPCConnection(); + } + JSONRPCConnection* rpcConnection = context->getOrCreateJSONRPCConnection(); if (!rpcConnection) { @@ -693,12 +700,12 @@ static Result _executeRPC(TestContext* context, const UnownedStringSlice& method } template -static Result _executeRPC(TestContext* context, const UnownedStringSlice& method, const T* msg, ExecuteResult& outRes) +static Result _executeRPC(TestContext* context, SpawnType spawnType, const UnownedStringSlice& method, const T* msg, ExecuteResult& outRes) { - return _executeRPC(context, method, GetRttiInfo::get(), (const void*)msg, outRes); + return _executeRPC(context, spawnType, method, GetRttiInfo::get(), (const void*)msg, outRes); } -Result spawnAndWaitTestServer(TestContext* context, const String& testPath, const CommandLine& inCmdLine, ExecuteResult& outRes) +Result spawnAndWaitTestServer(TestContext* context, SpawnType spawnType, const String& testPath, const CommandLine& inCmdLine, ExecuteResult& outRes) { String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executable); @@ -708,7 +715,7 @@ Result spawnAndWaitTestServer(TestContext* context, const String& testPath, cons args.toolName = exeName; args.args = inCmdLine.m_args; - return _executeRPC(context, TestServerProtocol::ExecuteToolTestArgs::g_methodName, &args, outRes); + return _executeRPC(context, spawnType, TestServerProtocol::ExecuteToolTestArgs::g_methodName, &args, outRes); } static SlangResult _extractArg(const CommandLine& cmdLine, const String& argName, String& outValue) @@ -1063,14 +1070,10 @@ ToolReturnCode spawnAndWait(TestContext* context, const String& testPath, SpawnT spawnResult = spawnAndWaitSharedLibrary(context, testPath, cmdLine, outExeRes); break; } - case SpawnType::UseProxy: - { - spawnResult = spawnAndWaitProxy(context, testPath, cmdLine, outExeRes); - break; - } + case SpawnType::UseFullyIsolatedTestServer: case SpawnType::UseTestServer: { - spawnResult = spawnAndWaitTestServer(context, testPath, cmdLine, outExeRes); + spawnResult = spawnAndWaitTestServer(context, spawnType, testPath, cmdLine, outExeRes); break; } default: break; @@ -3501,46 +3504,8 @@ static SlangResult runUnitTestModule(TestContext* context, TestOptions& testOpti { if (testPassesCategoryMask(context, testOptions)) { - if (spawnType == SpawnType::UseProxy) - { - CommandLine cmdLine; - - // The 'command' is the module - cmdLine.setExecutablePath(Path::combine(context->exeDirectoryPath, moduleName)); - - // Pass the test name / index - cmdLine.addArg(testName); - - { - StringBuilder buf; - buf << i; - cmdLine.addArg(buf.ProduceString()); - } - - // Pass the enabled apis - { - StringBuilder buf; - buf << context->options.enabledApis; - cmdLine.addArg(buf.ProduceString()); - } - - { - TestReporter::TestScope scopeTest(reporter, testOptions.command); - ExecuteResult exeRes; - - const auto testResult = _asTestResult(spawnAndWait(context, filePath, spawnType, cmdLine, exeRes)); - - // If the test fails, output any output - which might give information about individual tests that have failed. - if (testResult == TestResult::Fail) - { - String output = getOutput(exeRes); - reporter->message(TestMessageType::TestFailure, output.getBuffer()); - } - - reporter->addResult(testResult); - } - } - else if (spawnType == SpawnType::UseTestServer) + if (spawnType == SpawnType::UseTestServer || + spawnType == SpawnType::UseFullyIsolatedTestServer) { TestServerProtocol::ExecuteUnitTestArgs args; args.enabledApis = context->options.enabledApis; @@ -3551,7 +3516,7 @@ static SlangResult runUnitTestModule(TestContext* context, TestOptions& testOpti TestReporter::TestScope scopeTest(reporter, testOptions.command); ExecuteResult exeRes; - SlangResult rpcRes = _executeRPC(context, TestServerProtocol::ExecuteUnitTestArgs::g_methodName, &args, exeRes); + SlangResult rpcRes = _executeRPC(context, spawnType, TestServerProtocol::ExecuteUnitTestArgs::g_methodName, &args, exeRes); const auto testResult = _asTestResult(ToolReturnCode(exeRes.resultCode)); // If the test fails, output any output - which might give information about individual tests that have failed. -- cgit v1.2.3