Thrift now works in PHP, hot stuff
Summary: End to end communication working in Thrift with PHP
Problem: It's a bit slower than pillar still. Need to find out why.
Reviewed By: aditya
Test Plan: Unit tests are in the test directory. Get lucas on the PHP case...
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664720 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/cpp/Makefile b/test/cpp/Makefile
index 21c09ec..36abb43 100644
--- a/test/cpp/Makefile
+++ b/test/cpp/Makefile
@@ -12,19 +12,28 @@
LD = g++
# Compiler flags
-LIBS = ../../lib/cpp/server/TSimpleServer.cc \
- ../../lib/cpp/protocol/TBinaryProtocol.cc \
- ../../lib/cpp/transport/TBufferedTransport.cc \
- ../../lib/cpp/transport/TServerSocket.cc \
- ../../lib/cpp/transport/TSocket.cc
-CFL = -Wall -O3 -Igen-cpp -I../../lib/cpp $(LIBS)
-CFL = -Wall -O3 -Igen-cpp -I../../lib/cpp -lthrift
+LIBS = ../../lib/cpp/src/server/TSimpleServer.cc \
+ ../../lib/cpp/src/protocol/TBinaryProtocol.cc \
+ ../../lib/cpp/src/transport/TBufferedTransport.cc \
+ ../../lib/cpp/src/transport/TChunkedTransport.cc \
+ ../../lib/cpp/src/transport/TServerSocket.cc \
+ ../../lib/cpp/src/transport/TSocket.cc
+DCFL = -Wall -O3 -g -Igen-cpp -I../../lib/cpp/src $(LIBS)
+CFL = -Wall -O3 -Igen-cpp -I../../lib/cpp/src -lthrift
all: server client
+debug: server-debug client-debug
+
stubs: ../ThriftTest.thrift
$(THRIFT) -cpp ../ThriftTest.thrift
+server-debug: stubs
+ g++ -o TestServer $(DCFL) src/TestServer.cc gen-cpp/ThriftTest.cc
+
+client-debug: stubs
+ g++ -o TestClient $(DCFL) src/TestClient.cc gen-cpp/ThriftTest.cc
+
server: stubs
g++ -o TestServer $(CFL) src/TestServer.cc gen-cpp/ThriftTest.cc
diff --git a/test/cpp/src/TestClient.cc b/test/cpp/src/TestClient.cc
index 6bd06b9..083661f 100644
--- a/test/cpp/src/TestClient.cc
+++ b/test/cpp/src/TestClient.cc
@@ -77,14 +77,7 @@
printf("testByte(1)");
uint8_t u8 = testClient.testByte(1);
printf(" = %d\n", (int)u8);
-
- /**
- * U32 TEST
- */
- printf("testU32(1)");
- uint32_t u32 = testClient.testU32(1);
- printf(" = %u\n", u32);
-
+
/**
* I32 TEST
*/
@@ -93,13 +86,6 @@
printf(" = %d\n", i32);
/**
- * U64 TEST
- */
- printf("testU64(34359738368)");
- uint64_t u64 = testClient.testU64(34359738368);
- printf(" = %lu\n", u64);
-
- /**
* I64 TEST
*/
printf("testI64(-34359738368)");
@@ -109,40 +95,34 @@
/**
* STRUCT TEST
*/
- printf("testStruct({\"Zero\", 1, 2, -3, 4, -5})");
+ printf("testStruct({\"Zero\", 1, -3, -5})");
Xtruct out;
out.string_thing = "Zero";
out.byte_thing = 1;
- out.u32_thing = 2;
out.i32_thing = -3;
- out.u64_thing = 4;
out.i64_thing = -5;
Xtruct in = testClient.testStruct(out);
- printf(" = {\"%s\", %d, %u, %d, %lu, %ld}\n",
+ printf(" = {\"%s\", %d, %d, %ld}\n",
in.string_thing.c_str(),
(int)in.byte_thing,
- in.u32_thing,
in.i32_thing,
- in.u64_thing,
in.i64_thing);
/**
* NESTED STRUCT TEST
*/
- printf("testNest({1, {\"Zero\", 1, 2, -3, 4, -5}), 5}");
+ printf("testNest({1, {\"Zero\", 1, -3, -5}), 5}");
Xtruct2 out2;
out2.byte_thing = 1;
out2.struct_thing = out;
out2.i32_thing = 5;
Xtruct2 in2 = testClient.testNest(out2);
in = in2.struct_thing;
- printf(" = {%d, {\"%s\", %d, %u, %d, %lu, %ld}, %d}\n",
+ printf(" = {%d, {\"%s\", %d, %d, %ld}, %d}\n",
in2.byte_thing,
in.string_thing.c_str(),
(int)in.byte_thing,
- in.u32_thing,
in.i32_thing,
- in.u64_thing,
in.i64_thing,
in2.i32_thing);
@@ -270,7 +250,7 @@
*/
printf("testTypedef(309858235082523)");
UserId uid = testClient.testTypedef(309858235082523);
- printf(" = %lu\n", uid);
+ printf(" = %ld\n", uid);
/**
* NESTED MAP TEST
@@ -297,9 +277,7 @@
Xtruct truck;
truck.string_thing = "Truck";
truck.byte_thing = 8;
- truck.u32_thing = 8;
truck.i32_thing = 8;
- truck.u64_thing = 8;
truck.i64_thing = 8;
insane.xtructs.push_back(truck);
printf("testInsanity()");
@@ -307,7 +285,7 @@
printf(" = {");
map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
- printf("%lu => {", i_iter->first);
+ printf("%ld => {", i_iter->first);
map<Numberz,Insanity>::const_iterator i2_iter;
for (i2_iter = i_iter->second.begin();
i2_iter != i_iter->second.end();
@@ -317,7 +295,7 @@
map<Numberz, UserId>::const_iterator um;
printf("{");
for (um = userMap.begin(); um != userMap.end(); ++um) {
- printf("%d => %lu, ", um->first, um->second);
+ printf("%d => %ld, ", um->first, um->second);
}
printf("}, ");
@@ -325,12 +303,10 @@
list<Xtruct>::const_iterator x;
printf("{");
for (x = xtructs.begin(); x != xtructs.end(); ++x) {
- printf("{\"%s\", %d, %u, %d, %lu, %ld}, ",
+ printf("{\"%s\", %d, %d, %ld}, ",
x->string_thing.c_str(),
(int)x->byte_thing,
- x->u32_thing,
x->i32_thing,
- x->u64_thing,
x->i64_thing);
}
printf("}");
diff --git a/test/cpp/src/TestServer.cc b/test/cpp/src/TestServer.cc
index 206b6f5..c0df233 100644
--- a/test/cpp/src/TestServer.cc
+++ b/test/cpp/src/TestServer.cc
@@ -24,46 +24,32 @@
return thing;
}
- uint32_t testU32(uint32_t thing) {
- printf("testU32(%u)\n", thing);
- return thing;
- }
-
int32_t testI32(int32_t thing) {
printf("testI32(%d)\n", thing);
return thing;
}
- uint64_t testU64(uint64_t thing) {
- printf("testU64(%lu)\n", thing);
- return thing;
- }
-
int64_t testI64(int64_t thing) {
printf("testI64(%ld)\n", thing);
return thing;
}
Xtruct testStruct(Xtruct thing) {
- printf("testStruct({\"%s\", %d, %u, %d, %lu, %ld})\n",
+ printf("testStruct({\"%s\", %d, %d, %ld})\n",
thing.string_thing.c_str(),
(int)thing.byte_thing,
- thing.u32_thing,
thing.i32_thing,
- thing.u64_thing,
thing.i64_thing);
return thing;
}
Xtruct2 testNest(Xtruct2 nest) {
Xtruct thing = nest.struct_thing;
- printf("testNest({%d, {\"%s\", %d, %u, %d, %lu, %ld}, %d})\n",
+ printf("testNest({%d, {\"%s\", %d, %d, %ld}, %d})\n",
(int)nest.byte_thing,
thing.string_thing.c_str(),
(int)thing.byte_thing,
- thing.u32_thing,
thing.i32_thing,
- thing.u64_thing,
thing.i64_thing,
nest.i32_thing);
return nest;
@@ -123,7 +109,7 @@
}
UserId testTypedef(UserId thing) {
- printf("testTypedef(%lu)\n", thing);
+ printf("testTypedef(%ld)\n", thing);
return thing;
}
@@ -150,17 +136,13 @@
Xtruct hello;
hello.string_thing = "Hello2";
hello.byte_thing = 2;
- hello.u32_thing = 2;
hello.i32_thing = 2;
- hello.u64_thing = 2;
hello.i64_thing = 2;
Xtruct goodbye;
goodbye.string_thing = "Goodbye4";
goodbye.byte_thing = 4;
- goodbye.u32_thing = 4;
goodbye.i32_thing = 4;
- goodbye.u64_thing = 4;
goodbye.i64_thing = 4;
Insanity crazy;
@@ -187,7 +169,7 @@
printf(" = {");
map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
- printf("%lu => {", i_iter->first);
+ printf("%ld => {", i_iter->first);
map<Numberz,Insanity>::const_iterator i2_iter;
for (i2_iter = i_iter->second.begin();
i2_iter != i_iter->second.end();
@@ -197,7 +179,7 @@
map<Numberz, UserId>::const_iterator um;
printf("{");
for (um = userMap.begin(); um != userMap.end(); ++um) {
- printf("%d => %lu, ", um->first, um->second);
+ printf("%d => %ld, ", um->first, um->second);
}
printf("}, ");
@@ -205,12 +187,10 @@
list<Xtruct>::const_iterator x;
printf("{");
for (x = xtructs.begin(); x != xtructs.end(); ++x) {
- printf("{\"%s\", %d, %u, %d, %lu, %ld}, ",
+ printf("{\"%s\", %d, %d, %ld}, ",
x->string_thing.c_str(),
(int)x->byte_thing,
- x->u32_thing,
x->i32_thing,
- x->u64_thing,
x->i64_thing);
}
printf("}");