aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-04-28 16:55:49 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-04-28 16:55:49 -0700
commit4354a8eb28f4da2869adf38203f8a7676ff68611 (patch)
treede6cb8f307d1832a2d9521565942ed744b9c4b6f /src
parent37815e59db32e411c5adad32bdefbb4c02d91ae1 (diff)
parentc48f26f5dc519fec2732bdf5fd29eaa50ad283ac (diff)
Merge github.com:grpc/grpc into one-pass
Diffstat (limited to 'src')
-rw-r--r--src/core/support/alloc.c2
-rw-r--r--src/core/support/time_win32.c2
-rw-r--r--src/objective-c/examples/Sample/Podfile.lock44
-rw-r--r--src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m89
4 files changed, 68 insertions, 69 deletions
diff --git a/src/core/support/alloc.c b/src/core/support/alloc.c
index a19a0141d4..d2ed82e771 100644
--- a/src/core/support/alloc.c
+++ b/src/core/support/alloc.c
@@ -55,7 +55,7 @@ void *gpr_realloc(void *p, size_t size) {
}
void *gpr_malloc_aligned(size_t size, size_t alignment_log) {
- size_t alignment = 1 << alignment_log;
+ size_t alignment = ((size_t)1) << alignment_log;
size_t extra = alignment - 1 + sizeof(void *);
void *p = gpr_malloc(size + extra);
void **ret = (void **)(((gpr_uintptr)p + extra) & ~(alignment - 1));
diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c
index 539470bccf..f4443b5c2d 100644
--- a/src/core/support/time_win32.c
+++ b/src/core/support/time_win32.c
@@ -64,7 +64,7 @@ void gpr_sleep_until(gpr_timespec until) {
}
delta = gpr_time_sub(until, now);
- sleep_millis = delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
+ sleep_millis = (DWORD)delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
Sleep(sleep_millis);
}
}
diff --git a/src/objective-c/examples/Sample/Podfile.lock b/src/objective-c/examples/Sample/Podfile.lock
deleted file mode 100644
index ccf5aa0f06..0000000000
--- a/src/objective-c/examples/Sample/Podfile.lock
+++ /dev/null
@@ -1,44 +0,0 @@
-PODS:
- - gRPC (0.0.1):
- - gRPC/C-Core (= 0.0.1)
- - gRPC/GRPCClient (= 0.0.1)
- - gRPC/ProtoRPC (= 0.0.1)
- - gRPC/RxLibrary (= 0.0.1)
- - gRPC/C-Core (0.0.1):
- - OpenSSL (~> 1.0.200)
- - gRPC/GRPCClient (0.0.1):
- - gRPC/C-Core
- - gRPC/RxLibrary
- - gRPC/ProtoRPC (0.0.1):
- - gRPC/GRPCClient
- - gRPC/RxLibrary
- - gRPC/RxLibrary (0.0.1)
- - OpenSSL (1.0.201)
- - ProtocolBuffers (1.9.8)
- - RemoteTest (0.0.1):
- - gRPC (~> 0.0)
- - ProtocolBuffers (~> 1.9)
- - Route_guide (0.0.1):
- - ProtocolBuffers (~> 1.9)
-
-DEPENDENCIES:
- - gRPC (from `../../../..`)
- - RemoteTest (from `RemoteTestClient`)
- - Route_guide (from `RouteGuideClient`)
-
-EXTERNAL SOURCES:
- gRPC:
- :path: ../../../..
- RemoteTest:
- :path: RemoteTestClient
- Route_guide:
- :path: RouteGuideClient
-
-SPEC CHECKSUMS:
- gRPC: f6c1bf5dde59ab543e4bd1d5e2ea56da4a9a0253
- OpenSSL: 4e990d04b14015c49c800c400b86ae44a4818a5c
- ProtocolBuffers: 9a4a171c0c7cc8f21dd29aeca4f9ac775d84a880
- RemoteTest: 021a51c04d5795f286b379ca5ef14d0be5b2fb9b
- Route_guide: a277da8eef182774abb050d7b81109f5878f8652
-
-COCOAPODS: 0.36.0
diff --git a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
index 6c5de81277..2ef6a6e4ab 100644
--- a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
+++ b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
@@ -34,6 +34,7 @@
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
+#import <gRPC/GRXWriter+Immediate.h>
#import <RemoteTest/Messages.pb.h>
#import <RemoteTest/Test.pb.h>
@@ -48,43 +49,85 @@
_service = [[RMTTestService alloc] initWithHost:@"grpc-test.sandbox.google.com"];
}
-- (void)testEmptyRPC {
- __weak XCTestExpectation *noRPCError = [self expectationWithDescription:@"RPC succeeded."];
- __weak XCTestExpectation *responded = [self expectationWithDescription:@"Response received."];
+// Tests as described here: https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md
- [_service emptyCallWithRequest:[RMTEmpty defaultInstance]
- handler:^(RMTEmpty *response, NSError *error) {
+- (void)testEmptyUnaryRPC {
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
+
+ RMTEmpty *request = [RMTEmpty defaultInstance];
+
+ [_service emptyCallWithRequest:request handler:^(RMTEmpty *response, NSError *error) {
XCTAssertNil(error, @"Finished with unexpected error: %@", error);
- [noRPCError fulfill];
- XCTAssertNotNil(response, @"nil response received.");
- [responded fulfill];
+
+ id expectedResponse = [RMTEmpty defaultInstance];
+ XCTAssertEqualObjects(response, expectedResponse);
+
+ [expectation fulfill];
}];
[self waitForExpectationsWithTimeout:2. handler:nil];
}
-- (void)testSimpleProtoRPC {
- __weak XCTestExpectation *noRPCError = [self expectationWithDescription:@"RPC succeeded."];
- __weak XCTestExpectation *responded = [self expectationWithDescription:@"Response received."];
- __weak XCTestExpectation *validResponse = [self expectationWithDescription:@"Valid response."];
+- (void)testLargeUnaryRPC {
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
RMTSimpleRequest *request = [[[[[[RMTSimpleRequestBuilder alloc] init]
- setResponseSize:100]
- setFillUsername:YES]
- setFillOauthScope:YES]
+ setResponseType:RMTPayloadTypeCompressable]
+ setResponseSize:314159]
+ setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
+ setBody:[NSMutableData dataWithLength:271828]]]
build];
+
[_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) {
XCTAssertNil(error, @"Finished with unexpected error: %@", error);
- [noRPCError fulfill];
- XCTAssertNotNil(response, @"nil response received.");
- [responded fulfill];
- // We expect empty strings, not nil:
- XCTAssertNotNil(response.username, @"Response's username is nil.");
- XCTAssertNotNil(response.oauthScope, @"Response's OAuth scope is nil.");
- [validResponse fulfill];
+
+ id expectedResponse = [[[[RMTSimpleResponseBuilder alloc] init]
+ setPayloadBuilder:[[[[RMTPayloadBuilder alloc] init]
+ setType:RMTPayloadTypeCompressable]
+ setBody:[NSMutableData dataWithLength:314159]]]
+ build];
+ XCTAssertEqualObjects(response, expectedResponse);
+
+ [expectation fulfill];
}];
- [self waitForExpectationsWithTimeout:2. handler:nil];
+ [self waitForExpectationsWithTimeout:4. handler:nil];
+}
+
+- (void)testClientStreamingRPC {
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
+
+ id request1 = [[[[RMTStreamingInputCallRequestBuilder alloc] init]
+ setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
+ setBody:[NSMutableData dataWithLength:27182]]]
+ build];
+ id request2 = [[[[RMTStreamingInputCallRequestBuilder alloc] init]
+ setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
+ setBody:[NSMutableData dataWithLength:8]]]
+ build];
+ id request3 = [[[[RMTStreamingInputCallRequestBuilder alloc] init]
+ setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
+ setBody:[NSMutableData dataWithLength:1828]]]
+ build];
+ id request4 = [[[[RMTStreamingInputCallRequestBuilder alloc] init]
+ setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
+ setBody:[NSMutableData dataWithLength:45904]]]
+ build];
+ id<GRXWriter> writer = [GRXWriter writerWithContainer:@[request1, request2, request3, request4]];
+
+ [_service streamingInputCallWithRequestsWriter:writer
+ handler:^(RMTStreamingInputCallResponse *response, NSError *error) {
+ XCTAssertNil(error, @"Finished with unexpected error: %@", error);
+
+ id expectedResponse = [[[[RMTStreamingInputCallResponseBuilder alloc] init]
+ setAggregatedPayloadSize:74922]
+ build];
+ XCTAssertEqualObjects(response, expectedResponse);
+
+ [expectation fulfill];
+ }];
+
+ [self waitForExpectationsWithTimeout:4. handler:nil];
}
@end