summaryrefslogtreecommitdiffstats
path: root/tools/slang-unit-test/unit-test-process.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-11-24 09:34:05 -0500
committerGitHub <noreply@github.com>2021-11-24 09:34:05 -0500
commitbdc61bb8db321a8d788aa739b889354540a49ee0 (patch)
tree16c564282a28d69e77d51855a41f11bdfa80fded /tools/slang-unit-test/unit-test-process.cpp
parent9e084ffab37c276d40931a58633041a2e10de623 (diff)
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.
Diffstat (limited to 'tools/slang-unit-test/unit-test-process.cpp')
-rw-r--r--tools/slang-unit-test/unit-test-process.cpp51
1 files changed, 24 insertions, 27 deletions
diff --git a/tools/slang-unit-test/unit-test-process.cpp b/tools/slang-unit-test/unit-test-process.cpp
index 548ef168f..77f03ddee 100644
--- a/tools/slang-unit-test/unit-test-process.cpp
+++ b/tools/slang-unit-test/unit-test-process.cpp
@@ -2,6 +2,7 @@
#include "../../source/core/slang-string-util.h"
#include "../../source/core/slang-process-util.h"
+
#include "../../source/core/slang-io.h"
#include "../../source/core/slang-http.h"
#include "../../source/core/slang-random-generator.h"
@@ -10,22 +11,30 @@
using namespace Slang;
+static SlangResult _createProcess(UnitTestContext* context, const char* toolName, const List<String>* optArgs, RefPtr<Process>& outProcess)
+{
+ CommandLine cmdLine;
+ cmdLine.setExecutable(context->executableDirectory, "test-process");
+ cmdLine.addArg(toolName);
+ if (optArgs)
+ {
+ cmdLine.m_args.addRange(optArgs->getBuffer(), optArgs->getCount());
+ }
+
+ SLANG_RETURN_ON_FAIL(Process::create(cmdLine, Process::Flag::AttachDebugger, outProcess));
+
+ return SLANG_OK;
+}
+
static SlangResult _httpReflectTest(UnitTestContext* context)
{
SlangResult finalRes = SLANG_OK;
RefPtr<Process> process;
-
- {
- CommandLine cmdLine;
- cmdLine.setExecutable(context->executableDirectory, "test-proxy");
- cmdLine.addArg("http-reflect");
- SLANG_RETURN_ON_FAIL(Process::create(cmdLine, Process::Flag::AttachDebugger, process));
- }
+ SLANG_RETURN_ON_FAIL(_createProcess(context, "http-reflect", nullptr, process));
Stream* writeStream = process->getStream(Process::StreamType::StdIn);
RefPtr<BufferedReadStream> readStream( new BufferedReadStream(process->getStream(Process::StreamType::StdOut)));
-
RefPtr<HTTPPacketConnection> connection = new HTTPPacketConnection(readStream, writeStream);
RefPtr<RandomGenerator> rand = RandomGenerator::create(10000);
@@ -81,32 +90,27 @@ static SlangResult _httpReflectTest(UnitTestContext* context)
static SlangResult _countTest(UnitTestContext* context, Index size, Index crashIndex = -1)
{
- RefPtr<Process> process;
-
/* Here we are trying to test what happens if the server produces a large amount of data, and
we just wait for termination. Do we receive all of the data irrespective of how much there is? */
+ List<String> args;
{
- CommandLine cmdLine;
-
- cmdLine.setExecutable(context->executableDirectory, "test-proxy");
- cmdLine.addArg("count");
-
StringBuilder buf;
buf << size;
- cmdLine.addArg(buf);
+ args.add(buf);
if (crashIndex >= 0)
{
buf.Clear();
buf << crashIndex;
- cmdLine.addArg(buf);
+ args.add(buf);
}
-
- SLANG_RETURN_ON_FAIL(Process::create(cmdLine, Process::Flag::AttachDebugger, process));
}
+ RefPtr<Process> process;
+ SLANG_RETURN_ON_FAIL(_createProcess(context, "count", &args, process));
+
ExecuteResult exeRes;
#if 0
@@ -156,12 +160,7 @@ static SlangResult _countTests(UnitTestContext* context)
static SlangResult _reflectTest(UnitTestContext* context)
{
RefPtr<Process> process;
- {
- CommandLine cmdLine;
- cmdLine.setExecutable(context->executableDirectory, "test-proxy");
- cmdLine.addArg("reflect");
- SLANG_RETURN_ON_FAIL(Process::create(cmdLine, Process::Flag::AttachDebugger, process));
- }
+ SLANG_RETURN_ON_FAIL(_createProcess(context, "reflect", nullptr, process));
// Write a bunch of stuff to the stream
Stream* readStream = process->getStream(Process::StreamType::StdOut);
@@ -191,8 +190,6 @@ static SlangResult _reflectTest(UnitTestContext* context)
SLANG_UNIT_TEST(CommandLineProcess)
{
SLANG_CHECK(SLANG_SUCCEEDED(_countTests(unitTestContext)));
-
SLANG_CHECK(SLANG_SUCCEEDED(_reflectTest(unitTestContext)));
-
SLANG_CHECK(SLANG_SUCCEEDED(_httpReflectTest(unitTestContext)));
}