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_r376807031
########## 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: `;` is difficult on Windows, because it's used as divider for the Java-classpath already, while `:` is difficult on non-Windows, because that is used as divider for Java-classpaths. Might be best to not embed the classpath into the command at all and use [CLASSPATH](https://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html) environment variable instead? ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
