/******************************************************************************* * Entry point ******************************************************************************/ int main(int argc, char *argv[argc]) { // We first parse command line switchs opt_t opt = opt_defaults; opt_parse(argc, argv, &opt); // Next we prepare the model rdr_t *rdr = rdr_new(opt.maxent); rdr->min_count = opt.min_count; mdl_t *mdl = mdl_new(rdr); mdl->opt = &opt; // And switch to requested mode switch (opt.mode) { case 0: dotrain(mdl); break; case 1: dolabel(mdl); break; case 2: dodump(mdl); break; case 3: doupdt(mdl); break; } // And cleanup mdl_free(mdl); return EXIT_SUCCESS; }
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(); }