Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ant build with cmake #14

Merged
merged 54 commits into from
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a853310
Add support for building and testing with cmake
stephen-webb Oct 6, 2019
774ea16
Add support for building and testing with cmake
stephen-webb Oct 7, 2019
b472300
Simplify integration into vcpkg
stephen-webb Oct 11, 2019
e3000f6
Fix issues building on Linux
stephen-webb Oct 12, 2019
80a9fdb
Disable building tests by default to conform with vcpkg guidelines
stephen-webb Oct 13, 2019
d919ea1
Provide find modules for APR and APR-Util. Add the version resource t…
stephen-webb Jan 28, 2020
c244c28
Build examples when building tests
stephen-webb Jan 31, 2020
e64b7cf
Use cmake from maven to build and only use ant for site deployment an…
stephen-webb Jan 31, 2020
5b5ec13
Set release date to today.
stephen-webb Jan 31, 2020
a71f936
Set the letter case of find modules to that required by case sensitiv…
stephen-webb Jan 31, 2020
e5f8af1
Set the letter case of find modules to that required by case sensitiv…
stephen-webb Jan 31, 2020
704a80f
Merge branch 'master' of https://github.com/apache/logging-log4cxx
stephen-webb Jan 31, 2020
6c1e0b6
Set the letter case of find modules to that required by case sensitiv…
stephen-webb Jan 31, 2020
472d97b
Set the letter case of find modules to that required by case sensitiv…
stephen-webb Jan 31, 2020
5b81898
Set the letter case of find modules to that required by case sensitiv…
stephen-webb Jan 31, 2020
0504bc5
Merge branch 'master' of https://github.com/stephen-webb/logging-log4cxx
stephen-webb Jan 31, 2020
4ffba69
Merge https://github.com/apache/logging-log4cxx
stephen-webb Jan 31, 2020
c3146a5
Add JSON appender and test
stephen-webb Jan 31, 2020
73f7333
Add JSON appender and test
stephen-webb Jan 31, 2020
426660e
Merge https://github.com/apache/logging-log4cxx into replace-ant-buil…
stephen-webb Jan 31, 2020
f3edfc4
Merge branch 'master' of https://github.com/stephen-webb/logging-log4cxx
stephen-webb Jan 31, 2020
48c597b
Fix some test case failures
stephen-webb Jan 31, 2020
08d6176
Fix some test case failures
stephen-webb Jan 31, 2020
dc7dc14
Remove unused files
stephen-webb Jan 31, 2020
b3bec51
Remove unused files
stephen-webb Jan 31, 2020
7995db2
Merge branch 'replace-ant-build-with-cmake' of https://github.com/ste…
stephen-webb Jan 31, 2020
8dc8120
Fix some test case failures
stephen-webb Jan 31, 2020
4745721
Use automatic checks instead of options for log4cxx_private.h configu…
stephen-webb Feb 1, 2020
c4f1b3d
Provide install directory variables as defined by the GNU Coding Stan…
stephen-webb Feb 1, 2020
6862c5e
Use semantic versioning symbolic links in the installed target
stephen-webb Feb 1, 2020
f133149
Install a pkgconfig file on unix systems
stephen-webb Feb 1, 2020
d08e392
Fix failing defaultinittestcase
stephen-webb Feb 3, 2020
06875bd
Revert "Fix failing defaultinittestcase"
stephen-webb Feb 3, 2020
b9d9b0e
Fix failing defaultinittestcase
stephen-webb Feb 3, 2020
cd4a455
Only include smtpappendertestcase when libesmtp is available
stephen-webb Feb 6, 2020
d5b5c38
Run autoconf during packaging if the OS is unix
stephen-webb Feb 7, 2020
e0b4e4d
Remove ant build references from build instructions. Add instructions…
stephen-webb Feb 7, 2020
ac90504
Change to cmake-maven-plugin that works on Windows
stephen-webb Feb 7, 2020
6ae3567
Fix typo in instructions for building from source on Windows
stephen-webb Feb 7, 2020
d0c6cae
Allow maven to be used with generators that need to be told which con…
stephen-webb Feb 7, 2020
b971dd0
Make socketservertestcase work independently of ant build
stephen-webb Feb 8, 2020
a261ca7
Remove cpptasks as a dependency
stephen-webb Feb 8, 2020
84d3b60
Add platform specific instructions for cmake install
stephen-webb Feb 9, 2020
178598b
Allow tests on Windows to be run from ctest
stephen-webb Feb 9, 2020
2027010
Merge branch 'replace-ant-build-with-cmake' of https://github.com/ste…
stephen-webb Feb 9, 2020
c8eb659
Halt with an error if either APR or APR-Util cannot be found
stephen-webb Feb 9, 2020
c36fea0
Make the file render properly.
ams-tschoening Feb 9, 2020
bb9ab5f
Enhance support for paths with spaces by simply using a different div…
ams-tschoening Feb 9, 2020
e2c3533
Make the file render properly.
ams-tschoening Feb 9, 2020
05e107a
Allow the socketservertestcase to be run on Windows
stephen-webb Feb 10, 2020
0e5aee9
Allow the socketservertestcase to be built with Java 8
stephen-webb Feb 10, 2020
13a1eed
Fix abnormal termination fault in socketservertestcase. Remove C++11 …
stephen-webb Feb 10, 2020
af0134a
Prevent test case failures on Windows by excluding tests that require…
stephen-webb Feb 10, 2020
3775ffa
Prevent socketservertestcase failures when using Maven to build and test
stephen-webb Feb 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,51 +229,6 @@
</delete>
</target>

