From d3b9dca285cd4642f676d4e7642ac2e8e55eb836 Mon Sep 17 00:00:00 2001 From: Roger Meier Date: Fri, 24 Jun 2011 14:01:10 +0000 Subject: [PATCH] THRIFT-457 test/cpp makefiles do not honor --prefix configuration setting git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1139309 13f79535-47bb-0310-9956-ffa450edef68 --- configure.ac | 1 + test/Makefile.am | 4 + test/cpp/Makefile.am | 112 ++++++++++++++++++ test/cpp/Stress-test.mk | 71 ----------- test/cpp/Thrift-test.mk | 78 ------------ test/cpp/src/{main.cpp => StressTest.cpp} | 0 ...{nb-main.cpp => StressTestNonBlocking.cpp} | 0 test/cpp/src/TestClient.cpp | 6 +- test/cpp/src/TestServer.cpp | 21 +++- 9 files changed, 139 insertions(+), 154 deletions(-) create mode 100755 test/cpp/Makefile.am delete mode 100644 test/cpp/Stress-test.mk delete mode 100644 test/cpp/Thrift-test.mk rename test/cpp/src/{main.cpp => StressTest.cpp} (100%) rename test/cpp/src/{nb-main.cpp => StressTestNonBlocking.cpp} (100%) diff --git a/configure.ac b/configure.ac index 48f93b5c..ad926b07 100644 --- a/configure.ac +++ b/configure.ac @@ -474,6 +474,7 @@ AC_CONFIG_FILES([ lib/py/Makefile lib/rb/Makefile test/Makefile + test/cpp/Makefile test/hs/Makefile test/py/Makefile test/py.twisted/Makefile diff --git a/test/Makefile.am b/test/Makefile.am index ae114040..5ca20d0c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -19,6 +19,10 @@ SUBDIRS = +if WITH_CPP +SUBDIRS += cpp +endif + if WITH_PYTHON SUBDIRS += py SUBDIRS += py.twisted diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am new file mode 100755 index 00000000..a828e579 --- /dev/null +++ b/test/cpp/Makefile.am @@ -0,0 +1,112 @@ +# +# 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. +# +noinst_LTLIBRARIES = libtestgencpp.la libstresstestgencpp.la +nodist_libtestgencpp_la_SOURCES = \ + gen-cpp/ThriftTest_constants.cpp \ + gen-cpp/ThriftTest_types.cpp \ + gen-cpp/ThriftTest_constants.h \ + gen-cpp/ThriftTest_types.h \ + gen-cpp/ThriftTest_types.tcc \ + gen-cpp/ThriftTest.tcc + +libtestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la + +nodist_libstresstestgencpp_la_SOURCES = \ + gen-cpp/StressTest_constants.cpp \ + gen-cpp/StressTest_types.cpp \ + gen-cpp/StressTest_constants.h \ + gen-cpp/StressTest_types.h \ + gen-cpp/Service.cpp \ + gen-cpp/Service.h + +libstresstestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la + +check_PROGRAMS = \ + TestServer \ + TestClient \ + StressTest \ + StressTestNonBlocking + +# we currently do not run the testsuite, stop c++ server issue +# TESTS = \ +# $(check_PROGRAMS) + +TestServer_SOURCES = \ + src/TestServer.cpp + +TestServer_LDADD = \ + libtestgencpp.la \ + $(top_builddir)/lib/cpp/libthrift.la \ + $(top_builddir)/lib/cpp/libthriftz.la \ + $(top_builddir)/lib/cpp/libthriftnb.la \ + -levent -lboost_program_options + +TestClient_SOURCES = \ + src/TestClient.cpp + +TestClient_LDADD = \ + libtestgencpp.la \ + $(top_builddir)/lib/cpp/libthrift.la \ + $(top_builddir)/lib/cpp/libthriftz.la \ + $(top_builddir)/lib/cpp/libthriftnb.la \ + -levent -lboost_program_options + +StressTest_SOURCES = \ + src/StressTest.cpp + +StressTest_LDADD = \ + libstresstestgencpp.la \ + $(top_builddir)/lib/cpp/libthrift.la + +StressTestNonBlocking_SOURCES = \ + src/StressTestNonBlocking.cpp + +StressTestNonBlocking_LDADD = \ + libstresstestgencpp.la \ + $(top_builddir)/lib/cpp/libthriftnb.la \ + -levent +# +# Common thrift code generation rules +# +THRIFT = $(top_builddir)/compiler/cpp/thrift + +gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp: $(top_srcdir)/test/ThriftTest.thrift + $(THRIFT) --gen cpp:templates $< + +gen-cpp/ThriftTest.cpp gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp: $(top_srcdir)/test/StressTest.thrift + $(THRIFT) --gen cpp $< + +INCLUDES = \ + -I$(top_srcdir)/lib/cpp/src -Igen-cpp + +AM_CPPFLAGS = $(BOOST_CPPFLAGS) +AM_CXXFLAGS = -Wall + +clean-local: + $(RM) -r gen-cpp + +EXTRA_DIST = \ + src/TestClient.cpp \ + src/TestServer.cpp \ + src/StressTest.cpp \ + src/StressTestNonBlocking.cpp \ + realloc/realloc_test.c \ + realloc/Makefile + + diff --git a/test/cpp/Stress-test.mk b/test/cpp/Stress-test.mk deleted file mode 100644 index 049bcb8f..00000000 --- a/test/cpp/Stress-test.mk +++ /dev/null @@ -1,71 +0,0 @@ -# -# 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. -# - -ifndef thrift_home -thrift_home=../.. -endif #thrift_home - -target: all - -ifndef boost_home -#boost_home=../../../../../thirdparty/boost_1_33_1 -boost_home=/usr/local/include/boost-1_33_1 -endif #boost_home -target: all - -include_paths = $(thrift_home)/lib/cpp/src \ - $(thrift_home)/lib/cpp \ - $(thrift_home)/ \ - $(boost_home) - -include_flags = $(patsubst %,-I%, $(include_paths)) - -# Tools -ifndef THRIFT -THRIFT = ../../compiler/cpp/thrift -endif # THRIFT - -CC = g++ -LD = g++ - -# Compiler flags -DCFL = -Wall -O3 -g -I./gen-cpp $(include_flags) -L$(thrift_home)/lib/cpp/.libs -lthrift -lthriftnb -levent -CFL = -Wall -O3 -I./gen-cpp $(include_flags) -L$(thrift_home)/lib/cpp/.libs -lthrift -lthriftnb -levent - -all: stress-test stress-test-nb - -debug: stress-test-debug stress-test-debug-nb - -stubs: ../StressTest.thrift - $(THRIFT) --gen cpp --gen php ../StressTest.thrift - -stress-test-debug-nb: stubs - $(CC) -o stress-test-nb $(DCFL) src/nb-main.cpp ./gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp - -stress-test-nb: stubs - $(CC) -o stress-test-nb $(CFL) src/nb-main.cpp ./gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp - -stress-test-debug: stubs - $(CC) -o stress-test $(DCFL) src/main.cpp ./gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp - -stress-test: stubs - $(CC) -o stress-test $(CFL) src/main.cpp ./gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp - -clean: - rm -fr stress-test stress-test-nb gen-cpp diff --git a/test/cpp/Thrift-test.mk b/test/cpp/Thrift-test.mk deleted file mode 100644 index e0a624cb..00000000 --- a/test/cpp/Thrift-test.mk +++ /dev/null @@ -1,78 +0,0 @@ -# -# 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. -# - -# Makefile for Thrift test project. -# Default target is everything - -ifndef thrift_home -thrift_home=../.. -endif #thrift_home - -target: all - -ifndef boost_home -#boost_home=../../../../../thirdparty/boost_1_33_1 -boost_home=/usr/local/include/boost-1_33_1 -endif #boost_home -target: all - -include_paths = $(thrift_home)/lib/cpp/src \ - $(boost_home) - -include_flags = $(patsubst %,-I%, $(include_paths)) - -# Tools -ifndef THRIFT -THRIFT = ../../compiler/cpp/thrift -endif # THRIFT - -CC = g++ -LD = g++ - -# Compiler flags -DCFL = -Wall -O3 -g -I. -I./gen-cpp $(include_flags) -L$(thrift_home)/lib/cpp/.libs -lthrift -lthriftnb -levent -lboost_program_options -LFL = -L$(thrift_home)/lib/cpp/.libs -lthrift -lthriftnb -levent -lboost_program_options -CCFL = -Wall -O3 -I. -I./gen-cpp $(include_flags) -CFL = $(CCFL) $(LFL) - -all: server client - -debug: server-debug client-debug - -stubs: ../ThriftTest.thrift - $(THRIFT) --gen cpp:templates ../ThriftTest.thrift - -server-debug: stubs - $(CC) -o TestServer $(DCFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ./gen-cpp/ThriftTest_constants.cpp - -client-debug: stubs - $(CC) -o TestClient $(DCFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ./gen-cpp/ThriftTest_constants.cpp - -server: stubs - $(CC) -o TestServer $(CFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ./gen-cpp/ThriftTest_constants.cpp - -client: stubs - $(CC) -o TestClient $(CFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ./gen-cpp/ThriftTest_constants.cpp - -small: - $(THRIFT) --gen cpp:templates ../SmallTest.thrift - $(CC) -c $(CCFL) ./gen-cpp/SmallService.cpp ./gen-cpp/SmallTest_types.cpp - -clean: - rm -fr *.o TestServer TestClient gen-cpp diff --git a/test/cpp/src/main.cpp b/test/cpp/src/StressTest.cpp similarity index 100% rename from test/cpp/src/main.cpp rename to test/cpp/src/StressTest.cpp diff --git a/test/cpp/src/nb-main.cpp b/test/cpp/src/StressTestNonBlocking.cpp similarity index 100% rename from test/cpp/src/nb-main.cpp rename to test/cpp/src/StressTestNonBlocking.cpp diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index 23d7dcd8..ceea8389 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -17,6 +17,9 @@ * under the License. */ +#define __STDC_FORMAT_MACROS +#include + #include #include #include @@ -32,9 +35,6 @@ #include "ThriftTest.h" -#define __STDC_FORMAT_MACROS -#include - using namespace boost; using namespace std; using namespace apache::thrift; diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index bb3cd434..9ba05098 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -17,6 +17,9 @@ * under the License. */ +#define __STDC_FORMAT_MACROS +#include + #include #include #include @@ -39,8 +42,6 @@ #include -#define __STDC_FORMAT_MACROS -#include #include using namespace std; @@ -114,6 +115,22 @@ class TestHandler : public ThriftTestIf { out = thing; } + void testStringMap(map &out, const map &thing) { + printf("testMap({"); + map::const_iterator m_iter; + bool first = true; + for (m_iter = thing.begin(); m_iter != thing.end(); ++m_iter) { + if (first) { + first = false; + } else { + printf(", "); + } + printf("%s => %s", (m_iter->first).c_str(), (m_iter->second).c_str()); + } + printf("})\n"); + out = thing; + } + void testSet(set &out, const set &thing) { printf("testSet({"); set::const_iterator s_iter; -- 2.17.1