void test_mdl_createAndExecute() { int status; pqueue* pq = (pqueue*)1; char* const tcpAddr = "127.0.0.1"; const unsigned short tcpPort = 38800; char* const addr = "224.0.0.1"; const unsigned short port = 1; int (*int_func)() = (int(*)())1; void (*void_func)() = (void(*)())2; McastInfo mcastInfo; Mdl* mdl; mcastInfo.group.addr = addr; mcastInfo.group.port = port; mcastInfo.server.addr = tcpAddr; mcastInfo.server.port = tcpPort; /* Invalid product-queue argument */ mdl = mdl_new(NULL, &mcastInfo, void_func, NULL); log_log(LOG_INFO); OP_ASSERT_TRUE(mdl == NULL); log_clear(); /* Invalid multicast information argument */ mdl = mdl_new(pq, NULL, void_func, NULL); log_log(LOG_INFO); OP_ASSERT_TRUE(mdl == NULL); log_clear(); /* Invalid missed-product-function argument */ mdl = mdl_new(pq, &mcastInfo, NULL, NULL); log_log(LOG_INFO); OP_ASSERT_TRUE(mdl == NULL); log_clear(); /* Trivial execution */ vcmtpReceiver_new_ExpectAndReturn( NULL, tcpAddr, tcpPort, int_func, int_func, void_func, addr, port, NULL, 0, NULL, cmp_cstr, cmp_short, NULL, NULL, NULL, cmp_cstr, cmp_short, NULL); mdl = mdl_new(pq, &mcastInfo, void_func, NULL); log_log(LOG_INFO); OP_ASSERT_FALSE(mdl == NULL); vcmtpReceiver_execute_ExpectAndReturn(NULL, 0, NULL); status = mdl_start(mdl); log_log(LOG_INFO); OP_ASSERT_EQUAL_INT(LDM7_SHUTDOWN, status); vcmtpReceiver_free_ExpectAndReturn(NULL, NULL); mdl_free(mdl); log_log(LOG_INFO); OP_VERIFY(); }
static void test_last_mcast_prod() { McastSessionMemory* msm; int status; getLdmLogDir_ExpectAndReturn(CWD); OP_ASSERT_TRUE(msm_delete(SERVICE_ADDR, MCAST_GROUP_ID)); openMsm(&msm); signaturet sig1; status = msm_getLastMcastProd(msm, sig1); log_log(LOG_ERR); OP_ASSERT_FALSE(status); signaturet sig2; (void)memset(&sig2, 1, sizeof(sig2)); status = msm_setLastMcastProd(msm, sig2); log_log(LOG_ERR); OP_ASSERT_TRUE(status); status = msm_getLastMcastProd(msm, sig1); log_log(LOG_ERR); OP_ASSERT_TRUE(status); OP_ASSERT_TRUE(memcmp(&sig1, &sig2, sizeof(sig1)) == 0); status = msm_close(msm); log_log(LOG_ERR); OP_ASSERT_TRUE(status); // Verify the data in the new file openMsm(&msm); status = msm_getLastMcastProd(msm, sig1); log_log(LOG_ERR); OP_ASSERT_TRUE(status); OP_ASSERT_TRUE(memcmp(&sig1, &sig2, sizeof(signaturet)) == 0); status = msm_close(msm); log_log(LOG_ERR); OP_ASSERT_TRUE(status); OP_VERIFY(); }
static void test_missed_mcast_files() { McastSessionMemory* msm; int status; McastProdIndex iProd; openMsm(&msm); msm_clearAllMissedFiles(msm); status = msm_getAnyMissedFileNoWait(msm, &iProd); log_log(LOG_ERR); OP_ASSERT_FALSE(status); status = msm_addMissedFile(msm, 1); OP_ASSERT_TRUE(status); status = msm_addMissedFile(msm, 2); OP_ASSERT_TRUE(status); status = msm_addMissedFile(msm, 3); OP_ASSERT_TRUE(status); status = msm_peekMissedFileNoWait(msm, &iProd); OP_ASSERT_TRUE(status); OP_ASSERT_TRUE(iProd == 1); status = msm_addRequestedFile(msm, iProd); OP_ASSERT_TRUE(status); status = msm_removeMissedFileNoWait(msm, &iProd); OP_ASSERT_TRUE(status); OP_ASSERT_TRUE(iProd == 1); status = msm_removeMissedFileNoWait(msm, &iProd); OP_ASSERT_TRUE(status); OP_ASSERT_TRUE(iProd == 2); status = msm_addRequestedFile(msm, iProd); OP_ASSERT_TRUE(status); status = msm_removeRequestedFileNoWait(msm, &iProd); OP_ASSERT_TRUE(status); OP_ASSERT_TRUE(iProd == 1); msm_close(msm); log_log(LOG_ERR); OP_ASSERT_TRUE(status); openMsm(&msm); status = msm_getAnyMissedFileNoWait(msm, &iProd); log_log(LOG_ERR); OP_ASSERT_TRUE(status); OP_ASSERT_TRUE(iProd = 2); status = msm_getAnyMissedFileNoWait(msm, &iProd); log_log(LOG_ERR); OP_ASSERT_TRUE(status); OP_ASSERT_TRUE(iProd = 3); status = msm_getAnyMissedFileNoWait(msm, &iProd); log_log(LOG_ERR); OP_ASSERT_FALSE(status); msm_close(msm); OP_VERIFY(); }