<target name="run-socketserver"
depends="clean-output"
description="Runs SocketServer test">
<property environment="env" />
<mkdir dir="${tests.output.dir}" />
<delete>
<fileset dir="${tests.output.dir}"
includes="*"
/>
</delete>
<mkdir dir="target/test-classes" />
<javac srcdir="src/test/java"
includes="org/apache/log4j/net/ShortSocketServer.java"
destdir="target/test-classes"
classpath="${log4j.jar}"
/>
<parallel>
<java classname="org.apache.log4j.net.ShortSocketServer"
fork="yes" dir="src/test/resources"
classpath="target/test-classes:${log4j.jar}">
<arg value="8" />
<arg value="input/socketServer" />
</java>
<sequential>
<sleep seconds="2" />
<exec executable="${testsuite.exe}"
dir="${tests.resources.dir}"
failonerror="true">
<arg value="-v" />
<arg value="socketservertestcase" />

<env key="LD_LIBRARY_PATH"
value="${log4cxx.lib.dir}:${apr.lib.dir}:${apr-util.lib.dir}:${env.LD_LIBRARY_PATH}"
/>
<env key="DYLD_LIBRARY_PATH"
value="${log4cxx.lib.dir}:${apr.lib.dir}:${apr-util.lib.dir}:${env.DYLD_LIBRARY_PATH}"
/>
<env key="Path"
value="${log4cxx.lib.dir};${env.Path}"
/>
</exec>
</sequential>
</parallel>
</target>

<target name="apidocs"
description="Build log4cxx manual">
<copy file="${base.dir}/src/site/doxy/Doxyfile.in"
Expand Down
6 changes: 5 additions & 1 deletion src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
add_subdirectory(cpp)
find_package(Java COMPONENTS Development)
if(Java_Development_FOUND)
add_subdirectory(java)
endif(Java_Development_FOUND)
add_subdirectory(cpp)
13 changes: 10 additions & 3 deletions src/test/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ foreach(testName IN LISTS ALL_LOG4CXX_TESTS)
COMMAND ${testName} -v
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../resources
)
set_tests_properties(${testName} PROPERTIES
ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2"
)

if(${testName} STREQUAL socketservertestcase)
set_tests_properties(socketservertestcase PROPERTIES
ENVIRONMENT "SOCKET_SERVER_COMMAND=$<JOIN:${START_SOCKET_SERVER_COMMAND}, >"
)
else()
set_tests_properties(${testName} PROPERTIES
ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2"
)
endif()
if(WIN32)
set_tests_properties(${testName} PROPERTIES ENVIRONMENT
"PATH=$<SHELL_PATH:$<TARGET_FILE_DIR:log4cxx>>$<SEMICOLON>$ENV{PATH}"
Expand Down
6 changes: 5 additions & 1 deletion src/test/cpp/net/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set(NET_TESTS
socketappendertestcase
sockethubappendertestcase
socketservertestcase
syslogappendertestcase
telnetappendertestcase
xmlsocketappendertestcase
Expand All @@ -14,4 +13,9 @@ endif(HAS_LIBESMPT)
foreach(fileName IN LISTS NET_TESTS)
add_executable(${fileName} "${fileName}.cpp")
endforeach()
if(Java_Development_FOUND)
add_executable(socketservertestcase socketserverstarter.cpp socketservertestcase.cpp)
add_dependencies(socketservertestcase test-classes)
list(APPEND NET_TESTS socketservertestcase)
endif(Java_Development_FOUND)
set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} ${NET_TESTS} PARENT_SCOPE)
108 changes: 108 additions & 0 deletions src/test/cpp/net/socketserverstarter.cpp
Original file line number Diff line number Diff line change
@@ -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)
ams-tschoening marked this conversation as resolved.
Show resolved Hide resolved
{
// 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));
ams-tschoening marked this conversation as resolved.
Show resolved Hide resolved
char* pcmd = apr_pstrdup(pool, cmd);
int i = 0;
for (; i < 14 && pcmd && *pcmd; ++i)
{
args[i] = pcmd;
if (NULL != (pcmd = strchr(pcmd, ' ')))
ams-tschoening marked this conversation as resolved.
Show resolved Hide resolved
{
while(' ' == *pcmd)
{
*pcmd = 0;
++pcmd;
}
}
}
args[i] = 0;
//fprintf(stdout, "starting=%s with %d arguments\n", args[0], i);
stat = apr_proc_create(&server_pid, args[0], args, NULL, attr, pool);
#endif


if (stat == APR_SUCCESS) // Allow server time to load
apr_sleep(1000000); // 1 seconds
}
else
fputs("The environment variable SOCKET_SERVER_COMMAND"
" must contain the server process path"
" followed by space separated command arguments\n", stderr);

