Ejemplo n.º 1
0
void 
    test_processInfo
    (
        void
    )
{
    processLibProcEntry* entries = NULL;
    RU32 entryIndex = 0;
    rSequence proc = NULL;
    RPWCHAR path = NULL;

    entries = processLib_getProcessEntries( TRUE );

    CU_ASSERT_PTR_NOT_EQUAL_FATAL( entries, NULL );

    CU_ASSERT_NOT_EQUAL_FATAL( entries[ entryIndex ].pid, 0 );

    proc = processLib_getProcessInfo( entries[ entryIndex ].pid );

    CU_ASSERT_PTR_NOT_EQUAL( proc, NULL );

    CU_ASSERT_TRUE( rSequence_getSTRINGW( proc, RP_TAGS_FILE_PATH, &path ) );

    CU_ASSERT_PTR_NOT_EQUAL( path, NULL );
    CU_ASSERT_NOT_EQUAL( rpal_string_strlenw( path ), 0 );

    rSequence_free( proc );

    rpal_memory_free( entries );
}
Ejemplo n.º 2
0
void 
    test_modules
    (
        void
    )
{
    processLibProcEntry* entries = NULL;
    RU32 entryIndex = 0;
    rList mods = NULL;
    rSequence mod = NULL;
    RPWCHAR path = NULL;

    entries = processLib_getProcessEntries( TRUE );

    CU_ASSERT_PTR_NOT_EQUAL_FATAL( entries, NULL );

    CU_ASSERT_NOT_EQUAL_FATAL( entries[ entryIndex ].pid, 0 );

    mods = processLib_getProcessModules( entries[ entryIndex ].pid );

    CU_ASSERT_PTR_NOT_EQUAL( mods, NULL );

    CU_ASSERT_TRUE( rList_getSEQUENCE( mods, RP_TAGS_DLL, &mod ) );

    CU_ASSERT_TRUE( rSequence_getSTRINGW( mod, RP_TAGS_FILE_PATH, &path ) );

    CU_ASSERT_PTR_NOT_EQUAL( path, NULL );
    CU_ASSERT_NOT_EQUAL( rpal_string_strlenw( path ), 0 );

    rSequence_free( mods );

    rpal_memory_free( entries );
}
Ejemplo n.º 3
0
void test_phalcon_cpy_wrt_ctor(void)
{
	startup_php(__func__);
	zend_first_try {
		zval* dest;
		zval* src;

		PHALCON_MM_GROW();
		/* dest is not observed by Phalcon */
			MAKE_STD_ZVAL(dest);
			ZVAL_STRING(dest, "R^itaM cha svAdhyAyapravachane cha", 1);

			PHALCON_INIT_VAR(src);
			ZVAL_STRING(src, "satyaM cha svAdhyAyapravachane cha", 1);

			PHALCON_CPY_WRT_CTOR(dest, src);

			CU_ASSERT_PTR_NOT_EQUAL(dest, src);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(src), 1);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(dest), 1);
			CU_ASSERT_EQUAL(Z_TYPE_P(src), IS_STRING);
			CU_ASSERT_EQUAL(Z_ISREF_P(src), 0);
			CU_ASSERT_EQUAL(Z_ISREF_P(dest), 0);
		PHALCON_MM_RESTORE();

		CU_ASSERT_EQUAL(_mem_block_check(dest, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
		CU_ASSERT_PTR_NOT_EQUAL(dest, src);
		CU_ASSERT_EQUAL(Z_REFCOUNT_P(dest), 1);
		CU_ASSERT_STRING_EQUAL(Z_STRVAL_P(dest), "satyaM cha svAdhyAyapravachane cha");
		zval_ptr_dtor(&dest);

		PHALCON_MM_GROW();
		/* dest will be observed by Phalcon */
			dest = NULL;

			PHALCON_INIT_VAR(src);
			ZVAL_STRING(src, "satyaM cha svAdhyAyapravachane cha", 1);

			PHALCON_CPY_WRT_CTOR(dest, src);

			CU_ASSERT_PTR_NOT_EQUAL(dest, src);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(src), 1);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(dest), 1);
			CU_ASSERT_EQUAL(Z_TYPE_P(src), IS_STRING);
			CU_ASSERT_EQUAL(Z_ISREF_P(src), 0);
			CU_ASSERT_EQUAL(Z_ISREF_P(dest), 0);
		PHALCON_MM_RESTORE();
		/* At this point dest will be destroyed */

	}
	zend_catch {
		CU_ASSERT(0);
	}
	zend_end_try();

	shutdown_php();
	CU_ASSERT_EQUAL(leaks, 0);
}
Ejemplo n.º 4
0
void test_malloc_deux_pointeurs_differents() {
	void* ptr = mymalloc(4);
	void* ptr2= mymalloc(4);
	CU_ASSERT_PTR_NOT_EQUAL(ptr, ptr2);
	myfree(ptr);
	myfree(ptr2);
}
Ejemplo n.º 5
0
static void test_string_substring_until_middle() {
	char *original = "hola mundo!";
	char *substring = string_substring_until(original, 5);
	CU_ASSERT_STRING_EQUAL(substring, "hola ");
	CU_ASSERT_PTR_NOT_EQUAL(substring, original);
	free(substring);
}
Ejemplo n.º 6
0
static void test_string_substring_until_end() {
	char *original = "hola mundo!";
	char *substring = string_substring_until(original, strlen(original));
	CU_ASSERT_STRING_EQUAL(substring, original);
	CU_ASSERT_PTR_NOT_EQUAL(substring, original);
	free(substring);
}
Ejemplo n.º 7
0
static void test_string_substring_from_middle() {
	char *original = "hola mundo!";
	char *substring = string_substring_from(original, 5);
	CU_ASSERT_STRING_EQUAL(substring, "mundo!");
	CU_ASSERT_PTR_NOT_EQUAL(substring, &(original[5]));
	free(substring);
}
Ejemplo n.º 8
0
static void test_string_substring_from_start() {
	char *original = "hola mundo!";
	char *substring = string_substring_from(original, 0);
	CU_ASSERT_STRING_EQUAL(substring, original);
	CU_ASSERT_PTR_NOT_EQUAL(substring, original);
	free(substring);
}
Ejemplo n.º 9
0
static void test_string_substring_with_equal_large() {
	char* original_word = "hola";
	char* substring = string_substring(original_word, 0, 4);
	CU_ASSERT_STRING_EQUAL(substring, original_word);
	CU_ASSERT_PTR_NOT_EQUAL(substring, original_word);
	free(substring);
}
Ejemplo n.º 10
0
static void test_string_substring_extract_internal_text() {
        char* original_word = "hola mundo";
        char* substring = string_substring(original_word, 2, 5);
        CU_ASSERT_STRING_EQUAL(substring, "la mu");
        CU_ASSERT_PTR_NOT_EQUAL(substring, original_word);
        free(substring);
}
Ejemplo n.º 11
0
static void test_string_substring_from_other_start() {
        char* original_word = "hola mundo!";
        char* substring = string_substring(original_word, 5, strlen(original_word) - 5);
        CU_ASSERT_STRING_EQUAL(substring, "mundo!");
        CU_ASSERT_PTR_NOT_EQUAL(substring, original_word);
        free(substring);
}
Ejemplo n.º 12
0
void test_pointer_function_registry()
{
  function_registry* fr = pointer_function_registry();
  int* tester = (int*)&fr;

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

  /* test the copy function */
  void** cpy = (void**)fr->copy(&tester);
  CU_ASSERT_PTR_EQUAL(*cpy, tester);

  /* test to be sure that it is actually a copy */
  tester = (int*)&tester;
  CU_ASSERT_PTR_NOT_EQUAL(*cpy, tester);

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

  /* finish the test */
  test_failure();
  printf("\n");
}
Ejemplo n.º 13
0
void bi_list_test_pop_back_tail(void)
{
	TBiList list;
	TBiElement head;
	TBiElement tail;

	bi_list_ctor(&list);
	bi_element_ctor(&head);
	bi_element_ctor(&tail);

	bi_list_push_back(&list, &head);
	bi_list_push_back(&list, &tail);

	TBiElement* old_tail = list.tail;
	TBiElement* old_tail_prev = old_tail->prev;

	TBiElement* back = bi_list_pop_back(&list);

	/* check if back is not 0 */
	CU_ASSERT_PTR_NOT_EQUAL(0, back);
	/* check if back is the old_tail */
	CU_ASSERT_PTR_EQUAL(back, old_tail);
	/* check if new tail is the predecessor of the old_tail */
	CU_ASSERT_PTR_EQUAL(old_tail_prev, list.tail);
}
static void ipv4_and_ipv6_dns_server(void) {
	struct addrinfo *ai;
	int timeout;
	endpoint_t *client;
	const char *nameservers[]={
		"8.8.8.8",
		"2a01:e00::2",
		NULL
	};
	
	if (!belle_sip_tester_ipv6_available()){
		belle_sip_warning("Test skipped, IPv6 connectivity not available.");
		return;
	}
	client = create_endpoint();
	CU_ASSERT_PTR_NOT_NULL_FATAL(client);
	timeout = belle_sip_stack_get_dns_timeout(client->stack);
	set_custom_resolv_conf(client->stack,nameservers);
	client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_SIP_DOMAIN, SIP_PORT, AF_INET, a_resolve_done, client);
	CU_ASSERT_NOT_EQUAL(client->resolver_ctx, NULL);
	CU_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout));
	CU_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL);
	if (client->ai_list) {
		struct sockaddr_in *sock_in = (struct sockaddr_in *)client->ai_list->ai_addr;
		CU_ASSERT_EQUAL(ntohs(sock_in->sin_port), SIP_PORT);
		ai = belle_sip_ip_address_to_addrinfo(AF_INET, IPV4_SIP_IP, SIP_PORT);
		if (ai) {
			CU_ASSERT_EQUAL(sock_in->sin_addr.s_addr, ((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr);
			belle_sip_freeaddrinfo(ai);
		}
	}

	destroy_endpoint(client);
}
Ejemplo n.º 15
0
static void test_queue(void)
{
	struct ofp_ifqueue ifq;
	struct ifq_entry e;

	ifq.ifq_tail = NULL;
	ifq.ifq_len = 0;
	e.next = NULL;

	odp_packet_t m = odp_packet_alloc(ofp_packet_pool, 0);

	IF_ENQUEUE(&ifq, m) while (0);
	CU_ASSERT_PTR_NOT_NULL(ifq.ifq_head);
	CU_ASSERT_PTR_EQUAL(ifq.ifq_head, ifq.ifq_tail);
	CU_ASSERT_PTR_NULL(ifq.ifq_tail->next);
	CU_ASSERT_EQUAL(ifq.ifq_len, 1);

	ifq.ifq_head = ifq.ifq_tail = &e;

	IF_ENQUEUE(&ifq, m) while (0);
	CU_ASSERT_PTR_NOT_NULL(ifq.ifq_head);
	CU_ASSERT_PTR_NOT_NULL(ifq.ifq_tail);
	CU_ASSERT_PTR_NOT_EQUAL(ifq.ifq_head, ifq.ifq_tail);
	CU_ASSERT_PTR_EQUAL(ifq.ifq_head->next, ifq.ifq_tail);
	CU_ASSERT_PTR_NULL(ifq.ifq_tail->next);
	CU_ASSERT_EQUAL(ifq.ifq_len, 2);

	odp_packet_free(m);
}
Ejemplo n.º 16
0
void bi_list_test_push_back_next(void)
{
	TBiList list;
	TBiElement head;
	TBiElement next;

	bi_list_ctor(&list);
	bi_element_ctor(&head);
	bi_element_ctor(&next);

	bi_list_push_back(&list, &head);

	TBiElement* oldTail = list.tail;

	bi_list_push_back(&list, &next);

	/* check if list is not empty */
	CU_ASSERT_EQUAL(0, bi_list_empty(&list));
	/* check if next is a new tail of the list */
	CU_ASSERT_PTR_EQUAL(&next, list.tail);
	/* check if on the list are more than one element */
	CU_ASSERT_PTR_NOT_EQUAL(list.head, list.tail);
	/* check if oldTail is the predecessor of next */
	CU_ASSERT_PTR_EQUAL(oldTail, next.prev);
	/* check if next is a successor of the oldTail */
	CU_ASSERT_PTR_EQUAL(&next, oldTail->next);
}
static void dns_fallback(void) {
	struct addrinfo *ai;
	int timeout;
	endpoint_t *client = create_endpoint();
	const char *nameservers[]={
		"94.23.19.176", /*linphone.org ; this is not a name server, it will not respond*/
		"8.8.8.8", /* public nameserver, should work*/
		NULL
	};

	CU_ASSERT_PTR_NOT_NULL_FATAL(client);
	timeout = belle_sip_stack_get_dns_timeout(client->stack);
	set_custom_resolv_conf(client->stack,nameservers);
	client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_SIP_DOMAIN, SIP_PORT, AF_INET, a_resolve_done, client);
	CU_ASSERT_NOT_EQUAL(client->resolver_ctx, NULL);
	CU_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout));
	CU_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL);
	if (client->ai_list) {
		struct sockaddr_in *sock_in = (struct sockaddr_in *)client->ai_list->ai_addr;
		CU_ASSERT_EQUAL(ntohs(sock_in->sin_port), SIP_PORT);
		ai = belle_sip_ip_address_to_addrinfo(AF_INET, IPV4_SIP_IP, SIP_PORT);
		if (ai) {
			CU_ASSERT_EQUAL(sock_in->sin_addr.s_addr, ((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr);
			belle_sip_freeaddrinfo(ai);
		}
	}

	destroy_endpoint(client);
}
void ASSERT_BUFFER_NOTEQUALS(buffer_t* buffer, msg_t* messages[]) {
    int i;
    for(i=0; i<buffer->size; i++) {
        CU_ASSERT_PTR_NOT_EQUAL(buffer->queue[buffer->T].content,messages[i]->content);
        buffer->T=(buffer->T+1)%(buffer->size);
    }
}
Ejemplo n.º 19
0
void testCreateDestroy(void)
{
    le_sem_Ref_t semPtr=NULL,semPtr2=NULL;

    semPtr     = le_sem_Create( "SEMAPHORE-1", 10);
    CU_ASSERT_PTR_NOT_EQUAL(semPtr, NULL);

    semPtr2    = le_sem_CreateTraceable( "SEMAPHORE-2", 1);
    CU_ASSERT_PTR_NOT_EQUAL(semPtr2, NULL);


    le_sem_Delete(semPtr);
    CU_PASS("Destruct semaphore\n");
    le_sem_Delete(semPtr2);
    CU_PASS("Destruct semaphore\n");
}
Ejemplo n.º 20
0
void bi_list_test_pop_front_head(void)
{
	TBiList list;
	TBiElement head;
	TBiElement tail;

	bi_list_ctor(&list);
	bi_element_ctor(&head);
	bi_element_ctor(&tail);

	bi_list_push_front(&list, &head);
	bi_list_push_front(&list, &tail);

	TBiElement* old_head = list.head;
	TBiElement* old_head_next = old_head->next;

	TBiElement* front = bi_list_pop_front(&list);

	/* check if front is not 0 */
	CU_ASSERT_PTR_NOT_EQUAL(0, front);
	/* check if front is the old_head */
	CU_ASSERT_PTR_EQUAL(front, old_head);
	/* check if new head is the successor of the old_head */
	CU_ASSERT_PTR_EQUAL(old_head_next, list.head);
}
Ejemplo n.º 21
0
void bi_list_test_push_front_next(void)
{
	TBiList list;
	TBiElement head;
	TBiElement next;

	bi_list_ctor(&list);
	bi_element_ctor(&head);
	bi_element_ctor(&next);

	bi_list_push_front(&list, &head);

	TBiElement* old_head = list.head;

	bi_list_push_front(&list, &next);

	/* check if list is not empty */
	CU_ASSERT_EQUAL(0, bi_list_empty(&list));
	/* check if next is a new head of the list */
	CU_ASSERT_PTR_EQUAL(&next, list.head);
	/* check if on the list are more than one element */
	CU_ASSERT_PTR_NOT_EQUAL(list.head, list.tail);
	/* check if old_head is the successor of next */
	CU_ASSERT_PTR_EQUAL(old_head, next.next);
	/* check if next is a predecessor of the old_head */
	CU_ASSERT_PTR_EQUAL(&next, old_head->prev);
}
Ejemplo n.º 22
0
static void test_string_substring_empty() {
	char* original_word = "";
	char* substring = string_substring(original_word, 0, 3);
	CU_ASSERT_STRING_EQUAL(substring, original_word);
	CU_ASSERT_PTR_NOT_EQUAL(substring, original_word);
	free(substring);
}
Ejemplo n.º 23
0
void test_phalcon_separate_param(void)
{
	startup_php(__func__);
	zend_first_try {
		zval* x;
		zval* orig;

		PHALCON_MM_GROW();
			MAKE_STD_ZVAL(x);
			ZVAL_LONG(x, 0xB61964F6l);
			Z_ADDREF_P(x);
			Z_ADDREF_P(x);
			Z_ADDREF_P(x);
			orig = x;

			CU_ASSERT_EQUAL(Z_REFCOUNT_P(x), 4);
			CU_ASSERT_EQUAL(Z_ISREF_P(x), 0);

			PHALCON_SEPARATE_PARAM(x);

			CU_ASSERT_EQUAL(Z_REFCOUNT_P(x), 1);
			CU_ASSERT_EQUAL(Z_ISREF_P(x), 0);
			CU_ASSERT_PTR_NOT_EQUAL(x, orig);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(orig), 4);
			CU_ASSERT_EQUAL(Z_ISREF_P(orig), 0);

			CU_ASSERT_EQUAL(Z_TYPE_P(x), IS_LONG);
			CU_ASSERT_EQUAL(Z_LVAL_P(x), 0xB61964F6l);

			CU_ASSERT_EQUAL(Z_TYPE_P(x), Z_TYPE_P(orig));
			CU_ASSERT_EQUAL(Z_LVAL_P(x), Z_LVAL_P(orig));

			zval_ptr_dtor(&orig);
			CU_ASSERT_EQUAL(_mem_block_check(x, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(_mem_block_check(orig, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(orig), 3);

			zval_ptr_dtor(&orig);
			CU_ASSERT_EQUAL(_mem_block_check(x, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(_mem_block_check(orig, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(orig), 2);

			zval_ptr_dtor(&orig);
			CU_ASSERT_EQUAL(_mem_block_check(x, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(_mem_block_check(orig, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
			CU_ASSERT_EQUAL(Z_REFCOUNT_P(orig), 1);

			zval_ptr_dtor(&orig);
			CU_ASSERT_EQUAL(_mem_block_check(x, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC), 1);
		PHALCON_MM_RESTORE();
	}
	zend_catch {
		CU_ASSERT(0);
	}
	zend_end_try();

	shutdown_php();
	CU_ASSERT_EQUAL(leaks, 0);
}
/* Successful IPv6 AAAA query */
static void ipv6_aaaa_query(void) {
	struct addrinfo *ai;
	int timeout;
	endpoint_t *client;

	if (!belle_sip_tester_ipv6_available()){
		belle_sip_warning("Test skipped, IPv6 connectivity not available.");
		return;
	}

	client = create_endpoint();
	CU_ASSERT_PTR_NOT_NULL_FATAL(client);
	timeout = belle_sip_stack_get_dns_timeout(client->stack);
	client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV6_SIP_DOMAIN, SIP_PORT, AF_INET6, a_resolve_done, client);
	CU_ASSERT_NOT_EQUAL(client->resolver_ctx, NULL);
	CU_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout));
	CU_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL);
	if (client->ai_list) {
		struct addrinfo *next;
		struct sockaddr_in6 *sock_in6 = (struct sockaddr_in6 *)client->ai_list->ai_addr;
		CU_ASSERT_EQUAL(ntohs(sock_in6->sin6_port), SIP_PORT);
		/*the IPv6 address shall return first, and must be a real ipv6 address*/
		CU_ASSERT_TRUE(client->ai_list->ai_family==AF_INET6);
		CU_ASSERT_FALSE(IN6_IS_ADDR_V4MAPPED(&sock_in6->sin6_addr));
		ai = belle_sip_ip_address_to_addrinfo(AF_INET6, IPV6_SIP_IP, SIP_PORT);
		CU_ASSERT_PTR_NOT_NULL(ai);
		if (ai) {
			struct in6_addr *ipv6_address = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr;
			int i;
			for (i = 0; i < 8; i++) {
				CU_ASSERT_EQUAL(sock_in6->sin6_addr.s6_addr[i], ipv6_address->s6_addr[i]);
			}
			belle_sip_freeaddrinfo(ai);
		}
		next=client->ai_list->ai_next;
		CU_ASSERT_PTR_NOT_NULL(next);
		if (next){
			sock_in6 = (struct sockaddr_in6 *)next->ai_addr;
			CU_ASSERT_TRUE(next->ai_family==AF_INET6);
			CU_ASSERT_TRUE(IN6_IS_ADDR_V4MAPPED(&sock_in6->sin6_addr));
			CU_ASSERT_EQUAL(ntohs(sock_in6->sin6_port), SIP_PORT);
			ai = belle_sip_ip_address_to_addrinfo(AF_INET6, IPV6_SIP_IPV4, SIP_PORT);
			CU_ASSERT_PTR_NOT_NULL(ai);
			if (ai) {
				struct in6_addr *ipv6_address = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr;
				int i;
				for (i = 0; i < 8; i++) {
					CU_ASSERT_EQUAL(sock_in6->sin6_addr.s6_addr[i], ipv6_address->s6_addr[i]);
				}
				belle_sip_freeaddrinfo(ai);
			}
		}
	}
	destroy_endpoint(client);
}
static void local_query(void) {
	int timeout;
	endpoint_t *client = create_endpoint();

	CU_ASSERT_PTR_NOT_NULL_FATAL(client);
	timeout = belle_sip_stack_get_dns_timeout(client->stack);
	client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, "localhost", SIP_PORT, AF_INET, a_resolve_done, client);
	// A DNS query is needed on Windows platform
#ifdef WIN32
	CU_ASSERT_PTR_NOT_EQUAL(client->resolver_ctx, NULL);
#else
	CU_ASSERT_PTR_EQUAL(client->resolver_ctx, NULL);
#endif
	CU_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout));
	CU_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL);
	if (client->ai_list) {
		struct sockaddr_in *sock_in = (struct sockaddr_in *)client->ai_list->ai_addr;
		CU_ASSERT_EQUAL(ntohs(sock_in->sin_port), SIP_PORT);
	}
	destroy_endpoint(client);
}
/* Successful SRV + A or AAAA queries */
static void srv_a_query(void) {
	int timeout;
	endpoint_t *client = create_endpoint();

	CU_ASSERT_PTR_NOT_NULL_FATAL(client);
	timeout = belle_sip_stack_get_dns_timeout(client->stack);
	client->resolver_ctx = belle_sip_stack_resolve(client->stack, "udp", SRV_DOMAIN, SIP_PORT, AF_INET, a_resolve_done, client);
	CU_ASSERT_NOT_EQUAL(client->resolver_ctx, NULL);
	CU_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout));
	CU_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL);

	destroy_endpoint(client);
}
Ejemplo n.º 27
0
static void test_helper_strdup() {
	// Check for only one strdup. helper_strdup is only needed as long as strdup is not defined anyway.
	CU_ASSERT_PTR_EQUAL(strdup, helper_strdup);
	
	char* str = "a test string";
	char* got = helper_strdup(str);
	CU_ASSERT_STRING_EQUAL(str, got);
	CU_ASSERT_PTR_NOT_EQUAL(str, got);
	free(got);
	
	// Test returning NULL
	CU_ASSERT_PTR_EQUAL(helper_strdup(NULL), NULL);
}
Ejemplo n.º 28
0
void testPostOK(void)
{
    le_sem_Ref_t semPtr=NULL;

    semPtr     = le_sem_Create( "SEMAPHORE-1", 10);
    CU_ASSERT_PTR_NOT_EQUAL(semPtr, NULL);

    le_sem_Post(semPtr);
    CU_ASSERT_EQUAL(le_sem_GetValue(semPtr),11);

    le_sem_Delete(semPtr);
    CU_PASS("Destruct semaphore\n");
}
Ejemplo n.º 29
0
void test_reader_list_addTwoReaders(){
	reader_list_initialize();
	CU_ASSERT_EQUAL(reader_list_size(),0);
	reader_t* reader_ritardoUnitario_bufferGenerico=reader_initialize("Reader 1",1,10);
	reader_t* reader_ritardo5_bufferUnitario=reader_initialize("Reader 2",5,1);
	add_twoReaders(reader_ritardoUnitario_bufferGenerico,reader_ritardo5_bufferUnitario);
	CU_ASSERT_PTR_NOT_NULL(reader_list->head);
	CU_ASSERT_PTR_NOT_NULL(reader_list->tail);
	CU_ASSERT_PTR_NOT_EQUAL(reader_list->head, reader_list->tail);
	CU_ASSERT_PTR_EQUAL(reader_list->head->next, reader_list->tail);
	CU_ASSERT_EQUAL(reader_list_size(),2);
	remove_twoReaders(reader_ritardoUnitario_bufferGenerico,reader_ritardo5_bufferUnitario);
	reader_list_destroy();
}
Ejemplo n.º 30
0
void test_rf_set_clone() {
	char a[] = "a";
	char b[] = "b";
	char c[] = "c";

	rf_SetElement *elems1[] = {
		rf_set_element_new_string(a),
		rf_set_element_new_string(b),
		rf_set_element_new_string(c),
	};
	rf_Set *set1 = rf_set_new(3, elems1);

	rf_Set *result = rf_set_clone(set1);

	CU_ASSERT_PTR_NOT_EQUAL(set1, result);
	for(int i = 0; i < result->cardinality; i++) {
		CU_ASSERT_PTR_NOT_EQUAL(set1->elements[i], result->elements[i]);
		CU_ASSERT_EQUAL(*set1->elements[i]->value.string, *result->elements[i]->value.string);
	}

	rf_set_free(set1);
	rf_set_free(result);
}