コード例 #1
0
ファイル: vcmtp_c_api_test.cpp プロジェクト: rmlawton/LDM
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();
}
コード例 #2
0
static void test_running()
{
    msm_lock_ExpectAndReturn(true, 0, cmp_bool);
    mcastPid = getpid(); // emulate running process
    msm_getPid_MockWithCallback(msm_getPid_callback);
    msm_unlock_ExpectAndReturn(0);
    OP_ASSERT_TRUE(mlsm_ensureRunning(feedtype) == 0);
    log_log(LOG_ERR);
    OP_VERIFY();
}
コード例 #3
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();
}
コード例 #4
0
static void test_msm_open()
{
    McastSessionMemory* msm;

    openMsm(&msm);
    OP_ASSERT_TRUE(msm != NULL);

    OP_ASSERT_TRUE(msm_close(msm));
    log_log(LOG_ERR);

    OP_VERIFY();
}
コード例 #5
0
static void test_not_running()
{
    msm_lock_ExpectAndReturn(true, 0, cmp_bool);
    mcastPid = 1; // kill(1, 0) will return -1 -- emulating no-such-process
    msm_getPid_MockWithCallback(msm_getPid_callback);
    fork_ExpectAndReturn(1);
    msm_put_ExpectAndReturn(feedtype, mcastPid, 0, cmp_int, cmp_int);
    msm_unlock_ExpectAndReturn(0);
    OP_ASSERT_TRUE(mlsm_ensureRunning(feedtype) == 0);
    log_log(LOG_ERR);
    OP_VERIFY();
}
コード例 #6
0
ファイル: nick_tests.c プロジェクト: cryogen/oftc-ircd
static void
nick_handler_when_can_not_register_changes_nick()
{
    Client client = { 0 };

    vector_get_ExpectAndReturn(NULL, 0, "Test", NULL, cmp_int);
    client_find_ExpectAndReturn("Test", NULL, cmp_cstr);
    client_set_nickname_ExpectAndReturn(&client, "Test", true, cmp_ptr, cmp_cstr);
    client_can_register_ExpectAndReturn(&client, false, cmp_ptr);

    handler(&client, NULL);

    OP_VERIFY();
}
コード例 #7
0
ファイル: nick_tests.c プロジェクト: cryogen/oftc-ircd
static void
nick_handler_when_blank_nick_sends_error()
{
    Client client = { 0 };

    vector_get_ExpectAndReturn(NULL, 0, "", NULL, cmp_int);
    server_get_this_server_ExpectAndReturn(NULL);
    client_send_ExpectAndReturn(NULL, &client, ERR_NONICKNAMEGIVEN, NULL,
                                NULL, cmp_ptr, cmp_cstr);

    handler(&client, NULL);

    OP_VERIFY();
}
コード例 #8
0
ファイル: nick_tests.c プロジェクト: cryogen/oftc-ircd
static void
nick_handler_when_in_use_send_error()
{
    Client client = { 0 };

    vector_get_ExpectAndReturn(NULL, 0, "Test", NULL, cmp_int);
    client_find_ExpectAndReturn("Test", &client, cmp_cstr);
    server_get_this_server_ExpectAndReturn(NULL);
    client_send_ExpectAndReturn(NULL, &client, ERR_NICKNAMEINUSE, NULL,
                                NULL, cmp_ptr, cmp_cstr);

    handler(&client, NULL);

    OP_VERIFY();
}
コード例 #9
0
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();
}
コード例 #10
0
ファイル: mcast_test.cpp プロジェクト: Unidata/LDM
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();
}
コード例 #11
0
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();
}
コード例 #12
0
static void test_conflict()
{
    OP_ASSERT_TRUE(mlsm_addPotentialSender(mcastInfo) == 0);
    OP_ASSERT_TRUE(mlsm_addPotentialSender(mcastInfo) == LDM7_DUP);
    OP_VERIFY();
}
コード例 #13
0
static void test_noPotentialSender()
{
    OP_ASSERT_TRUE(mlsm_ensureRunning(feedtype) == LDM7_NOENT);
    log_clear();
    OP_VERIFY();
}