LOGUNIT_ASSERT(stat == APR_SUCCESS);
}
};


LOGUNIT_TEST_SUITE_REGISTRATION(SocketServerStarter)

3 changes: 1 addition & 2 deletions src/test/cpp/net/socketservertestcase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "../logunit.h"
#include <log4cxx/spi/loggerrepository.h>


//Define INT64_C for compilers that don't have it
#if (!defined(INT64_C))
#define INT64_C(value) value ## LL
Expand Down Expand Up @@ -478,4 +477,4 @@ LOGUNIT_CLASS(SocketServerTestCase)
const File SocketServerTestCase::TEMP("output/temp");
const File SocketServerTestCase::FILTERED("output/filtered");

LOGUNIT_TEST_SUITE_REGISTRATION_DISABLED(SocketServerTestCase)
LOGUNIT_TEST_SUITE_REGISTRATION(SocketServerTestCase)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test really be enabled? While your CMAKE-build might handle things automatically, it might be more difficult for users without CMAKE. Took me a while to figure things out based on this commit myself and the test still fails currently...

set PATH=C:\Program Files\Java\jdk-8\bin;C:\Program Files (x86)\UnxUtils\usr\local\wbin;%PATH%
set TEST_PROJ=%cd%
set LOG4CXX_VER_BASE=..\..\..\..
set TEST_SRC=%LOG4CXX_VER_BASE%\src\src\test
set TEST_RES=%TEST_SRC%\resources

set TOTO=wonderful
set key1=value
set key2=value2

set log4j_CLASSPATH=%LOG4CXX_VER_BASE%\..\..\..\..\Java\log4j-1.2.17.jar
set SOCKET_SERVER_SOURCES=%TEST_SRC%\java\org\apache\log4j\net\ShortSocketServer.java
set SOCKET_SERVER_CLASSPATH=%TEST_RES%;%log4j_CLASSPATH%
set CLASSPATH=%SOCKET_SERVER_CLASSPATH%
set SOCKET_SERVER_COMMAND=C:\Program Files\Java\jdk-8\bin\java.exe;org.apache.log4j.net.ShortSocketServer;8;input/socketServer

pushd "%TEST_RES%"
javac -d "." -classpath "%log4j_CLASSPATH%" "%SOCKET_SERVER_SOURCES%"
"%TEST_PROJ%\Win32\Debug\out\%~n0.exe" %*
popd

goto :EOF

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling a testcase is needed when building multiple tests into a single executable. To run a disabled test case you then need to add it as a parameter.
The socketservertestcase excutable has only one test case so I do not think it is appropriate to disable it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is not about different executables, but that this one test case only requires additional Java and is difficult to setup. It has been disabled in the past for a long time already:

b279aa7#diff-78b9ec5d590a88f742877f2f096c52a9R51

18 changes: 18 additions & 0 deletions src/test/java/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include(FetchContent)
FetchContent_Declare(log4j
URL https://www-us.apache.org/dist/logging/log4j/1.2.17/log4j-1.2.17.tar.gz
URL_HASH MD5=8218714e41ee0c6509dcfeafa2e1f53f
)
FetchContent_GetProperties(log4j)
if(NOT log4j_POPULATED)
FetchContent_Populate(log4j)
endif()
set(log4j_CLASSPATH "${log4j_SOURCE_DIR}/log4j-1.2.17.jar" )
set(SOCKET_SERVER_SOURCES org/apache/log4j/net/ShortSocketServer.java)
add_custom_target(test-classes
COMMAND ${Java_JAVAC_EXECUTABLE} -d ${CMAKE_CURRENT_BINARY_DIR}
--class-path "${log4j_CLASSPATH}" ${SOCKET_SERVER_SOURCES}
ams-tschoening marked this conversation as resolved.
Show resolved Hide resolved
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set(SOCKET_SERVER_CLASSPATH "${CMAKE_CURRENT_BINARY_DIR}:${log4j_CLASSPATH}" )
set(START_SOCKET_SERVER_COMMAND ${Java_JAVA_EXECUTABLE} --class-path ${SOCKET_SERVER_CLASSPATH} org.apache.log4j.net.ShortSocketServer 8 input/socketServer PARENT_SCOPE)