Esempio n. 1
0
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();
}
Esempio n. 2
0
void test_vcmtpReceiver_new()
{
    int                         status;
    VcmtpCReceiver*             receiver;
    const char*                 addr = "224.0.0.1";
    const unsigned short        port = 1;

    status = vcmtpReceiver_new(NULL, bof_func, eof_func, missed_file_func,
            addr, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_clear();
    status = vcmtpReceiver_new(&receiver, NULL, eof_func, missed_file_func,
            addr, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_clear();
    status = vcmtpReceiver_new(&receiver, bof_func, NULL, missed_file_func,
            addr, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_clear();
    status = vcmtpReceiver_new(&receiver, bof_func, eof_func, NULL,
            addr, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_clear();
    status = vcmtpReceiver_new(&receiver, bof_func, eof_func, missed_file_func,
            NULL, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_clear();

    status = vcmtpReceiver_new(&receiver, bof_func, eof_func, missed_file_func,
            addr, port, NULL);
    OP_ASSERT_EQUAL_INT(0, status);
    log_clear();

    OP_VERIFY();
}
Esempio n. 3
0
void test_fmtpReceiver_new()
{
    int                         status;
    FmtpReceiver*              receiver;
    const char*                 addr = "224.0.0.1";
    const unsigned short        port = 1;
    const char* const           tcpAddr = "127.0.0.1";
    const unsigned short        tcpPort = 38800;

    status = mcastReceiver_new(NULL, tcpAddr, tcpPort, bof_func, eof_func,
            missed_file_func, addr, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_list_clear();
    status = mcastReceiver_new(&receiver, tcpAddr, tcpPort, NULL, eof_func,
            missed_file_func, addr, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_list_clear();
    status = mcastReceiver_new(&receiver, tcpAddr, tcpPort, bof_func, NULL,
            missed_file_func, addr, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_list_clear();
    status = mcastReceiver_new(&receiver, tcpAddr, tcpPort, bof_func, eof_func,
            NULL, addr, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_list_clear();
    status = mcastReceiver_new(&receiver, tcpAddr, tcpPort, bof_func, eof_func,
            missed_file_func, NULL, port, NULL);
    OP_ASSERT_EQUAL_INT(EINVAL, status);
    log_list_clear();

    status = mcastReceiver_new(&receiver, tcpAddr, tcpPort, bof_func, eof_func,
            missed_file_func, addr, port, NULL);
    OP_ASSERT_EQUAL_INT(0, status);
    log_list_clear();

    OP_VERIFY();
}