static void test_recv_status_on_client_twice() { grpc_op *op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &g_state.trailing_metadata_recv; op->data.recv_status_on_client.status = &g_state.status; op->data.recv_status_on_client.status_details = &g_state.details; op->data.recv_status_on_client.status_details_capacity = &g_state.details_capacity; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cq_expect_completion(g_state.cqv, tag(1), 1); cq_verify(g_state.cqv); op = g_state.ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = NULL; op->data.recv_status_on_client.status = NULL; op->data.recv_status_on_client.status_details = NULL; op->data.recv_status_on_client.status_details_capacity = NULL; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
TEST(EngineTest, Initialize) { EngineOptions options = get_tiny_options(); Engine engine(options); COERCE_ERROR(engine.initialize()); COERCE_ERROR(engine.uninitialize()); cleanup_test(options); }
static void test_send_messages_at_the_same_time() { grpc_op *op; gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); prepare_test(1); op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message = tag(2); op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); grpc_byte_buffer_destroy(request_payload); cleanup_test(); }
static void test_send_server_status_twice() { gpr_log(GPR_INFO, "test_send_server_status_twice"); grpc_op *op; prepare_test(0); op = g_state.ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.trailing_metadata_count = 0; op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; op->data.send_status_from_server.status_details = "xyz"; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.trailing_metadata_count = 0; op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; op->data.send_status_from_server.status_details = "xyz"; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.server_call, g_state.ops, (size_t)(op - g_state.ops), tag(2), NULL)); cleanup_test(); }
static void test_send_initial_metadata_more_than_once() { grpc_op *op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cq_expect_completion(g_state.cqv, tag(1), 0); cq_verify(g_state.cqv); op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
static void test_receive_initial_metadata_twice_at_client() { grpc_op *op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; op->data.recv_initial_metadata = &g_state.initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cq_expect_completion(g_state.cqv, tag(1), 0); cq_verify(g_state.cqv); op = g_state.ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; op->data.recv_initial_metadata = &g_state.initial_metadata_recv; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
int main(int argc, char **argv) { (void)argc; (void)argv; const uint32_t net = 0x0a0a0a00; char *password; setup_test("tcpr-test", "test-spurious-fins"); password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999); setup_connection(net | 2, net | 4, net | 3, 8888, 9999, 0xdeadbeef, 0xcafebabe, test_options_size, test_options, peer_mss, peer_ws, password); fprintf(stderr, "Application: FIN (failure)\n"); send_segment(internal_log, net | 4, net | 2, 9999, 8888, TH_ACK | TH_FIN, 0xcafebabe + 1, 0xdeadbeef + 1, 0, NULL, 0, NULL, password); fprintf(stderr, " Filter: RST\n"); recv_segment(internal_log, net | 2, net | 4, 8888, 9999, TH_RST, 0xdeadbeef + 1, 0, 0, NULL, 0, NULL, password); cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 1, 0); cleanup_test(); return EXIT_SUCCESS; }
static void test_non_null_reserved_on_start_batch() { gpr_log(GPR_INFO, "test_non_null_reserved_on_start_batch"); prepare_test(1); GPR_ASSERT(GRPC_CALL_ERROR == grpc_call_start_batch(g_state.call, NULL, 0, NULL, tag(1))); cleanup_test(); }
// this is a good test to see if initialize/uninitialize pair is complete. // eg: aren't we incorrectly relying on constructor of some object, rather than initialize()? // eg: aren't we lazy to skip some uninitialization, which makes next initialize() crash? // again, don't do anything in constructor! there is no point to do so. do it in initialize(). TEST(EngineTest, RestartManyTimes) { EngineOptions options = get_tiny_options(); Engine engine(options); // initialize the same engine many times. for (int i = 0; i < 2; ++i) { COERCE_ERROR(engine.initialize()); COERCE_ERROR(engine.uninitialize()); } cleanup_test(options); }
TEST(EngineTest, Restart) { EngineOptions options = get_tiny_options(); for (int i = 0; i < 2; ++i) { Engine engine(options); COERCE_ERROR(engine.initialize()); COERCE_ERROR(engine.uninitialize()); } cleanup_test(options); }
int main(int ac, char **av) { int lc, i; tst_parse_opts(ac, av, NULL, NULL); setup(); /* check looping state */ for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; for (i = 0; i < TST_TOTAL; i++) { if (setup_test(i)) { tst_resm(TFAIL, "mlockall() Failed while setup " "for checking error %s", TC[i].edesc); continue; } TEST(mlockall(TC[i].flag)); /* check return code */ if (TEST_RETURN == -1) { if (TEST_ERRNO != TC[i].error) tst_brkm(TFAIL, cleanup, "mlock() Failed with wrong " "errno, expected errno=%s, " "got errno=%d : %s", TC[i].edesc, TEST_ERRNO, strerror(TEST_ERRNO)); else tst_resm(TPASS, "expected failure - errno " "= %d : %s", TEST_ERRNO, strerror(TEST_ERRNO)); } else { if (i <= 1) tst_resm(TCONF, "mlockall02 did not BEHAVE as expected."); else tst_brkm(TFAIL, cleanup, "mlock() Failed, expected " "return value=-1, got %ld", TEST_RETURN); } cleanup_test(i); } } /* cleanup and exit */ cleanup(); tst_exit(); }
static void test_send_close_from_client_on_server() { grpc_op *op; prepare_test(0); op = g_state.ops; op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_NOT_ON_SERVER == grpc_call_start_batch(g_state.server_call, g_state.ops, (size_t)(op - g_state.ops), tag(2), NULL)); cleanup_test(); }
static void test_receive_message_with_invalid_flags() { grpc_op *op; grpc_byte_buffer *payload = NULL; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &payload; op->flags = 1; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_INVALID_FLAGS == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
static void test_recv_close_on_server_with_invalid_flags() { grpc_op *op; prepare_test(0); op = g_state.ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = NULL; op->flags = 1; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_INVALID_FLAGS == grpc_call_start_batch(g_state.server_call, g_state.ops, (size_t)(op - g_state.ops), tag(2), NULL)); cleanup_test(); }
static void test_non_null_reserved_on_op() { grpc_op *op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; op->reserved = tag(2); op++; GPR_ASSERT(GRPC_CALL_ERROR == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
static void test_too_many_metadata() { grpc_op *op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = (size_t)INT_MAX + 1; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_INVALID_METADATA == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
static void test_recv_close_on_server_from_client() { grpc_op *op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = NULL; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_NOT_ON_CLIENT == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
int TestDbHotBackupTestTeardown(CuTest *ct) { struct handlers *info; DB_ENV *dbenv; DB *dbp; if (ct->context == NULL) return (EINVAL); info = ct->context; dbenv = info->dbenvp; dbp = info->dbp; /* Close all handles and clean the directories. */ CuAssert(ct, "cleanup_test", cleanup_test(dbenv, dbp) == 0); free(info); ct->context = NULL; return (0); }
TEST(HashBasicTest, Create) { EngineOptions options = get_tiny_options(); Engine engine(options); COERCE_ERROR(engine.initialize()); { UninitializeGuard guard(&engine); HashMetadata meta("test", 8); HashStorage storage; Epoch epoch; COERCE_ERROR(engine.get_storage_manager()->create_hash(&meta, &storage, &epoch)); EXPECT_TRUE(storage.exists()); COERCE_ERROR(storage.verify_single_thread(&engine)); COERCE_ERROR(engine.uninitialize()); } cleanup_test(options); }
TEST(HashBasicTest, CreateAndDrop) { EngineOptions options = get_tiny_options(); Engine engine(options); COERCE_ERROR(engine.initialize()); { UninitializeGuard guard(&engine); HashMetadata meta("dd", 8); HashStorage storage; Epoch epoch; COERCE_ERROR(engine.get_storage_manager()->create_hash(&meta, &storage, &epoch)); EXPECT_TRUE(storage.exists()); COERCE_ERROR(engine.get_storage_manager()->drop_storage(storage.get_id(), &epoch)); EXPECT_TRUE(!storage.exists()); COERCE_ERROR(engine.uninitialize()); } cleanup_test(options); }
static void test_send_status_from_server_with_invalid_flags() { grpc_op *op; prepare_test(0); op = g_state.ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.trailing_metadata_count = 0; op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; op->data.send_status_from_server.status_details = "xyz"; op->flags = 1; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_INVALID_FLAGS == grpc_call_start_batch(g_state.server_call, g_state.ops, (size_t)(op - g_state.ops), tag(2), NULL)); cleanup_test(); }
static void test_send_server_status_from_client() { grpc_op *op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.trailing_metadata_count = 0; op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; op->data.send_status_from_server.status_details = "xyz"; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_NOT_ON_CLIENT == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
TEST(MasstreeSplitTest, SplitBorder) { EngineOptions options = get_tiny_options(); Engine engine(options); engine.get_proc_manager()->pre_register("split_border_task", split_border_task); COERCE_ERROR(engine.initialize()); { UninitializeGuard guard(&engine); MasstreeMetadata meta("ggg"); MasstreeStorage storage; Epoch epoch; COERCE_ERROR(engine.get_storage_manager()->create_masstree(&meta, &storage, &epoch)); EXPECT_TRUE(storage.exists()); COERCE_ERROR(engine.get_thread_pool()->impersonate_synchronous("split_border_task")); COERCE_ERROR(engine.uninitialize()); } cleanup_test(options); }
int main(int argc, char **argv) { (void)argc; (void)argv; const uint32_t net = 0x0a0a0a00; char *password; setup_test("tcpr-test", "test-recover-peer-send"); password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999); setup_connection(net | 2, net | 4, net | 3, 8888, 9999, 0xdeadbeef, 0xcafebabe, test_options_size, test_options, peer_mss, peer_ws, password); recover_connection(net | 5, net | 2, net | 3, 9999, 8888, 0xfeedbead, 0xcafebabe, 0xdeadbeef, test_options_size, test_options, peer_mss, peer_ws, TCPR_HAVE_ACK | TCPR_HAVE_PEER_MSS | TCPR_HAVE_PEER_WS, password); fprintf(stderr, " Peer: \"baz\" (retransmit)\n"); send_segment(external_log, net | 2, net | 3, 8888, 9999, TH_ACK, 0xdeadbeef + 1, 0xcafebabe + 1, 0, NULL, 4, "baz", password); recv_segment(internal_log, net | 2, net | 5, 8888, 9999, TH_ACK, 0xdeadbeef + 1, 0xfeedbead + 1, 0, NULL, 4, "baz", password); fprintf(stderr, "Application: ACK\n"); send_segment(internal_log, net | 5, net | 2, 9999, 8888, TH_ACK, 0xfeedbead + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); fprintf(stderr, "Application: update\n"); send_update(net | 2, net | 5, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 5, 0, 0, (0xfeedbead + 1) - (0xcafebabe + 1), TCPR_HAVE_ACK); fprintf(stderr, " Filter: ACK\n"); recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_ACK, 0xcafebabe + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 1, (0xfeedbead + 1) - (0xcafebabe + 1)); cleanup_test(); return EXIT_SUCCESS; }
TEST(HashBasicTest, CreateAndQuery) { EngineOptions options = get_tiny_options(); Engine engine(options); engine.get_proc_manager()->pre_register(proc::ProcAndName("query_task", query_task)); COERCE_ERROR(engine.initialize()); { UninitializeGuard guard(&engine); HashMetadata meta("test2", 8); HashStorage storage; Epoch epoch; COERCE_ERROR(engine.get_storage_manager()->create_hash(&meta, &storage, &epoch)); EXPECT_TRUE(storage.exists()); COERCE_ERROR(engine.get_thread_pool()->impersonate_synchronous("query_task")); COERCE_ERROR(storage.verify_single_thread(&engine)); COERCE_ERROR(engine.uninitialize()); } cleanup_test(options); }
static void test_recv_close_on_server_twice() { grpc_op *op; prepare_test(0); op = g_state.ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = NULL; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = NULL; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.server_call, g_state.ops, (size_t)(op - g_state.ops), tag(2), NULL)); cleanup_test(); }
static void test_receive_two_messages_at_the_same_time() { grpc_op *op; grpc_byte_buffer *payload = NULL; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &payload; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &payload; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
static void test_recv_status_on_client_from_server() { grpc_op *op; prepare_test(0); op = g_state.ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &g_state.trailing_metadata_recv; op->data.recv_status_on_client.status = &g_state.status; op->data.recv_status_on_client.status_details = &g_state.details; op->data.recv_status_on_client.status_details_capacity = &g_state.details_capacity; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_NOT_ON_SERVER == grpc_call_start_batch(g_state.server_call, g_state.ops, (size_t)(op - g_state.ops), tag(2), NULL)); cleanup_test(); }
static void test_send_null_message() { gpr_log(GPR_INFO, "test_send_null_message"); grpc_op *op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message = NULL; op->flags = 0; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_ERROR_INVALID_MESSAGE == grpc_call_start_batch(g_state.call, g_state.ops, (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); }
void run_test(int thread_count_arg, bool contended_arg, AccessorType type) { thread_count = thread_count_arg; contended = contended_arg; accessor_type = type; EngineOptions options = get_tiny_options(); options.log_.log_buffer_kb_ = 1 << 12; options.thread_.group_count_ = 1; options.thread_.thread_count_per_group_ = thread_count; Engine engine(options); engine.get_proc_manager()->pre_register("create_tpcb_tables_task", create_tpcb_tables_task); engine.get_proc_manager()->pre_register("run_tpcb_task", run_tpcb_task); engine.get_proc_manager()->pre_register("verify_tpcb_task", verify_tpcb_task); COERCE_ERROR(engine.initialize()); { UninitializeGuard guard(&engine); COERCE_ERROR(engine.get_thread_pool()->impersonate_synchronous("create_tpcb_tables_task")); { start_rendezvous.initialize(); std::vector<thread::ImpersonateSession> sessions; for (int i = 0; i < thread_count; ++i) { thread::ImpersonateSession session; EXPECT_TRUE( engine.get_thread_pool()->impersonate("run_tpcb_task", &i, sizeof(i), &session)); sessions.emplace_back(std::move(session)); } start_rendezvous.signal(); for (int i = 0; i < thread_count; ++i) { COERCE_ERROR(sessions[i].get_result()); sessions[i].release(); } start_rendezvous.uninitialize(); } COERCE_ERROR(engine.get_thread_pool()->impersonate_synchronous("verify_tpcb_task")); COERCE_ERROR(engine.uninitialize()); } cleanup_test(options); }