You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2020/02/09 19:33:36 UTC

[GitHub] [logging-log4cxx] ams-tschoening commented on a change in pull request #14: Replace ant build with cmake

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

 ##########
 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));
 
 Review comment:
   What's the hard-coded `15` and `14` in the loop for?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services