KineticClient * KineticClient_Init(KineticClientConfig *config) { KineticLogger_Init(config->logFile, config->logLevel); KineticClient * client = KineticCalloc(1, sizeof(*client)); if (client == NULL) { KineticLogger_Close(); return NULL; } /* Use defaults if set to 0. */ if (config->readerThreads == 0) { config->readerThreads = KINETIC_CLIENT_DEFAULT_READER_THREADS; } if (config->maxThreadpoolThreads == 0) { config->maxThreadpoolThreads = KINETIC_CLIENT_DEFAULT_MAX_THREADPOOL_THREADS; } bool success = KineticBus_Init(client, config); if (!success) { KineticFree(client); KineticLogger_Close(); return NULL; } return client; }
void setUp(void) { KineticLogger_Init("stdout", 1); Session = (KineticSession) {.connected = true}; Operation = (KineticOperation) {.session = &Session}; KineticRequest_Init(&Request, &Session); Operation.request = &Request; } void tearDown(void) { KineticLogger_Close(); } /******************************************************************************* * Client Operations *******************************************************************************/ void test_KineticBuilder_BuildNoop_should_build_and_execute_a_NOOP_operation(void) { KineticOperation_ValidateOperation_Expect(&Operation); KineticBuilder_BuildNoop(&Operation); TEST_ASSERT_TRUE(Request.message.command.header->has_messagetype); TEST_ASSERT_FALSE(Request.pinAuth); TEST_ASSERT_EQUAL(0, Operation.timeoutSeconds); TEST_ASSERT_EQUAL(COM__SEAGATE__KINETIC__PROTO__COMMAND__MESSAGE_TYPE__NOOP, Request.message.command.header->messagetype); TEST_ASSERT_NULL(Operation.response); }
void setUp(void) { memset(&Session, 0, sizeof(Session)); Session.config = (KineticSessionConfig) { .host = "somehost.com", .port = 17, .clusterVersion = 6, }; Client.bus = &MessageBus; KineticCountingSemaphore_Create_ExpectAndReturn(KINETIC_MAX_OUTSTANDING_OPERATIONS_PER_SESSION, &Semaphore); KineticStatus status = KineticSession_Create(&Session, &Client); TEST_ASSERT_EQUAL_KineticStatus(KINETIC_STATUS_SUCCESS, status); TEST_ASSERT_FALSE(Session.connected); TEST_ASSERT_EQUAL_STRING(Session.config.host, "somehost.com"); TEST_ASSERT_EQUAL(17, Session.config.port); KineticRequest_Init(&Request, &Session); OperationCompleteCallbackCount = 0; LastStatus = KINETIC_STATUS_INVALID; } void tearDown(void) { KineticLogger_Close(); } void test_KineticSession_Create_should_return_KINETIC_STATUS_SESSION_EMPTY_upon_NULL_session(void) { TEST_ASSERT_EQUAL(KINETIC_STATUS_SESSION_EMPTY, KineticSession_Create(NULL, NULL)); }
void tearDown(void) { if (FileDesc >= 0) { LOG0("Shutting down socket..."); KineticSocket_Close(FileDesc); FileDesc = 0; } KineticLogger_Close(); }
void setUp(void) { KineticLogger_Init("stdout", 3); Session = (KineticSession) {.connected = false}; } void tearDown(void) { KineticLogger_Close(); } void test_KineticAllocator_NewSession_should_return_null_if_calloc_returns_null(void) { KineticCalloc_ExpectAndReturn(1, sizeof(KineticSession), NULL); KineticSession * session = KineticAllocator_NewSession(&MessageBus, &Config); TEST_ASSERT_NULL(session); }
void tearDown(void) { KineticLogger_Close(); }
void tearDown(void) { memset(&Response, 0, sizeof(Response)); KineticLogger_Close(); }
void KineticClient_Shutdown(KineticClient * const client) { KineticBus_Shutdown(client); KineticFree(client); KineticLogger_Close(); }
void KineticClient_Shutdown(void) { KineticLogger_Close(); }