Exemplo n.º 1
0
static void testSchedulerCheck (void)
{
	std::string s_one("one");
	std::string s_two("two");
	std::string s_three("three");
	std::string s_four("four");
	std::string s_five("five");

	ScheduleEventPtr three = Schedule_Event(4, nullptr, nullptr, nullptr, static_cast<void*>(&s_three));
	ScheduleEventPtr four = Schedule_Event(4, nullptr, nullptr, nullptr, static_cast<void*>(&s_four));
	ScheduleEventPtr five = Schedule_Event(4, nullptr, nullptr, nullptr, static_cast<void*>(&s_five));
	ScheduleEventPtr one = Schedule_Event(3, nullptr, delayCheck, nullptr, static_cast<void*>(&s_one));
	ScheduleEventPtr two = Schedule_Event(3, nullptr, nullptr, nullptr, static_cast<void*>(&s_two));

	ScheduleEventPtr e = Dequeue_Event(1);
	CU_ASSERT_FALSE(e);
	e = Dequeue_Event(2);
	CU_ASSERT_FALSE(e);
	/* one is delayed via check function - so we get the 2nd event at the first dequeue here */
	e = Dequeue_Event(3);
	CU_ASSERT_EQUAL_FATAL(e, two);
	/* now we are ready for the 1st event */
	e = Dequeue_Event(5);
	CU_ASSERT_EQUAL_FATAL(e, one);
	/* the remaining events are in order */
	e = Dequeue_Event(5);
	CU_ASSERT_EQUAL_FATAL(e, three);
	e = Dequeue_Event(5);
	CU_ASSERT_EQUAL_FATAL(e, four);
	e = Dequeue_Event(5);
	CU_ASSERT_EQUAL_FATAL(e, five);
}
Exemplo n.º 2
0
void test_hashMap_containsValue(void) {
    char * key = "key";
    char * value = "value";
    char * key2 = "key2";
    char * value2 = "value2";
    char * neValue = "notExisting";
    char * key3 = "key3";
    char * value3 = NULL;

    hashMap_clear(map, false, false);

    // Add one entry
    hashMap_put(map, key, value);

    // Add second entry
    hashMap_put(map, key2, value2);

    CU_ASSERT_TRUE(hashMap_containsValue(map, value));
    CU_ASSERT_TRUE(hashMap_containsValue(map, value2));
    CU_ASSERT_FALSE(hashMap_containsValue(map, neValue));
    CU_ASSERT_FALSE(hashMap_containsValue(map, NULL));

    // Add third entry with NULL value
    hashMap_put(map, key3, value3);

    CU_ASSERT_TRUE(hashMap_containsValue(map, value3));
}
Exemplo n.º 3
0
static void change_expires(){
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	LinphoneProxyConfig* proxy_config;
	register_with_refresh_base(lcm->lc,FALSE,NULL,NULL);

	linphone_core_get_default_proxy(lcm->lc,&proxy_config);

	linphone_proxy_config_edit(proxy_config);
	reset_counters(counters); /*clear stats*/

	/*nothing is supposed to arrive until done*/
	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000));

	linphone_proxy_config_set_expires(proxy_config,3);

	linphone_proxy_config_done(proxy_config);
	CU_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1));
	/*wait 2s without receive refresh*/
	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,2,2000));
	/* now, it should be ok*/
	CU_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,2));


	linphone_core_manager_destroy(lcm);
}
Exemplo n.º 4
0
static void test_compareStrAndNum() {
    int32_t num;

    CU_ASSERT_TRUE(compareStrAndNum("abcd", 1, "afgh", 1, NULL));
    CU_ASSERT_TRUE(compareStrAndNum("ABCD", 4, "abcd", 4, NULL));
    CU_ASSERT_TRUE(compareStrAndNum("AbCd", 3, "AbCE", 3, NULL));
    CU_ASSERT_TRUE(compareStrAndNum("ABCD", 1, "a", 1, NULL));

    CU_ASSERT_FALSE(compareStrAndNum("abcd", 1, "efgh", 1, NULL));
    CU_ASSERT_FALSE(compareStrAndNum("ABCD", 4, "abcd", 3, NULL));

    CU_ASSERT_TRUE(compareStrAndNum("abcd", 4, "abcd1", 5, NULL));
    CU_ASSERT_TRUE(compareStrAndNum("abcd", 4, "abcd123", 7, NULL));
    CU_ASSERT_FALSE(compareStrAndNum("abcd", 4, "abcd12A", 7, NULL));
    CU_ASSERT_FALSE(compareStrAndNum("abcd", 4, "abcdB12", 7, NULL));
    CU_ASSERT_FALSE(compareStrAndNum("abdd", 4, "abcd132", 7, NULL));

#define TEST_COMPARE_STR_AND_NUM(s1, l1, s2, l2, v, r)              \
    do {                                                            \
        num = -1;                                                    \
        CU_ASSERT_EQUAL(compareStrAndNum(s1, l1, s2, l2, &num),r);  \
        CU_ASSERT_EQUAL(num, v);                                    \
    } while(0);                                                     \

    TEST_COMPARE_STR_AND_NUM("abcd", 4, "abcd", 4, -1, TRUE);
    TEST_COMPARE_STR_AND_NUM("abcd", 4, "abcd1", 5, 1, TRUE);
    TEST_COMPARE_STR_AND_NUM("abcd", 4, "abcd123", 7, 123, TRUE);
    TEST_COMPARE_STR_AND_NUM("abcd", 4, "abcd12A", 7, -1, FALSE);
    TEST_COMPARE_STR_AND_NUM("abcd", 4, "abcdB12", 7, -1, FALSE);
    TEST_COMPARE_STR_AND_NUM("abdd", 4, "abcd132", 7, -1, FALSE);
}
Exemplo n.º 5
0
void test_grid_is_row_complete()
{
    // Create a grid.
    int numberOfRows = 4;
    int numberOfColumns = 4;
    TrnGrid* grid = trn_grid_new(numberOfRows, numberOfColumns);

    // Last row is void only.
    CU_ASSERT_FALSE( trn_grid_is_row_complete(grid,numberOfRows) );

    // Last row is full.
    TrnPositionInGrid pos;
    int columnIndex;
    pos.rowIndex = numberOfRows-1 ;
    for (columnIndex = 0 ; columnIndex < grid->numberOfColumns ; columnIndex++) {
        pos.columnIndex = columnIndex;
        trn_grid_set_cell(grid, pos, TRN_TETROMINO_I);
    }
    CU_ASSERT_TRUE( trn_grid_is_row_complete(grid,numberOfRows) );

    // Last row is full except last element. 
    pos.rowIndex = numberOfRows-1 ;
    pos.columnIndex = numberOfColumns-1 ;
    trn_grid_set_cell(grid, pos, TRN_TETROMINO_VOID);
    CU_ASSERT_FALSE( trn_grid_is_row_complete(grid,numberOfRows) );
}
Exemplo n.º 6
0
void nomls_tests()
{
	size_t first_diff = 0;
	int test_result;
	unchanged_users_v = apol_vector_create(free);
	changed_users_v = apol_vector_create(free);

	apol_vector_t *correct_unchanged_users_v = string_array_to_vector(nomls_unchanged_users);
	apol_vector_t *correct_changed_users_v = string_array_to_vector(nomls_changed_users);

	build_nomls_vecs();
	apol_vector_sort(unchanged_users_v, compare_str, NULL);
	apol_vector_sort(correct_unchanged_users_v, compare_str, NULL);
	CU_ASSERT_FALSE(test_result =
			apol_vector_compare(unchanged_users_v, correct_unchanged_users_v, compare_str, NULL, &first_diff));
	if (test_result) {
		print_test_failure(unchanged_users_v, correct_unchanged_users_v, first_diff, "Unchanged MLS Users");
	}
	apol_vector_sort(changed_users_v, compare_str, NULL);
	apol_vector_sort(correct_changed_users_v, compare_str, NULL);
	CU_ASSERT_FALSE(test_result =
			apol_vector_compare(changed_users_v, correct_changed_users_v, compare_str, NULL, &first_diff));
	if (test_result) {
		print_test_failure(changed_users_v, correct_changed_users_v, first_diff, "Changed MLS Users");
	}
	apol_vector_destroy(&unchanged_users_v);
	apol_vector_destroy(&changed_users_v);
	apol_vector_destroy(&correct_unchanged_users_v);
	apol_vector_destroy(&correct_changed_users_v);

}
Exemplo n.º 7
0
static void subscribe_failure_handle_by_app(void) {
	LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_rc");
	LinphoneProxyConfig* config;
	LinphoneFriend* lf;
	char* lf_identity=linphone_address_as_string_uri_only(pauline->identity);
	 linphone_core_get_default_proxy(marie->lc,&config);

	CU_ASSERT_TRUE(subscribe_to_callee_presence(marie,pauline));
	wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,1); /*just to wait for unsubscription even if not notified*/

	sal_set_recv_error(marie->lc->sal, 0); /*simulate an error*/

	CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneRegistrationProgress,2));
	CU_ASSERT_EQUAL(linphone_proxy_config_get_error(config),LinphoneReasonIOError);
	sal_set_recv_error(marie->lc->sal, 1);

	lf = linphone_core_get_friend_by_address(marie->lc,lf_identity);
	linphone_friend_edit(lf);
	linphone_friend_enable_subscribes(lf,FALSE); /*disable subscription*/
	linphone_friend_done(lf);
	CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneRegistrationOk,2)); /*wait for register ok*/
	linphone_friend_edit(lf);
	linphone_friend_enable_subscribes(lf,TRUE);
	linphone_friend_done(lf);
	CU_ASSERT_FALSE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,2)); /*just to wait for unsubscription even if not notified*/

	linphone_core_manager_destroy(marie);
	CU_ASSERT_FALSE(wait_for(NULL,pauline->lc,&pauline->stat.number_of_NewSubscriptionRequest,3)); /*just to wait for unsubscription even if not notified*/

	linphone_core_manager_destroy(pauline);
}
Exemplo n.º 8
0
static void test_string_ends_with() {
	CU_ASSERT_TRUE(string_ends_with("MiArchivo.txt", "txt"));
	CU_ASSERT_TRUE(string_ends_with("MiArchivo.txt", "MiArchivo.txt"));
	CU_ASSERT_FALSE(string_ends_with("MiArchivo.doc", "txt"));
	CU_ASSERT_FALSE(string_ends_with("MiDoc", "txt"));
	CU_ASSERT_FALSE(string_ends_with("", "txt"));
}
Exemplo n.º 9
0
void testNTH()
{
    list_t *l = list_new();
    for (int i = 0; i < 100; ++i)
        {
            int *x = malloc(sizeof(int));
            *x = i;
            list_add(l, x);
        }

    int *x;

    for (int i = 0; i < 100; ++i)
        {
            CU_ASSERT(list_nth(l, i, (void **)&x));
            CU_ASSERT_EQUAL(*x, i);
        }

    CU_ASSERT_FALSE(list_nth(l, -1, (void **)&x));
    CU_ASSERT_EQUAL(x, NULL);
    CU_ASSERT_FALSE(list_nth(l, 100, (void **)&x));
    CU_ASSERT_EQUAL(x, NULL);

    list_foreach(l, free);
    list_free(l);
}
Exemplo n.º 10
0
static void test_string_starts_with() {
	CU_ASSERT_TRUE(string_starts_with("#Comentario", "#"));
	CU_ASSERT_TRUE(string_starts_with("Comentario", "Comen"));
	CU_ASSERT_FALSE(string_starts_with("Comentario", "comen"));
	CU_ASSERT_FALSE(string_starts_with("Comentario", "lala"));
	CU_ASSERT_FALSE(string_starts_with("", "#"));
}
Exemplo n.º 11
0
/*
 * From 19.1.1 SIP and SIPS URI Components
 * 									   				dialog
										reg./redir. Contact/
			default  Req.-URI  To  From  Contact   R-R/Route  external
user          --          o      o    o       o          o         o
password      --          o      o    o       o          o         o
host          --          m      m    m       m          m         m
port          (1)         o      -    -       o          o         o
user-param    ip          o      o    o       o          o         o
method        INVITE      -      -    -       -          -         o
maddr-param   --          o      -    -       o          o         o
ttl-param     1           o      -    -       o          -         o
transp.-param (2)         o      -    -       o          o         o
lr-param      --          o      -    -       -          o         o
other-param   --          o      o    o       o          o         o
headers       --          -      -    -       o          -         o*/
void testUriComponentsChecker() {
	belle_sip_uri_t* uri = belle_sip_uri_parse("sip:hostonly");
	CU_ASSERT_TRUE(belle_sip_uri_check_components_from_request_uri(uri));
	belle_sip_object_unref(uri);

	{
	belle_sip_header_from_t*	header = belle_sip_header_from_parse("From: sip:linphone.org:5061");
	CU_ASSERT_FALSE(belle_sip_uri_check_components_from_context(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(header)),NULL,"From"));
	belle_sip_object_unref(header);
	}
	{
	belle_sip_header_to_t*	header = belle_sip_header_to_parse("To: sip:linphone.org?header=interdit");
	CU_ASSERT_FALSE(belle_sip_uri_check_components_from_context(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(header)),NULL,"To"));
	belle_sip_object_unref(header);
	}
	{
	belle_sip_header_contact_t*	header = belle_sip_header_contact_parse("Contact: <sip:linphone.org;lr>");
	CU_ASSERT_FALSE(belle_sip_uri_check_components_from_context(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(header)),"REGISTER","Contact"));
	CU_ASSERT_TRUE(belle_sip_uri_check_components_from_context(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(header)),NULL,"Contact"));
	belle_sip_object_unref(header);
	}
	{
	belle_sip_header_record_route_t*	header = belle_sip_header_record_route_parse("Record-Route: <sip:linphone.org;ttl=interdit>");
	CU_ASSERT_FALSE(belle_sip_uri_check_components_from_context(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(header)),NULL,"Record-Route"));
	belle_sip_object_unref(header);
	}
	{
	belle_sip_uri_t* uri = belle_sip_uri_parse("sip:linphone.org:5061?header=toto");
	CU_ASSERT_TRUE(belle_sip_uri_check_components_from_context(uri,NULL,"Any"));
	belle_sip_object_unref(uri);
	}
}
Exemplo n.º 12
0
void test_error_level() {
	CU_ASSERT_TRUE(set_log_lvl(ERROR));
	char *test_msg = "Test msg";
	int deep = 1;
	CU_ASSERT_FALSE(debug(deep, test_msg));
	CU_ASSERT_FALSE(info(deep, test_msg));
	CU_ASSERT_FALSE(warn(deep, test_msg));
	CU_ASSERT_TRUE(error(deep, test_msg));
}
static void test_is_multicast(void) {

	CU_ASSERT_TRUE(ms_is_multicast("224.1.2.3"));
	CU_ASSERT_TRUE(ms_is_multicast("239.0.0.0"));
	CU_ASSERT_TRUE(ms_is_multicast("ff02::3:2"));
	CU_ASSERT_FALSE(ms_is_multicast("192.68.0.1"));
	CU_ASSERT_FALSE(ms_is_multicast("::1"));

}
Exemplo n.º 14
0
static gboolean
xmms_metadata_test_xform_init (xmms_xform_t *xform)
{
	const gchar *musicbrainz_va_id = "89ad4ac3-39f7-470e-963a-56509c546377";
	const gchar *title, *rpgain;
	gint track, totaltracks, compilation;

	CU_ASSERT_FALSE (xmms_xform_metadata_mapper_match (xform, "missing", "missing", -1));

	/* Basic string mapping */
	CU_ASSERT_TRUE (xmms_xform_metadata_mapper_match (xform, "title", "the title", -1));
	CU_ASSERT_TRUE (xmms_xform_metadata_get_str (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_TITLE, &title));
	CU_ASSERT_STRING_EQUAL ("the title", title);

	/* Mapping track number, without total tracks */
	CU_ASSERT_TRUE (xmms_xform_metadata_mapper_match (xform, "tracknr", "1", -1));
	CU_ASSERT_TRUE (xmms_xform_metadata_get_int (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_TRACKNR, &track));
	CU_ASSERT_FALSE (xmms_xform_metadata_get_int (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_TOTALTRACKS, &totaltracks));
	CU_ASSERT_EQUAL (1, track);

	/* Mapping track number, with total tracks */
	CU_ASSERT_TRUE (xmms_xform_metadata_mapper_match (xform, "tracknr", "1/10", -1));
	CU_ASSERT_TRUE (xmms_xform_metadata_get_int (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_TRACKNR, &track));
	CU_ASSERT_TRUE (xmms_xform_metadata_get_int (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_TOTALTRACKS, &totaltracks));
	CU_ASSERT_EQUAL (1, track);
	CU_ASSERT_EQUAL (10, totaltracks);

	/* Broken track number */
	CU_ASSERT_FALSE (xmms_xform_metadata_mapper_match (xform, "tracknr", "bad", -1));

	/* Mapping compilation indicator to boolean compilation */
	CU_ASSERT_TRUE (xmms_xform_metadata_mapper_match (xform, "compilation", "1", -1));
	CU_ASSERT_TRUE (xmms_xform_metadata_get_int (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_COMPILATION, &compilation));
	CU_ASSERT_EQUAL (TRUE, compilation);

	/* Mapping compilation indicator to boolean compilation */
	CU_ASSERT_TRUE (xmms_xform_metadata_mapper_match (xform, "compilation", musicbrainz_va_id, -1));
	CU_ASSERT_TRUE (xmms_xform_metadata_get_int (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_COMPILATION, &compilation));
	CU_ASSERT_EQUAL (TRUE, compilation);


	/* Mapping replaygain to the format the replaygain xform expects */
	CU_ASSERT_TRUE (xmms_xform_metadata_mapper_match (xform, "replaygain_track_gain", "-14.69", -1));
	CU_ASSERT_TRUE (xmms_xform_metadata_get_str (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_GAIN_TRACK, &rpgain));
	CU_ASSERT_STRING_EQUAL ("0.18428", rpgain);
	CU_ASSERT_TRUE (xmms_xform_metadata_mapper_match (xform, "replaygain_track_gain", "-14.69 dB", -1));
	CU_ASSERT_TRUE (xmms_xform_metadata_get_str (xform, XMMS_MEDIALIB_ENTRY_PROPERTY_GAIN_TRACK, &rpgain));
	CU_ASSERT_STRING_EQUAL ("0.18428", rpgain);


	CU_ASSERT_TRUE (xmms_xform_metadata_mapper_match (xform, "coverart", "test", 10));

	xmms_xform_outdata_type_add (xform, XMMS_STREAM_TYPE_MIMETYPE, "audio/pcm", XMMS_STREAM_TYPE_END);

	return TRUE;
}
Exemplo n.º 15
0
static void test_compareStr() {

    CU_ASSERT_TRUE(compareStr("abcd", 1, "afgh", 1));
    CU_ASSERT_TRUE(compareStr("ABCD", 4, "abcd", 4));
    CU_ASSERT_TRUE(compareStr("AbCd", 3, "AbCE", 3));
    CU_ASSERT_TRUE(compareStr("ABCD", 1, "a", 1));

    CU_ASSERT_FALSE(compareStr("abcd", 1, "efgh", 1));
    CU_ASSERT_FALSE(compareStr("ABCD", 4, "abcd", 3));
}
static void test_vqec_seq_num_le (void) {
    result = vqec_seq_num_le(5,4);
    CU_ASSERT_FALSE(result);
    result = vqec_seq_num_le(5,5);
    CU_ASSERT(result);
    result = vqec_seq_num_le(5,6);
    CU_ASSERT(result);
    result = vqec_seq_num_le(0xb,0x8000000b);
    CU_ASSERT(result);
    result = vqec_seq_num_le(0xb,0x8000000c);
    CU_ASSERT_FALSE(result);
}
Exemplo n.º 17
0
static void _dead_thread_two (void)
{
	s4_transaction_t *trans = s4_begin (s4, 0);

	CU_ASSERT_PTR_NOT_NULL (trans);
	g_usleep (G_USEC_PER_SEC / 2);
	CU_ASSERT_TRUE (s4_add (trans, "b", val, "a", val, "src"));
	g_usleep (G_USEC_PER_SEC);
	CU_ASSERT_FALSE (s4_add (trans, "a", val, "b", val, "src"));

	CU_ASSERT_FALSE (s4_commit (trans));
	CU_ASSERT_EQUAL (s4_errno (), S4E_DEADLOCK);
}
Exemplo n.º 18
0
void TestGridCellIsInGrid()
{
    // Create a grid.
    int numberOfRows = 2;
    int numberOfColumns = 3;
    TrnGrid* grid = trn_grid_new(numberOfRows, numberOfColumns);

    TrnPositionInGrid pos;
    int rowIndex;
    int columnIndex;

    // Check position that are in grid
    for (rowIndex = 0 ; rowIndex < numberOfRows; rowIndex++) {
        pos.rowIndex = rowIndex;
        for (columnIndex = 0 ; columnIndex < numberOfColumns ; columnIndex++) {
            pos.columnIndex = columnIndex;
            CU_ASSERT_TRUE(trn_grid_cell_is_in_grid(grid, pos));
        }
    }

    // Check row out of grid from top.
    pos.rowIndex = -1;
    for (columnIndex = 0 ; columnIndex < numberOfColumns ; columnIndex++) {
        pos.columnIndex = columnIndex;
        CU_ASSERT_FALSE(trn_grid_cell_is_in_grid(grid, pos));
    }

    // Check row out of grid from bottom.
    pos.rowIndex = numberOfRows;
    for (columnIndex = 0 ; columnIndex < numberOfColumns ; columnIndex++) {
        pos.columnIndex = columnIndex;
        CU_ASSERT_FALSE(trn_grid_cell_is_in_grid(grid, pos));
    }

    // Check column out of grid from left.
    pos.columnIndex = -1;
    for (rowIndex = 0 ; rowIndex < numberOfRows; rowIndex++) {
        pos.rowIndex = rowIndex;
        CU_ASSERT_FALSE(trn_grid_cell_is_in_grid(grid, pos));
    }

    // Check column out of grid from right.
    pos.columnIndex = numberOfColumns;
    for (rowIndex = 0 ; rowIndex < numberOfRows; rowIndex++) {
        pos.rowIndex = rowIndex;
        CU_ASSERT_FALSE(trn_grid_cell_is_in_grid(grid, pos));
    }
}
Exemplo n.º 19
0
void test_singlePattern(void)
{
    HObs hObs = NULL;
    RU8 pattern[] = { 0x01, 0x02, 0x03, 0x04 };
    RU8 buffer1[] = { 0x02, 0x04, 0xFF, 0xEF, 0x01, 0x02, 0x03, 0x04 };
    RU8 buffer2[] = { 0x02, 0x04, 0xFF, 0xEF, 0x01, 0x02, 0x03, 0x04, 0xEE, 0x6F };
    RU8 buffer3[] = { 0x02, 0x04, 0xFF, 0xEF, 0x01, 0x02, 0x01, 0x04, 0xEE, 0x6F };
    RU8 buffer4[] = { 0x02, 0x04, 0xFF, 0xEF, 0x01, 0x02, 0x03, 0x04, 0xEE, 0x6F, 0x01, 0x02, 0x03, 0x04 };
    RU32 context = 0;
    PVOID hitCtx = NULL;
    RU8* hitLoc = NULL;

    hObs = obsLib_new( 0, 0 );

    CU_ASSERT_TRUE_FATAL( rpal_memory_isValid( hObs ) );

    CU_ASSERT_TRUE_FATAL( obsLib_addPattern( hObs, (RPU8)&pattern, sizeof( pattern ), &context ) );

    // 1 pattern found end of buffer
    CU_ASSERT_TRUE_FATAL( obsLib_setTargetBuffer( hObs, buffer1, sizeof( buffer1 ) ) );
    CU_ASSERT_TRUE( obsLib_nextHit( hObs, &hitCtx, &hitLoc ) );
    CU_ASSERT_EQUAL( hitCtx, &context );
    CU_ASSERT_EQUAL( hitLoc, buffer1 + sizeof( buffer1 ) - 4 );
    CU_ASSERT_FALSE( obsLib_nextHit( hObs, &hitCtx, &hitLoc ) );

    // 1 pattern found middle of buffer
    CU_ASSERT_TRUE_FATAL( obsLib_setTargetBuffer( hObs, buffer2, sizeof( buffer2 ) ) );
    CU_ASSERT_TRUE( obsLib_nextHit( hObs, &hitCtx, &hitLoc ) );
    CU_ASSERT_EQUAL( hitCtx, &context );
    CU_ASSERT_EQUAL( hitLoc, buffer2 + sizeof( buffer2 ) - 6 );
    CU_ASSERT_FALSE( obsLib_nextHit( hObs, &hitCtx, &hitLoc ) );

    // 0 pattern found
    CU_ASSERT_TRUE_FATAL( obsLib_setTargetBuffer( hObs, buffer3, sizeof( buffer3 ) ) );
    CU_ASSERT_FALSE( obsLib_nextHit( hObs, &hitCtx, &hitLoc ) );

    // 2 pattern found end and middle of buffer
    CU_ASSERT_TRUE_FATAL( obsLib_setTargetBuffer( hObs, buffer4, sizeof( buffer4 ) ) );
    CU_ASSERT_TRUE( obsLib_nextHit( hObs, &hitCtx, &hitLoc ) );
    CU_ASSERT_EQUAL( hitCtx, &context );
    CU_ASSERT_EQUAL( hitLoc, buffer4 + sizeof( buffer4 ) - 10 );
    CU_ASSERT_TRUE( obsLib_nextHit( hObs, &hitCtx, &hitLoc ) );
    CU_ASSERT_EQUAL( hitCtx, &context );
    CU_ASSERT_EQUAL( hitLoc, buffer4 + sizeof( buffer4 ) - 4 );
    CU_ASSERT_FALSE( obsLib_nextHit( hObs, &hitCtx, &hitLoc ) );

    obsLib_free( hObs );
}
Exemplo n.º 20
0
static void proxy_transport_change_with_wrong_port_givin_up() {
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	LinphoneProxyConfig* proxy_config;
	LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
	char route[256];
	LCSipTransports transport= {LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM};
	sprintf(route,"sip:%s",test_route);

	linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/

	register_with_refresh_base_3(lcm->lc, FALSE, auth_domain, "sip2.linphone.org:5987", 0,transport,LinphoneRegistrationProgress);

	linphone_core_get_default_proxy(lcm->lc,&proxy_config);
	linphone_proxy_config_edit(proxy_config);

	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000));
	linphone_proxy_config_enableregister(proxy_config,FALSE);
	linphone_proxy_config_done(proxy_config);

	CU_ASSERT(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1));
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationOk,0);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,1);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0);

	linphone_core_manager_destroy(lcm);

}
Exemplo n.º 21
0
void test_string_function_registry()
{
  function_registry* fr = string_function_registry();
  char* tester = "hello";

  /* start the tests */
  printf("Test string_function_registry: ");
  CU_ASSERT_TRUE(!strcmp(fr->name, "string"));

  /* test the copy function */
  char* cpy = (char*)fr->copy(tester);
  CU_ASSERT_TRUE(!strcmp(cpy, tester));

  /* test to be sure that it is actually a copy */
  tester = "world";
  CU_ASSERT_FALSE(!strcmp(cpy, tester));

  /* free memory */
  fr->destroy(cpy);
  free(fr);

  /* finish the test */
  test_failure();
  printf("\n");
}
Exemplo n.º 22
0
static void testItemToHeadgear (void)
{
	inventory_t inv;
	const objDef_t *od;
	const invDef_t *container;
	item_t item;

	ResetInventoryList();

	OBJZERO(inv);

	od = INVSH_GetItemByIDSilent("irgoggles");
	CU_ASSERT_PTR_NOT_NULL_FATAL(od);

	container = INVSH_GetInventoryDefinitionByID("headgear");
	CU_ASSERT_PTR_NOT_NULL_FATAL(container);

	item.t = od;
	item.m = NULL;
	item.a = 0;

	CU_ASSERT_FALSE(INVSH_ExistsInInventory(&inv, container, &item));

	CU_ASSERT_PTR_NOT_NULL(i.AddToInventory(&i, &inv, &item, container, NONE, NONE, 1));

	CU_ASSERT_TRUE(INVSH_ExistsInInventory(&inv, container, &item));

	CU_ASSERT_PTR_NULL(i.AddToInventory(&i, &inv, &item, container, NONE, NONE, 1));
}
Exemplo n.º 23
0
static void testSpawnAndConnect (void)
{
	char userinfo[MAX_INFO_STRING];
	player_t *player;
	const char *name = "name";
	bool day = true;
	byte *buf;
	/* this entity string may not contain any inline models, we don't have the bsp tree loaded here */
	const int size = FS_LoadFile("game/entity.txt", &buf);
	edict_t *e = NULL;
	int cnt = 0;

	CU_ASSERT_NOT_EQUAL_FATAL(size, -1);
	CU_ASSERT_FATAL(size > 0);

	SV_InitGameProgs();
	/* otherwise we can't link the entities */
	SV_ClearWorld();

	player = G_PlayerGetNextHuman(0);
	svs.ge->SpawnEntities(name, day, (const char *)buf);
	CU_ASSERT_TRUE(svs.ge->ClientConnect(player, userinfo, sizeof(userinfo)));
	CU_ASSERT_FALSE(svs.ge->RunFrame());

	while ((e = G_EdictsGetNextInUse(e))) {
		Com_Printf("entity %i: %s\n", cnt, e->classname);
		cnt++;
	}

	CU_ASSERT_EQUAL(cnt, 45);

	SV_ShutdownGameProgs();
	FS_FreeFile(buf);
}
Exemplo n.º 24
0
void test_llist_rm_first(void) {
  Llist list = NULL;
  Node arc1;
  Node arc2;
  node_alloc(&arc1);
  node_alloc(&arc2);
  arc1.score = 150;
  arc2.score = 151;

  /* See if trying to suppress an element of an empty list works */
  CU_ASSERT_TRUE(llist_rm_first(&list));

  /* Add something in order to suppress it later */
  llist_add(arc1, &list);
  llist_add(arc2, &list);

  /* Suppress the first element of the list */
  llist_rm_first(&list);

  /* See if the remaining list have arc2 has its first element */
  CU_ASSERT_TRUE(node_is_equal(list->value, arc1));

  /* See deleting an element returns 0 */
  CU_ASSERT_FALSE(llist_rm_first(&list));

  /* Confirm the list is now a NULL pointer */
  CU_ASSERT_PTR_NULL(list);

  node_free(&arc1);
  node_free(&arc2);
}
Exemplo n.º 25
0
void test_hashMap_remove(void) {
    char * key = "key";
    char * value = "value";
    char * key2 = NULL;
    char * value2 = "value2";
    char * removeKey;

    hashMap_clear(map, false, false);

    // Add one entry
    hashMap_put(map, key, value);

    // Add second entry with null key
    hashMap_put(map, key2, value2);

    // Remove unexisting entry for map
    removeKey = "unexisting";
    hashMap_remove(map, removeKey);
    CU_ASSERT_EQUAL(map->size, 2);
    CU_ASSERT_FALSE(hashMap_isEmpty(map));

    hashMap_remove(map, key);
    CU_ASSERT_EQUAL(map->size, 1);

    hashMap_remove(map, key2);
    CU_ASSERT_EQUAL(map->size, 0);
    CU_ASSERT_TRUE(hashMap_isEmpty(map));

    // Remove unexisting entry for empty map
    removeKey = "unexisting";
    hashMap_remove(map, removeKey);
    CU_ASSERT_EQUAL(map->size, 0);
    CU_ASSERT_TRUE(hashMap_isEmpty(map));
}
Exemplo n.º 26
0
static void test_cimunit_init_event_with_thread(void)
{
    char event_name[] = "test";
    char thread_name[] = "thread";

    cimunit_event_t event;
    cimunit_event_init_with_thread(&event, event_name, thread_name);
  
    /// - Verify the event name is initialized
    CU_ASSERT_PTR_NOT_NULL_FATAL(event.event_name);
    CU_ASSERT_STRING_EQUAL(event.event_name, event_name);

    /// - Verify the thread name is initialized
    CU_ASSERT_PTR_NOT_NULL_FATAL(event.thread_name);
    CU_ASSERT_STRING_EQUAL(event.thread_name, thread_name);
    
    CU_ASSERT_FALSE(event.is_action);
  
    /// - No cross platform tests for mutex configuration
  
    /// - Verify the dependent events list is empty
    CU_ASSERT_PTR_NULL(event.action_events);
  
    cimunit_event_destroy(&event);
}
Exemplo n.º 27
0
static void io_recv_error_without_active_register(){
	LinphoneCoreManager *mgr;
	LinphoneCore* lc;
	int register_ok;
	stats* counters ;
	int number_of_udp_proxy=0;
	MSList* proxys;

	mgr=configure_lcm();
	lc=mgr->lc;
	counters = get_stats(lc);
	
	register_ok=counters->number_of_LinphoneRegistrationOk;
	number_of_udp_proxy=get_number_of_udp_proxy(lc);

	for (proxys=ms_list_copy(linphone_core_get_proxy_config_list(lc));proxys!=NULL;proxys=proxys->next) {
		LinphoneProxyConfig* proxy_cfg=(LinphoneProxyConfig*)proxys->data;
		linphone_proxy_config_edit(proxy_cfg);
		linphone_proxy_config_enable_register(proxy_cfg,FALSE);
		linphone_proxy_config_done(proxy_cfg);
	}
	ms_list_free(proxys);
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationCleared,register_ok /*because 1 udp*/));

	sal_set_recv_error(lc->sal, 0);

	/*nothing should happen because no active registration*/
	CU_ASSERT_FALSE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationProgress,2*(register_ok-number_of_udp_proxy) /*because 1 udp*/));

	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0)

	sal_set_recv_error(lc->sal, 1); /*reset*/

	linphone_core_manager_destroy(mgr);
}
Exemplo n.º 28
0
void rer_test_flags()
{
	{
		RER rer=rer_create("foo", "bar", "");
		CU_ASSERT_PTR_NOT_NULL_FATAL(rer);
		int flags = rer_getflags(rer);
		CU_ASSERT_EQUAL(flags, 0);
		flags = rer_setflag(rer, RER_F_GLOBAL);
		CU_ASSERT_EQUAL(flags, RER_F_GLOBAL);
		flags = rer_setflag(rer, RER_F_DRY_RUN);
		CU_ASSERT_EQUAL(flags, RER_F_GLOBAL | RER_F_DRY_RUN);
		flags = rer_getflags(rer);
		CU_ASSERT_EQUAL(flags, RER_F_GLOBAL | RER_F_DRY_RUN);
		flags = rer_clrflag(rer, RER_F_GLOBAL);
		CU_ASSERT_EQUAL(flags, RER_F_DRY_RUN);
		int ret = rer_chkflag(rer, RER_F_DRY_RUN);
		CU_ASSERT_TRUE(ret);
		ret = rer_chkflag(rer, RER_F_GLOBAL);
		CU_ASSERT_FALSE(ret);
		flags = rer_clrflag(rer, RER_F_DRY_RUN);
		CU_ASSERT_EQUAL(flags, 0);
		rer_destroy(rer);
	}
	{
		RER rer=rer_create("foo", "bar", "g");
		CU_ASSERT_PTR_NOT_NULL_FATAL(rer);
		int flags = rer_getflags(rer);
		CU_ASSERT_EQUAL(flags, RER_F_GLOBAL);
		rer_destroy(rer);
	}
}
Exemplo n.º 29
0
static void test_set_possible_timeslot(void) {
    init_test_exam();
    exam *test_exams[] = {exam1, exam2, exam3, exam4,
                            exam5, exam6, exam7, exam8};
    init_test_array_exams(8, test_exams);
    preprocess(exams);
    /* Timeslots for Exam 1 : same as availabilities (0 exams scheduled) */
    bool *timeslots_exam1 = set_possible_timeslot(exams->data[0], exams,
                                                    MAX_TIMESLOT);
    for(int i = 0; i < MAX_TIMESLOT; i++)
        CU_ASSERT_EQUAL(timeslots_exam1[i], exams->data[0]->availabilities[i]);
    free(timeslots_exam1);
    /* Schedule Exam 1 at timeslot 2 (index 1)*/
    exams->data[0]->timeslot = 1;
    /* Timeslots for Exam 7 : conflict with Exam 1 */
    bool *timeslots_exam7 = set_possible_timeslot(exams->data[6], exams,
                                                    MAX_TIMESLOT);
    CU_ASSERT_EQUAL(timeslots_exam7[0], exams->data[6]->availabilities[0]);
    /* Conflict */
    CU_ASSERT_FALSE(timeslots_exam7[1]);
    CU_ASSERT_EQUAL(timeslots_exam7[2], exams->data[6]->availabilities[2]);
    CU_ASSERT_EQUAL(timeslots_exam7[3], exams->data[6]->availabilities[3]);
    CU_ASSERT_EQUAL(timeslots_exam7[4], exams->data[6]->availabilities[4]);
    free(timeslots_exam7);
    clean_array_exams();
}
Exemplo n.º 30
0
/**
* @brief fo_tableExists() tests:
*   - Check for an existing table
*   - Check for table that does not exist
*   - Check for a non table entities (sequence, constraint, ...)
* @return void
*/
void test_fo_tableExists()
{
  PGconn* pgConn;
  int nonexistant_table;
  int existing_table;
  char* DBConfFile = dbConf;
  char* ErrorBuf;

  pgConn = fo_dbconnect(DBConfFile, &ErrorBuf);

  CU_ASSERT_PTR_NOT_NULL(pgConn);

  nonexistant_table = fo_tableExists(pgConn, "nonexistanttable");
  CU_ASSERT_FALSE(nonexistant_table);

  PGresult* result = PQexec(pgConn, "CREATE table exists()");
  CU_ASSERT_PTR_NOT_NULL_FATAL(result);
  CU_ASSERT_FALSE_FATAL(fo_checkPQcommand(pgConn, result, "create", __FILE__, __LINE__));

  existing_table = fo_tableExists(pgConn, "exists");
  CU_ASSERT_TRUE(existing_table);

  PQfinish(pgConn);
  return;
}