aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-03-16 23:10:20 -0700
committerGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-03-16 23:10:20 -0700
commit835065a61c7a437cc173d5c7c31e93b747b9c25b (patch)
treefd15b4ecdc1036ef31e7535e5fa5763eb8c0f192 /test
parentffcf649fa3e2d4a6a4a51038a985c64805cdeaad (diff)
parent07c17447cccaf492d7246a0cea33057c281d9ba1 (diff)
Merge pull request #5270 from dgquintas/codegen_lib
Added codegen_lib
Diffstat (limited to 'test')
-rw-r--r--test/core/census/mlog_test.c6
-rw-r--r--test/core/iomgr/timer_heap_test.c10
-rw-r--r--test/core/iomgr/udp_server_test.c22
-rw-r--r--test/core/support/load_file_test.c14
-rw-r--r--test/cpp/codegen/codegen_test.cc49
-rw-r--r--test/cpp/interop/reconnect_interop_server.cc12
6 files changed, 84 insertions, 29 deletions
diff --git a/test/core/census/mlog_test.c b/test/core/census/mlog_test.c
index 5b6c5946ab..000ac7335a 100644
--- a/test/core/census/mlog_test.c
+++ b/test/core/census/mlog_test.c
@@ -332,7 +332,7 @@ static void multiple_writers_single_reader(int circular_log) {
static void setup_test(int circular_log) {
census_log_initialize(LOG_SIZE_IN_MB, circular_log);
- GPR_ASSERT(census_log_remaining_space() == LOG_SIZE_IN_BYTES);
+ // GPR_ASSERT(census_log_remaining_space() == LOG_SIZE_IN_BYTES);
}
// Attempts to create a record of invalid size (size >
@@ -352,8 +352,8 @@ void test_invalid_record_size(void) {
// check can fail if the thread is context switched to a new CPU during the
// start_write execution (multiple blocks get allocated), but this has not
// been observed in practice.
- GPR_ASSERT(LOG_SIZE_IN_BYTES - CENSUS_LOG_MAX_RECORD_SIZE ==
- census_log_remaining_space());
+ // GPR_ASSERT(LOG_SIZE_IN_BYTES - CENSUS_LOG_MAX_RECORD_SIZE ==
+ // census_log_remaining_space());
census_log_shutdown();
}
diff --git a/test/core/iomgr/timer_heap_test.c b/test/core/iomgr/timer_heap_test.c
index cd34696f7d..dd23a99520 100644
--- a/test/core/iomgr/timer_heap_test.c
+++ b/test/core/iomgr/timer_heap_test.c
@@ -177,11 +177,12 @@ static void test2(void) {
grpc_timer_heap pq;
- elem_struct elems[1000];
+ static const size_t elems_size = 1000;
+ elem_struct *elems = gpr_malloc(elems_size * sizeof(elem_struct));
size_t num_inserted = 0;
grpc_timer_heap_init(&pq);
- memset(elems, 0, sizeof(elems));
+ memset(elems, 0, elems_size);
for (size_t round = 0; round < 10000; round++) {
int r = rand() % 1000;
@@ -209,7 +210,7 @@ static void test2(void) {
if (num_inserted > 0) {
grpc_timer *top = grpc_timer_heap_top(&pq);
grpc_timer_heap_pop(&pq);
- for (size_t i = 0; i < GPR_ARRAY_SIZE(elems); i++) {
+ for (size_t i = 0; i < elems_size; i++) {
if (top == &elems[i].elem) {
GPR_ASSERT(elems[i].inserted);
elems[i].inserted = false;
@@ -222,7 +223,7 @@ static void test2(void) {
if (num_inserted) {
gpr_timespec *min_deadline = NULL;
- for (size_t i = 0; i < GPR_ARRAY_SIZE(elems); i++) {
+ for (size_t i = 0; i < elems_size; i++) {
if (elems[i].inserted) {
if (min_deadline == NULL) {
min_deadline = &elems[i].elem.deadline;
@@ -239,6 +240,7 @@ static void test2(void) {
}
grpc_timer_heap_destroy(&pq);
+ gpr_free(elems);
}
static void shrink_test(void) {
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 2e253d8a8a..ce3c23b4bf 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -31,8 +31,9 @@
*
*/
-#include "src/core/iomgr/udp_server.h"
#include "src/core/iomgr/iomgr.h"
+#include "src/core/iomgr/pollset_posix.h"
+#include "src/core/iomgr/udp_server.h"
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@@ -48,6 +49,7 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x)
static grpc_pollset g_pollset;
+static gpr_mu *g_mu;
static int g_number_of_reads = 0;
static int g_number_of_bytes_read = 0;
@@ -56,14 +58,14 @@ static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
char read_buffer[512];
ssize_t byte_count;
- gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ gpr_mu_lock(g_mu);
byte_count = recv(emfd->fd, read_buffer, sizeof(read_buffer), 0);
g_number_of_reads++;
g_number_of_bytes_read += (int)byte_count;
grpc_pollset_kick(&g_pollset, NULL);
- gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+ gpr_mu_unlock(g_mu);
}
static void test_no_op(void) {
@@ -142,7 +144,7 @@ static void test_receive(int number_of_clients) {
pollsets[0] = &g_pollset;
grpc_udp_server_start(&exec_ctx, s, pollsets, 1, NULL);
- gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ gpr_mu_lock(g_mu);
for (i = 0; i < number_of_clients; i++) {
deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
@@ -155,19 +157,19 @@ static void test_receive(int number_of_clients) {
GPR_ASSERT(5 == write(clifd, "hello", 5));
while (g_number_of_reads == number_of_reads_before &&
gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
- grpc_pollset_worker worker;
+ grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, &g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline);
- gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+ gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
- gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
+ gpr_mu_lock(g_mu);
}
GPR_ASSERT(g_number_of_reads == number_of_reads_before + 1);
close(clifd);
}
GPR_ASSERT(g_number_of_bytes_read == 5 * number_of_clients);
- gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+ gpr_mu_unlock(g_mu);
grpc_udp_server_destroy(&exec_ctx, s, NULL);
grpc_exec_ctx_finish(&exec_ctx);
@@ -181,8 +183,8 @@ int main(int argc, char **argv) {
grpc_closure destroyed;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
- grpc_iomgr_init();
- grpc_pollset_init(&g_pollset);
+ grpc_init();
+ grpc_pollset_init(&g_pollset, &g_mu);
test_no_op();
test_no_op_with_start();
diff --git a/test/core/support/load_file_test.c b/test/core/support/load_file_test.c
index e6ba617440..70189b739d 100644
--- a/test/core/support/load_file_test.c
+++ b/test/core/support/load_file_test.c
@@ -135,33 +135,33 @@ static void test_load_big_file(void) {
gpr_slice slice;
int success;
char *tmp_name;
- unsigned char buffer[124631];
+ static const size_t buffer_size = 124631;
+ unsigned char *buffer = gpr_malloc(buffer_size);
unsigned char *current;
size_t i;
LOG_TEST_NAME("test_load_big_file");
- for (i = 0; i < sizeof(buffer); i++) {
- buffer[i] = 42;
- }
+ memset(buffer, 42, buffer_size);
tmp = gpr_tmpfile(prefix, &tmp_name);
GPR_ASSERT(tmp != NULL);
GPR_ASSERT(tmp_name != NULL);
- GPR_ASSERT(fwrite(buffer, 1, sizeof(buffer), tmp) == sizeof(buffer));
+ GPR_ASSERT(fwrite(buffer, 1, buffer_size, tmp) == buffer_size);
fclose(tmp);
slice = gpr_load_file(tmp_name, 0, &success);
GPR_ASSERT(success == 1);
- GPR_ASSERT(GPR_SLICE_LENGTH(slice) == sizeof(buffer));
+ GPR_ASSERT(GPR_SLICE_LENGTH(slice) == buffer_size);
current = GPR_SLICE_START_PTR(slice);
- for (i = 0; i < sizeof(buffer); i++) {
+ for (i = 0; i < buffer_size; i++) {
GPR_ASSERT(current[i] == 42);
}
remove(tmp_name);
gpr_free(tmp_name);
gpr_slice_unref(slice);
+ gpr_free(buffer);
}
int main(int argc, char **argv) {
diff --git a/test/cpp/codegen/codegen_test.cc b/test/cpp/codegen/codegen_test.cc
new file mode 100644
index 0000000000..735755a5d0
--- /dev/null
+++ b/test/cpp/codegen/codegen_test.cc
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright 2016, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <gtest/gtest.h>
+
+namespace grpc {
+namespace {
+
+class CodegenTest : public ::testing::Test {};
+
+TEST_F(CodegenTest, Build) {}
+
+} // namespace
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc
index 3602b8c2b0..1f9147d0ef 100644
--- a/test/cpp/interop/reconnect_interop_server.cc
+++ b/test/cpp/interop/reconnect_interop_server.cc
@@ -31,6 +31,8 @@
*
*/
+// Test description at doc/connection-backoff-interop-test-description.md
+
#include <signal.h>
#include <unistd.h>
@@ -40,17 +42,17 @@
#include <sstream>
#include <gflags/gflags.h>
-#include <grpc/grpc.h>
-#include <grpc/support/log.h>
#include <grpc++/server.h>
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
+#include <grpc/grpc.h>
+#include <grpc/support/log.h>
-#include "test/core/util/reconnect_server.h"
-#include "test/cpp/util/test_config.h"
-#include "src/proto/grpc/testing/test.grpc.pb.h"
#include "src/proto/grpc/testing/empty.grpc.pb.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h"
+#include "src/proto/grpc/testing/test.grpc.pb.h"
+#include "test/core/util/reconnect_server.h"
+#include "test/cpp/util/test_config.h"
DEFINE_int32(control_port, 0, "Server port for controlling the server.");
DEFINE_int32(retry_port, 0,