stephen-webb commented on a change in pull request #14: Replace ant build with 
cmake
URL: https://github.com/apache/logging-log4cxx/pull/14#discussion_r376843651
 
 

 ##########
 File path: src/test/cpp/net/socketserverstarter.cpp
 ##########
 @@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../logunit.h"
+
+#include <apr_thread_proc.h>
+#include <apr_env.h>
+#include <apr_file_io.h>
+#include <apr_strings.h>
+#include <apr_time.h>
+#include <log4cxx/helpers/pool.h>
+
+
+using namespace log4cxx;
+
+LOGUNIT_CLASS(SocketServerStarter)
+{
+   LOGUNIT_TEST_SUITE(SocketServerStarter);
+      LOGUNIT_TEST(startServer);
+   LOGUNIT_TEST_SUITE_END();
+   
+public:
+   void setUp()
+   {
+   }
+
+   void tearDown()
+   {
+   }
+   
+   void startServer()
+   {
+     helpers::Pool p;
+     apr_pool_t* pool = p.getAPRPool();
+     char* cmd = NULL;
+     apr_status_t stat = apr_env_get(&cmd, "SOCKET_SERVER_COMMAND", pool);
+
+     if (cmd && *cmd)
+     {
+          // prepare to launch the server
+          //
+          apr_proc_t server_pid;
+          apr_procattr_t* attr = NULL;
+          stat = apr_procattr_create(&attr, pool);
+          LOGUNIT_ASSERT(stat == APR_SUCCESS);
+          stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_NO_PIPE, 
APR_NO_PIPE);
+          LOGUNIT_ASSERT(stat == APR_SUCCESS);
+
+          //fprintf(stdout, "SOCKET_SERVER_COMMAND=%s\n", cmd);
+#ifdef SHELL_CMD_TYPE_WORKS
+          stat = apr_procattr_cmdtype_set(attr, APR_SHELLCMD);
+          LOGUNIT_ASSERT(stat == APR_SUCCESS);
+          stat = apr_proc_create(&server_pid, cmd, NULL, NULL, attr, pool);
+#else
+          stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM);
+          LOGUNIT_ASSERT(stat == APR_SUCCESS);
+          // convert the space separated cmd string to the argument list
+          //
+          char** args = (char**)apr_palloc(pool, 15 * sizeof(*args));
+          char* pcmd = apr_pstrdup(pool, cmd);
+          int i = 0;
+          for (; i < 14 && pcmd && *pcmd; ++i)
+          {
+              args[i] = pcmd;
+              if (NULL != (pcmd = strchr(pcmd, ' ')))
 
 Review comment:
   To avoid issues with ';' processing, I have added the capability to load the 
command parameters from a file (one per line) into socketserverstarter. 
   I now use this technique when running the socketservertestcase from ctest.
   I have left the SOCKET_SERVER_COMMAND as space separated with simple support 
for quoted arguments

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to