} END_TEST /* ------------------------------------------------------------------------- */ /* * Create a const-iterator over an enum descriptor. */ START_TEST(test_enum_iterator) { pb_enum_descriptor_iter_t it = pb_enum_descriptor_iter_create(&enum_descriptor); /* Assert enum descriptor size */ fail_if(pb_enum_descriptor_empty(&enum_descriptor)); ck_assert_uint_eq(3, pb_enum_descriptor_size(&enum_descriptor)); /* Walk through enum value descriptors forwards */ fail_unless(pb_enum_descriptor_iter_begin(&it)); for (size_t v = 0; v < 3; v++) { const pb_enum_value_descriptor_t *descriptor = pb_enum_descriptor_iter_current(&it); ck_assert_uint_eq(v, pb_enum_descriptor_iter_pos(&it)); /* Assemble value name */ char name[5]; snprintf(name, 5, "V%02d", pb_enum_value_descriptor_number(descriptor)); /* Assert value number and name */ ck_assert_uint_eq(v, pb_enum_value_descriptor_number(descriptor)); fail_if(strcmp(name, pb_enum_value_descriptor_name(descriptor))); /* Advance iterator */ ck_assert_uint_eq(v != 2, pb_enum_descriptor_iter_next(&it)); } /* Assert enum descriptor iterator validity */ fail_if(pb_enum_descriptor_iter_next(&it)); /* Walk through enum value descriptors backwards */ fail_unless(pb_enum_descriptor_iter_end(&it)); size_t v = 2; do { const pb_enum_value_descriptor_t *descriptor = pb_enum_descriptor_iter_current(&it); ck_assert_uint_eq(v, pb_enum_descriptor_iter_pos(&it)); /* Assemble value name */ char name[5]; snprintf(name, 5, "V%02d", pb_enum_value_descriptor_number(descriptor)); /* Assert value number and name */ ck_assert_uint_eq(v, pb_enum_value_descriptor_number(descriptor)); fail_if(strcmp(name, pb_enum_value_descriptor_name(descriptor))); /* Advance iterator */ ck_assert_uint_eq(v != 0, pb_enum_descriptor_iter_prev(&it)); } while (v--); /* Assert enum descriptor iterator validity again */ fail_if(pb_enum_descriptor_iter_prev(&it)); /* Free all allocated memory */ pb_enum_descriptor_iter_destroy(&it); } END_TEST
GST_END_TEST GST_START_TEST (request_data_sink_pad) { gchar *padname = NULL; KmsConnectData *data; GstBus *bus; data = kms_connect_data_create (1); data->data_probe = (KmsProbeType) data_probe_cb; data->audio_probe = (KmsProbeType) audio_probe_cb; data->video_probe = (KmsProbeType) video_probe_cb; /* Only tests data */ data->video_checks = data->audio_checks = 0; loop = g_main_loop_new (NULL, TRUE); pipeline = gst_pipeline_new (__FUNCTION__); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline); data->src = gst_element_factory_make ("dummysrc", NULL); data->sink = gst_element_factory_make ("dummysink", NULL); g_signal_connect (data->src, "pad-added", G_CALLBACK (src_pads_added), data); g_signal_connect (data->sink, "pad-added", G_CALLBACK (sink_pads_added), data); g_signal_connect (data->sink, "pad-removed", G_CALLBACK (sink_pads_removed), data); gst_bin_add_many (GST_BIN (pipeline), data->src, data->sink, NULL); /* request src pad using action */ g_signal_emit_by_name (data->src, "request-new-pad", KMS_ELEMENT_PAD_TYPE_DATA, NULL, GST_PAD_SRC, &data->data_src); fail_if (data->data_src == NULL); GST_DEBUG ("Data pad name: %s", data->data_src); /* request sink pad using action */ g_signal_emit_by_name (data->sink, "request-new-pad", KMS_ELEMENT_PAD_TYPE_DATA, "test", GST_PAD_SINK, &padname); fail_if (padname == NULL); GST_DEBUG ("Data pad name: %s", padname); g_object_set (G_OBJECT (data->src), "data", TRUE, NULL); g_timeout_add_seconds (4, print_timedout_pipeline, NULL); gst_element_set_state (pipeline, GST_STATE_PLAYING); g_main_loop_run (loop); gst_element_set_state (pipeline, GST_STATE_NULL); gst_bus_remove_signal_watch (bus); g_object_unref (bus); g_object_unref (pipeline); g_free (padname); g_main_loop_unref (loop); kms_connect_data_destroy (data); }
GST_END_TEST GST_START_TEST (test_date_tags) { GstTagList *tag_list, *tag_list2; GDate *date, *date2; gchar *str; date = g_date_new_dmy (14, 10, 2005); tag_list = gst_tag_list_new (); gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, GST_TAG_DATE, date, NULL); str = gst_tag_list_to_string (tag_list); fail_if (str == NULL); fail_if (strstr (str, "2005-10-14") == NULL); tag_list2 = gst_tag_list_new_from_string (str); fail_if (tag_list2 == NULL); fail_if (!gst_tag_list_get_date (tag_list2, GST_TAG_DATE, &date2)); fail_unless (gst_tag_list_is_equal (tag_list2, tag_list)); gst_tag_list_free (tag_list2); g_free (str); fail_if (g_date_compare (date, date2) != 0); fail_if (g_date_get_day (date) != 14); fail_if (g_date_get_month (date) != 10); fail_if (g_date_get_year (date) != 2005); fail_if (g_date_get_day (date2) != 14); fail_if (g_date_get_month (date2) != 10); fail_if (g_date_get_year (date2) != 2005); g_date_free (date2); gst_tag_list_free (tag_list); g_date_free (date); }
END_TEST /* * Test that IP address is not taken and NAK is sent if someone * replies to ARP requests for the offered address. */ START_TEST(test_dhcp_nak) { struct ip_addr addr; struct ip_addr netmask; struct ip_addr gw; u32_t xid; LWIP_UNUSED_ARG(_i); tcase = TEST_LWIP_DHCP; setdebug(0); IP4_ADDR(&addr, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0); netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input); dhcp_start(&net_test); fail_unless(txpacket == 1); // DHCP discover sent xid = net_test.dhcp->xid; // Write bad xid, not using htonl! memcpy(&dhcp_offer[46], &xid, 4); send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); // Interface down fail_if(netif_is_up(&net_test)); // IP addresses should be zero fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(struct ip_addr))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(struct ip_addr))); fail_if(memcmp(&gw, &net_test.gw, sizeof(struct ip_addr))); fail_unless(txpacket == 1); // Nothing more sent xid = htonl(net_test.dhcp->xid); memcpy(&dhcp_offer[46], &xid, 4); // insert correct transaction id send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); fail_unless(txpacket == 2); // DHCP request sent xid = net_test.dhcp->xid; // Write bad xid, not using htonl! memcpy(&dhcp_ack[46], &xid, 4); send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack)); fail_unless(txpacket == 2); // No more sent xid = htonl(net_test.dhcp->xid); // xid updated memcpy(&dhcp_ack[46], &xid, 4); // insert transaction id send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack)); fail_unless(txpacket == 3); // ARP request sent tcase = TEST_LWIP_DHCP_NAK; // Switch testcase // Send arp reply, mark offered IP as taken send_pkt(&net_test, arpreply, sizeof(arpreply)); fail_unless(txpacket == 4); // DHCP nak sent netif_remove(&net_test); }
END_TEST START_TEST(test_dhcp_nak_no_endmarker) { struct ip_addr addr; struct ip_addr netmask; struct ip_addr gw; u8_t dhcp_nack_no_endmarker[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x54, 0x75, 0xd0, 0x26, 0xd0, 0x0d, 0x08, 0x00, 0x45, 0x00, 0x01, 0x15, 0x38, 0x86, 0x00, 0x00, 0xff, 0x11, 0xc0, 0xa8, 0xc0, 0xa8, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00, 0x43, 0x00, 0x44, 0x01, 0x01, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x7a, 0xcb, 0xba, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x35, 0x01, 0x06, 0x36, 0x04, 0xc0, 0xa8, 0x01, 0x01, 0x31, 0xef, 0xad, 0x72, 0x31, 0x43, 0x4e, 0x44, 0x30, 0x32, 0x35, 0x30, 0x43, 0x52, 0x47, 0x44, 0x38, 0x35, 0x36, 0x3c, 0x08, 0x4d, 0x53, 0x46, 0x54, 0x20, 0x35, 0x2e, 0x30, 0x37, 0x0d, 0x01, 0x0f, 0x03, 0x06, 0x2c, 0x2e, 0x2f, 0x1f, 0x21, 0x79, 0xf9, 0x2b, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x71, 0xf3, 0x5b, 0xe2, 0x71, 0x2e, 0x01, 0x08, 0x03, 0x04, 0xc0, 0xa8, 0x01, 0x01, 0xff, 0xeb, 0x1e, 0x44, 0xec, 0xeb, 0x1e, 0x30, 0x37, 0x0c, 0x01, 0x0f, 0x03, 0x06, 0x2c, 0x2e, 0x2f, 0x1f, 0x21, 0x79, 0xf9, 0x2b, 0xff, 0x25, 0xc0, 0x09, 0xd6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; tcase = TEST_LWIP_DHCP_NAK_NO_ENDMARKER; setdebug(0); IP4_ADDR(&addr, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0); netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input); dhcp_start(&net_test); fail_unless(txpacket == 1); // DHCP discover sent u32_t xid = net_test.dhcp->xid; // Write bad xid, not using htonl! memcpy(&dhcp_offer[46], &xid, 4); send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); // Interface down fail_if(netif_is_up(&net_test)); // IP addresses should be zero fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(struct ip_addr))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(struct ip_addr))); fail_if(memcmp(&gw, &net_test.gw, sizeof(struct ip_addr))); fail_unless(txpacket == 1); // Nothing more sent xid = htonl(net_test.dhcp->xid); memcpy(&dhcp_offer[46], &xid, 4); // insert correct transaction id send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); fail_unless(net_test.dhcp->state == DHCP_REQUESTING); fail_unless(txpacket == 2); // No more sent xid = htonl(net_test.dhcp->xid); // xid updated memcpy(&dhcp_nack_no_endmarker[46], &xid, 4); // insert transaction id send_pkt(&net_test, dhcp_nack_no_endmarker, sizeof(dhcp_nack_no_endmarker)); // NAK should put us in another state for a while, no other way detecting it fail_unless(net_test.dhcp->state != DHCP_REQUESTING); netif_remove(&net_test); }
int main (int argc, char *argv[]) { game_t *game = game_create (game); game_start (game); // Swapping to or from outside of the board is illegal fail_if (session_legal_move (game, 0, 0, -1, 0)); fail_if (session_legal_move (game, 0, 0, 0, -1)); fail_if (session_legal_move (game, game->n_cols - 1, 0, game->n_cols, 0)); fail_if (session_legal_move (game, game->n_cols - 1, 0, game->n_cols - 1, -1)); fail_if (session_legal_move (game, 0, game->n_rows - 1, 0, game->n_rows)); fail_if (session_legal_move (game, 0, game->n_rows - 1, -1, game->n_rows - 1)); fail_if (session_legal_move (game, game->n_cols - 1, game->n_rows - 1, game->n_cols - 1, game->n_rows)); fail_if (session_legal_move (game, game->n_cols - 1, game->n_rows - 1, game->n_cols, game->n_rows - 1)); // Swapping non-adjacent locations is illegal fail_if (session_legal_move (game, 0, 0, 1, 1)); fail_if (session_legal_move (game, 1, 1, 0, 0)); fail_if (session_legal_move (game, 3, 2, 0, 1)); fail_if (session_legal_move (game, 5, 4, 2, 2)); // Swap and neither location is part of row or col of 3 or more game->n_gem_types = 1000000; setup_board_every_gem_different (game); // Since every location is different, there can be no legal moves int i, j; for (i = 0; i < game->n_cols; ++i) { for (j = 0; j < game->n_rows; ++j) { fail_if (session_legal_move (game, i, j, i - 1, j)); fail_if (session_legal_move (game, i, j, i, j - 1)); fail_if (session_legal_move (game, i, j, i + 1, j)); fail_if (session_legal_move (game, i, j, i, j + 1)); } } // Swap into a row of three // On bottom setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[2][3] = 999999; game->board[2][4] = 0; game->board[3][4] = 999999; fail_if (!session_legal_move (game, 2, 4, 3, 4)); fail_if (!session_legal_move (game, 3, 4, 2, 4)); // In middle setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[2][3] = 0; game->board[2][4] = 1999999; game->board[3][3] = 999999; fail_if (!session_legal_move (game, 2, 3, 3, 3)); fail_if (!session_legal_move (game, 3, 3, 2, 3)); // On top setup_board_every_gem_different (game); game->board[2][2] = 0; game->board[2][3] = 999999; game->board[2][4] = 2999999; game->board[3][2] = 999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swap into a col of three // On right setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[3][2] = 3999999; game->board[4][2] = 0; game->board[4][3] = 999999; fail_if (!session_legal_move (game, 4, 2, 4, 3)); fail_if (!session_legal_move (game, 4, 3, 4, 2)); // In middle setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 0; game->board[4][2] = 999999; game->board[3][3] = 999999; fail_if (!session_legal_move (game, 3, 2, 3, 3)); fail_if (!session_legal_move (game, 3, 3, 3, 2)); // On left setup_board_every_gem_different (game); game->board[2][2] = 0; game->board[3][2] = 999999; game->board[4][2] = 999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); // Swapping a special1 with a special1 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 1999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 1999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special1 with a special2 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 2999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special2 with a special2 setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[3][2] = 2999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special1 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special2 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special3 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 3999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 3999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); game_destroy (game); return 0; }
int pico_socket_close(struct pico_socket *s) { fail_if(s != example_session.socket); called_pico_socket_close++; return 0; }
END_TEST START_TEST(eina_rectangle_union_intersect) { Eina_Rectangle r1, r2, r3, r4, r5, r6, r7, r8, rd; fail_if(!eina_init()); EINA_RECTANGLE_SET(&r1, 10, 10, 50, 50); EINA_RECTANGLE_SET(&r2, 20, 20, 20, 20); EINA_RECTANGLE_SET(&r3, 0, 0, 10, 10); EINA_RECTANGLE_SET(&r4, 30, 30, 50, 50); EINA_RECTANGLE_SET(&r5, 10, 10, 0, 0); EINA_RECTANGLE_SET(&r6, 30, 30, 0, 0); EINA_RECTANGLE_SET(&r7, 10, 10, 5, 0); EINA_RECTANGLE_SET(&r8, 10, 10, 0, 5); rd = r1; fail_if(eina_rectangle_intersection(&rd, &r3)); fail_if(!eina_rectangle_intersection(&rd, &r2)); fail_if(rd.x != r2.x || rd.y != r2.y || rd.w != r2.w || rd.h != r2.h); rd = r1; fail_if(!eina_rectangle_intersection(&rd, &r4)); fail_if(rd.x != 30 || rd.y != 30 || rd.w != 30 || rd.h != 30); rd = r1; eina_rectangle_union(&rd, &r2); fail_if(rd.x != r1.x || rd.y != r1.y || rd.w != r1.w || rd.h != r1.h); rd = r6; fail_if(eina_rectangle_intersection(&rd, &r5)); rd = r7; fail_if(eina_rectangle_intersection(&rd, &r3)); rd = r8; fail_if(eina_rectangle_intersection(&rd, &r3)); rd = r1; eina_rectangle_union(&rd, &r3); fail_if(rd.x != 0 || rd.y != 0 || rd.w != 60 || rd.h != 60); rd = r3; eina_rectangle_union(&rd, &r4); fail_if(rd.x != 0 || rd.y != 0 || rd.w != 80 || rd.h != 80); rd = r5; eina_rectangle_union(&rd, &r6); fail_if(rd.x != 10 || rd.y != 10 || rd.w != 20 || rd.h != 20); eina_shutdown(); }
END_TEST START_TEST(eina_rectangle_pool_skyline) { Eina_Rectangle_Pool *pool; Eina_Rectangle *rects[8][8]; int x; int y; int w; int h; fail_if(!eina_init()); pool = eina_rectangle_pool_new(256, 256); fail_if(pool == NULL); eina_rectangle_pool_packing_set(pool, Eina_Packing_Bottom_Left_Skyline_Improved); eina_rectangle_pool_data_set(pool, rects); fail_if(eina_rectangle_pool_data_get(pool) != rects); fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL); for (x = 0; x < 8; x++) for (y = 0; y < 8; y++) { rects[x][y] = eina_rectangle_pool_request(pool, 32, 32); fail_if(rects[x][y] == NULL); } fail_if(eina_rectangle_pool_count(pool) != 64); fail_if(eina_rectangle_pool_get(rects[0][0]) != pool); fail_if(eina_rectangle_pool_geometry_get(pool, &w, &h) != EINA_TRUE); fail_if(w != 256 || h != 256); fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL); fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL); for (x = 0; x < 8; x++) eina_rectangle_pool_release(rects[0][x]); eina_rectangle_pool_free(pool); eina_shutdown(); }
END_TEST START_TEST(test_dhcp_invalid_overload) { u8_t dhcp_offer_invalid_overload[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, /* To unit */ 0x00, 0x0F, 0xEE, 0x30, 0xAB, 0x22, /* From Remote host */ 0x08, 0x00, /* Protocol: IP */ 0x45, 0x10, 0x01, 0x48, 0x00, 0x00, 0x00, 0x00, 0x80, 0x11, 0x36, 0xcc, 0xc3, 0xaa, 0xbd, 0xab, 0xc3, 0xaa, 0xbd, 0xc8, /* IP header */ 0x00, 0x43, 0x00, 0x44, 0x01, 0x34, 0x00, 0x00, /* UDP header */ 0x02, /* Type == Boot reply */ 0x01, 0x06, /* Hw Ethernet, 6 bytes addrlen */ 0x00, /* 0 hops */ 0xAA, 0xAA, 0xAA, 0xAA, /* Transaction id, will be overwritten */ 0x00, 0x00, /* 0 seconds elapsed */ 0x00, 0x00, /* Flags (unicast) */ 0x00, 0x00, 0x00, 0x00, /* Client ip */ 0xc3, 0xaa, 0xbd, 0xc8, /* Your IP */ 0xc3, 0xaa, 0xbd, 0xab, /* DHCP server ip */ 0x00, 0x00, 0x00, 0x00, /* relay agent */ 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MAC addr + padding */ /* Empty server name */ 0x34, 0x01, 0x02, 0xff, /* Overload: SNAME + END */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Empty boot file name */ 0x34, 0x01, 0x01, 0xff, /* Overload FILE + END */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, /* Magic cookie */ 0x35, 0x01, 0x02, /* Message type: Offer */ 0x36, 0x04, 0xc3, 0xaa, 0xbd, 0xab, /* Server identifier (IP) */ 0x33, 0x04, 0x00, 0x00, 0x00, 0x78, /* Lease time 2 minutes */ 0x03, 0x04, 0xc3, 0xaa, 0xbd, 0xab, /* Router IP */ 0x01, 0x04, 0xff, 0xff, 0xff, 0x00, /* Subnet mask */ 0x34, 0x01, 0x03, /* Overload: FILE + SNAME */ 0xff, /* End option */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Padding */ }; ip4_addr_t addr; ip4_addr_t netmask; ip4_addr_t gw; u32_t xid; LWIP_UNUSED_ARG(_i); tcase = TEST_LWIP_DHCP_INVALID_OVERLOAD; setdebug(0); IP4_ADDR(&addr, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0); netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input); netif_set_up(&net_test); dhcp_start(&net_test); fail_unless(txpacket == 1); /* DHCP discover sent */ xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&dhcp_offer_invalid_overload[46], &xid, 4); /* insert correct transaction id */ dhcp_offer_invalid_overload[311] = 3; send_pkt(&net_test, dhcp_offer_invalid_overload, sizeof(dhcp_offer_invalid_overload)); /* IP addresses should be zero */ fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t))); fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ dhcp_offer_invalid_overload[311] = 2; send_pkt(&net_test, dhcp_offer_invalid_overload, sizeof(dhcp_offer_invalid_overload)); /* IP addresses should be zero */ fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t))); fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ dhcp_offer_invalid_overload[311] = 1; send_pkt(&net_test, dhcp_offer_invalid_overload, sizeof(dhcp_offer_invalid_overload)); /* IP addresses should be zero */ fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t))); fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ dhcp_offer_invalid_overload[311] = 0; send_pkt(&net_test, dhcp_offer_invalid_overload, sizeof(dhcp_offer)); fail_unless(netif_dhcp_data(&net_test)->state == DHCP_STATE_REQUESTING); fail_unless(txpacket == 2); /* No more sent */ xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ tcase = TEST_NONE; dhcp_stop(&net_test); dhcp_cleanup(&net_test); netif_remove(&net_test); }
bool t_dep_para_full_worker(yarn_word_t pool_id, void* task) { (void) task; calc_func_t* calc_fun = (calc_func_t*) task; while(true) { enum yarn_epoch_status old_status; yarn_word_t epoch; DBG printf("\t\t\t\t\t\t\t\t"STR_TS"<%zu> NEXT => START\n", get_rel_time(), pool_id); if (!yarn_epoch_next(&epoch, &old_status)) { DBG printf("\t\t\t\t\t\t\t\t"STR_TS"<%zu> STOP\n", get_rel_time(), pool_id); break; } if (old_status == yarn_epoch_rollback) { DBG printf("\t\t\t\t\t\t\t\t"STR_TS"<%zu> NEXT => [%3zu] - ROLLBACK\n", get_rel_time(), pool_id, epoch); yarn_dep_rollback(epoch); yarn_epoch_rollback_done(epoch); } else { DBG printf("\t\t\t\t\t\t\t\t"STR_TS"<%zu> NEXT => [%3zu]\n", get_rel_time(), pool_id, epoch); } bool init_ret = yarn_dep_thread_init(pool_id, epoch); if (!init_ret) goto init_error; DBG printf("\t\t\t\t\t\t\t\t"STR_TS"<%zu> CALC => [%3zu]\n", get_rel_time(), pool_id, epoch); ret_t calc_ret = (*calc_fun)(pool_id); if (calc_ret == done) { DBG printf("\t\t\t\t\t\t\t\t"STR_TS"<%zu> F_STOP => [%3zu]\n", get_rel_time(), pool_id, epoch); yarn_epoch_stop(epoch); } DBG printf("\t\t\t\t\t\t\t\t"STR_TS"<%zu> DONE => [%3zu]\n", get_rel_time(), pool_id, epoch); yarn_epoch_set_done(epoch); yarn_dep_thread_destroy(pool_id); yarn_word_t commit_epoch; void* task; while (yarn_epoch_get_next_commit(&commit_epoch, &task)) { DBG printf("\t\t\t\t\t\t\t\t"STR_TS"<%zu> COMMIT => [%3zu]\n", get_rel_time(), pool_id, commit_epoch); yarn_dep_commit(commit_epoch); yarn_epoch_commit_done(commit_epoch); } if (calc_ret == ok) { continue; } else if (calc_ret == err) { goto dep_error; } } fail_if(false); return true; dep_error: init_error: perror(__FUNCTION__); return false; }
END_TEST START_TEST(test_dhcp_nak_no_endmarker) { ip4_addr_t addr; ip4_addr_t netmask; ip4_addr_t gw; u8_t dhcp_nack_no_endmarker[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x54, 0x75, 0xd0, 0x26, 0xd0, 0x0d, 0x08, 0x00, 0x45, 0x00, 0x01, 0x15, 0x38, 0x86, 0x00, 0x00, 0xff, 0x11, 0xc0, 0xa8, 0xc0, 0xa8, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00, 0x43, 0x00, 0x44, 0x01, 0x01, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x7a, 0xcb, 0xba, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x35, 0x01, 0x06, 0x36, 0x04, 0xc0, 0xa8, 0x01, 0x01, 0x31, 0xef, 0xad, 0x72, 0x31, 0x43, 0x4e, 0x44, 0x30, 0x32, 0x35, 0x30, 0x43, 0x52, 0x47, 0x44, 0x38, 0x35, 0x36, 0x3c, 0x08, 0x4d, 0x53, 0x46, 0x54, 0x20, 0x35, 0x2e, 0x30, 0x37, 0x0d, 0x01, 0x0f, 0x03, 0x06, 0x2c, 0x2e, 0x2f, 0x1f, 0x21, 0x79, 0xf9, 0x2b, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x71, 0xf3, 0x5b, 0xe2, 0x71, 0x2e, 0x01, 0x08, 0x03, 0x04, 0xc0, 0xa8, 0x01, 0x01, 0xff, 0xeb, 0x1e, 0x44, 0xec, 0xeb, 0x1e, 0x30, 0x37, 0x0c, 0x01, 0x0f, 0x03, 0x06, 0x2c, 0x2e, 0x2f, 0x1f, 0x21, 0x79, 0xf9, 0x2b, 0xff, 0x25, 0xc0, 0x09, 0xd6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; u32_t xid; LWIP_UNUSED_ARG(_i); tcase = TEST_LWIP_DHCP_NAK_NO_ENDMARKER; setdebug(0); IP4_ADDR(&addr, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0); netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input); netif_set_up(&net_test); dhcp_start(&net_test); fail_unless(txpacket == 1); /* DHCP discover sent */ xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */ memcpy(&dhcp_offer[46], &xid, 4); send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); /* IP addresses should be zero */ fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t))); fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */ send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); fail_unless(netif_dhcp_data(&net_test)->state == DHCP_STATE_REQUESTING); fail_unless(txpacket == 2); /* No more sent */ xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ memcpy(&dhcp_nack_no_endmarker[46], &xid, 4); /* insert transaction id */ send_pkt(&net_test, dhcp_nack_no_endmarker, sizeof(dhcp_nack_no_endmarker)); /* NAK should put us in another state for a while, no other way detecting it */ fail_unless(netif_dhcp_data(&net_test)->state != DHCP_STATE_REQUESTING); tcase = TEST_NONE; dhcp_stop(&net_test); dhcp_cleanup(&net_test); netif_remove(&net_test); }
END_TEST /* * Test case based on captured data where * replies are sent from a different IP than the * one the client unicasted to. */ START_TEST(test_dhcp_relayed) { u8_t relay_offer[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, 0x08, 0x00, 0x45, 0x00, 0x01, 0x38, 0xfd, 0x53, 0x00, 0x00, 0x40, 0x11, 0x78, 0x46, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x51, 0x35, 0xb6, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08, 0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1, 0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04, 0x00, 0x00, 0x54, 0x49, 0x35, 0x01, 0x02, 0x36, 0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff }; u8_t relay_ack1[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, 0x08, 0x00, 0x45, 0x00, 0x01, 0x38, 0xfd, 0x55, 0x00, 0x00, 0x40, 0x11, 0x78, 0x44, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x51, 0x35, 0xb6, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08, 0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1, 0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04, 0x00, 0x00, 0x54, 0x49, 0x35, 0x01, 0x05, 0x36, 0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff }; u8_t relay_ack2[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, 0x08, 0x00, 0x45, 0x00, 0x01, 0x38, 0xfa, 0x18, 0x00, 0x00, 0x40, 0x11, 0x7b, 0x81, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x49, 0x8b, 0x6e, 0xab, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x8a, 0x33, 0x05, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08, 0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1, 0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04, 0x00, 0x00, 0x54, 0x60, 0x35, 0x01, 0x05, 0x36, 0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff }; const u8_t arp_resp[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, /* DEST */ 0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, /* SRC */ 0x08, 0x06, /* Type: ARP */ 0x00, 0x01, /* HW: Ethernet */ 0x08, 0x00, /* PROTO: IP */ 0x06, /* HW size */ 0x04, /* PROTO size */ 0x00, 0x02, /* OPCODE: Reply */ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xab, /* Target MAC */ 0x4f, 0x8a, 0x32, 0x01, /* Target IP */ 0x00, 0x23, 0xc1, 0x00, 0x06, 0x50, /* src mac */ 0x4f, 0x8a, 0x33, 0x05, /* src ip */ /* Padding follows.. */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ip4_addr_t addr; ip4_addr_t netmask; ip4_addr_t gw; int i; u32_t xid; LWIP_UNUSED_ARG(_i); tcase = TEST_LWIP_DHCP_RELAY; setdebug(0); IP4_ADDR(&addr, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0); netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input); netif_set_up(&net_test); dhcp_start(&net_test); fail_unless(txpacket == 1); /* DHCP discover sent */ /* IP addresses should be zero */ fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t))); fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&relay_offer[46], &xid, 4); /* insert correct transaction id */ send_pkt(&net_test, relay_offer, sizeof(relay_offer)); /* request sent? */ fail_unless(txpacket == 2, "txpkt = %d, should be 2", txpacket); xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ memcpy(&relay_ack1[46], &xid, 4); /* insert transaction id */ send_pkt(&net_test, relay_ack1, sizeof(relay_ack1)); for (i = 0; i < 25; i++) { tick_lwip(); } fail_unless(txpacket == 5, "txpkt should be 5, is %d", txpacket); /* ARP requests sent */ /* Interface up */ fail_unless(netif_is_up(&net_test)); /* Now it should have taken the IP */ IP4_ADDR(&addr, 79, 138, 51, 5); IP4_ADDR(&netmask, 255, 255, 254, 0); IP4_ADDR(&gw, 79, 138, 50, 1); fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t))); fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 5, "txpacket = %d", txpacket); for (i = 0; i < 108000 - 25; i++) { tick_lwip(); } fail_unless(netif_is_up(&net_test)); fail_unless(txpacket == 6, "txpacket = %d", txpacket); /* We need to send arp response here.. */ send_pkt(&net_test, arp_resp, sizeof(arp_resp)); fail_unless(txpacket == 7, "txpacket = %d", txpacket); fail_unless(netif_is_up(&net_test)); xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ memcpy(&relay_ack2[46], &xid, 4); /* insert transaction id */ send_pkt(&net_test, relay_ack2, sizeof(relay_ack2)); for (i = 0; i < 100000; i++) { tick_lwip(); } fail_unless(txpacket == 7, "txpacket = %d", txpacket); tcase = TEST_NONE; dhcp_stop(&net_test); dhcp_cleanup(&net_test); netif_remove(&net_test); }
END_TEST /* * Test that IP address is not taken and NAK is sent if someone * replies to ARP requests for the offered address. */ START_TEST(test_dhcp_nak) { ip4_addr_t addr; ip4_addr_t netmask; ip4_addr_t gw; u32_t xid; LWIP_UNUSED_ARG(_i); tcase = TEST_LWIP_DHCP; setdebug(0); IP4_ADDR(&addr, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0); netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input); netif_set_up(&net_test); dhcp_start(&net_test); fail_unless(txpacket == 1); /* DHCP discover sent */ xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */ memcpy(&dhcp_offer[46], &xid, 4); send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); /* IP addresses should be zero */ fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t))); fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t))); fail_unless(txpacket == 1); /* Nothing more sent */ xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */ send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); fail_unless(txpacket == 2); /* DHCP request sent */ xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */ memcpy(&dhcp_ack[46], &xid, 4); send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack)); fail_unless(txpacket == 2); /* No more sent */ xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */ memcpy(&dhcp_ack[46], &xid, 4); /* insert transaction id */ send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack)); fail_unless(txpacket == 3); /* ARP request sent */ tcase = TEST_LWIP_DHCP_NAK; /* Switch testcase */ /* Send arp reply, mark offered IP as taken */ send_pkt(&net_test, arpreply, sizeof(arpreply)); fail_unless(txpacket == 4); /* DHCP nak sent */ tcase = TEST_NONE; dhcp_stop(&net_test); dhcp_cleanup(&net_test); netif_remove(&net_test); }
static void run_output_order_test (gint n_linked) { /* This test creates a multiqueue with 2 linked output, and 3 outputs that * return 'not-linked' when data is pushed, then verifies that all buffers * are received on not-linked pads only after earlier buffers on the * 'linked' pads are made */ GstElement *pipe; GstElement *mq; GstPad *inputpads[5]; GstPad *sinkpads[5]; struct PadData pad_data[5]; guint32 max_linked_id; guint32 eos_seen; GMutex *mutex; GCond *cond; gint i; const gint NPADS = 5; const gint NBUFFERS = 1000; mutex = g_mutex_new (); cond = g_cond_new (); pipe = gst_bin_new ("testbin"); mq = gst_element_factory_make ("multiqueue", NULL); fail_unless (mq != NULL); gst_bin_add (GST_BIN (pipe), mq); /* No limits */ g_object_set (mq, "max-size-bytes", (guint) 0, "max-size-buffers", (guint) 0, "max-size-time", (guint64) 0, "extra-size-bytes", (guint) 0, "extra-size-buffers", (guint) 0, "extra-size-time", (guint64) 0, NULL); /* Construct NPADS dummy output pads. The first 'n_linked' return FLOW_OK, the rest * return NOT_LINKED. The not-linked ones check the expected ordering of * output buffers */ for (i = 0; i < NPADS; i++) { GstPad *mq_srcpad, *mq_sinkpad; gchar *name; name = g_strdup_printf ("dummysrc%d", i); inputpads[i] = gst_pad_new (name, GST_PAD_SRC); g_free (name); gst_pad_set_getcaps_function (inputpads[i], mq_dummypad_getcaps); mq_sinkpad = gst_element_get_request_pad (mq, "sink%d"); fail_unless (mq_sinkpad != NULL); gst_pad_link (inputpads[i], mq_sinkpad); gst_pad_set_active (inputpads[i], TRUE); mq_srcpad = mq_sinkpad_to_srcpad (mq, mq_sinkpad); name = g_strdup_printf ("dummysink%d", i); sinkpads[i] = gst_pad_new (name, GST_PAD_SINK); g_free (name); gst_pad_set_chain_function (sinkpads[i], mq_dummypad_chain); gst_pad_set_event_function (sinkpads[i], mq_dummypad_event); gst_pad_set_getcaps_function (sinkpads[i], mq_dummypad_getcaps); pad_data[i].pad_num = i; pad_data[i].max_linked_id_ptr = &max_linked_id; pad_data[i].eos_count_ptr = &eos_seen; pad_data[i].is_linked = (i < n_linked ? TRUE : FALSE); pad_data[i].n_linked = n_linked; pad_data[i].cond = cond; pad_data[i].mutex = mutex; pad_data[i].first_buf = TRUE; gst_pad_set_element_private (sinkpads[i], pad_data + i); gst_pad_link (mq_srcpad, sinkpads[i]); gst_pad_set_active (sinkpads[i], TRUE); gst_object_unref (mq_sinkpad); gst_object_unref (mq_srcpad); } /* Run the test. Push 1000 buffers through the multiqueue in a pattern */ max_linked_id = 0; eos_seen = 0; gst_element_set_state (pipe, GST_STATE_PLAYING); for (i = 0; i < NBUFFERS; i++) { const guint8 pad_pattern[] = { 0, 0, 0, 0, 1, 1, 2, 1, 0, 2, 3, 2, 3, 1, 4 }; const guint n = sizeof (pad_pattern) / sizeof (guint8); guint8 cur_pad; GstBuffer *buf; GstFlowReturn ret; cur_pad = pad_pattern[i % n]; buf = gst_buffer_new_and_alloc (4); g_static_mutex_lock (&_check_lock); fail_if (buf == NULL); g_static_mutex_unlock (&_check_lock); GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf), i + 1); GST_BUFFER_TIMESTAMP (buf) = (i + 1) * GST_SECOND; ret = gst_pad_push (inputpads[cur_pad], buf); g_static_mutex_lock (&_check_lock); if (pad_data[cur_pad].is_linked) { fail_unless (ret == GST_FLOW_OK, "Push on pad %d returned %d when FLOW_OK was expected", cur_pad, ret); } else { /* Expect OK initially, then NOT_LINKED when the srcpad starts pushing */ fail_unless (ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED, "Push on pad %d returned %d when FLOW_OK or NOT_LINKED was expected", cur_pad, ret); } g_static_mutex_unlock (&_check_lock); } for (i = 0; i < NPADS; i++) { gst_pad_push_event (inputpads[i], gst_event_new_eos ()); } /* Wait while the buffers are processed */ g_mutex_lock (mutex); while (eos_seen < 5) { g_cond_wait (cond, mutex); } g_mutex_unlock (mutex); /* Clean up */ for (i = 0; i < 5; i++) { GstPad *mq_input = gst_pad_get_peer (inputpads[i]); gst_pad_unlink (inputpads[i], mq_input); gst_element_release_request_pad (mq, mq_input); gst_object_unref (mq_input); gst_object_unref (inputpads[i]); gst_object_unref (sinkpads[i]); } gst_element_set_state (pipe, GST_STATE_NULL); gst_object_unref (pipe); g_cond_free (cond); g_mutex_free (mutex); }
END_TEST START_TEST(benchmark_str) { match_entry * entry = match_entry_createl("/blog/post", strlen("/blog/post") ); node * n = r3_tree_create(1); int route_data = 999; r3_tree_insert_path(n, "/foo/bar/baz", NULL); r3_tree_insert_path(n, "/foo/bar/qux", NULL); r3_tree_insert_path(n, "/foo/bar/quux", NULL); r3_tree_insert_path(n, "/foo/bar/corge", NULL); r3_tree_insert_path(n, "/foo/bar/grault", NULL); r3_tree_insert_path(n, "/foo/bar/garply", NULL); r3_tree_insert_path(n, "/foo/baz/bar", NULL); r3_tree_insert_path(n, "/foo/baz/qux", NULL); r3_tree_insert_path(n, "/foo/baz/quux", NULL); r3_tree_insert_path(n, "/foo/baz/corge", NULL); r3_tree_insert_path(n, "/foo/baz/grault", NULL); r3_tree_insert_path(n, "/foo/baz/garply", NULL); r3_tree_insert_path(n, "/foo/qux/bar", NULL); r3_tree_insert_path(n, "/foo/qux/baz", NULL); r3_tree_insert_path(n, "/foo/qux/quux", NULL); r3_tree_insert_path(n, "/foo/qux/corge", NULL); r3_tree_insert_path(n, "/foo/qux/grault", NULL); r3_tree_insert_path(n, "/foo/qux/garply", NULL); r3_tree_insert_path(n, "/foo/quux/bar", NULL); r3_tree_insert_path(n, "/foo/quux/baz", NULL); r3_tree_insert_path(n, "/foo/quux/qux", NULL); r3_tree_insert_path(n, "/foo/quux/corge", NULL); r3_tree_insert_path(n, "/foo/quux/grault", NULL); r3_tree_insert_path(n, "/foo/quux/garply", NULL); r3_tree_insert_path(n, "/foo/corge/bar", NULL); r3_tree_insert_path(n, "/foo/corge/baz", NULL); r3_tree_insert_path(n, "/foo/corge/qux", NULL); r3_tree_insert_path(n, "/foo/corge/quux", NULL); r3_tree_insert_path(n, "/foo/corge/grault", NULL); r3_tree_insert_path(n, "/foo/corge/garply", NULL); r3_tree_insert_path(n, "/foo/grault/bar", NULL); r3_tree_insert_path(n, "/foo/grault/baz", NULL); r3_tree_insert_path(n, "/foo/grault/qux", NULL); r3_tree_insert_path(n, "/foo/grault/quux", NULL); r3_tree_insert_path(n, "/foo/grault/corge", NULL); r3_tree_insert_path(n, "/foo/grault/garply", NULL); r3_tree_insert_path(n, "/foo/garply/bar", NULL); r3_tree_insert_path(n, "/foo/garply/baz", NULL); r3_tree_insert_path(n, "/foo/garply/qux", NULL); r3_tree_insert_path(n, "/foo/garply/quux", NULL); r3_tree_insert_path(n, "/foo/garply/corge", NULL); r3_tree_insert_path(n, "/foo/garply/grault", NULL); r3_tree_insert_path(n, "/bar/foo/baz", NULL); r3_tree_insert_path(n, "/bar/foo/qux", NULL); r3_tree_insert_path(n, "/bar/foo/quux", NULL); r3_tree_insert_path(n, "/bar/foo/corge", NULL); r3_tree_insert_path(n, "/bar/foo/grault", NULL); r3_tree_insert_path(n, "/bar/foo/garply", NULL); r3_tree_insert_path(n, "/bar/baz/foo", NULL); r3_tree_insert_path(n, "/bar/baz/qux", NULL); r3_tree_insert_path(n, "/bar/baz/quux", NULL); r3_tree_insert_path(n, "/bar/baz/corge", NULL); r3_tree_insert_path(n, "/bar/baz/grault", NULL); r3_tree_insert_path(n, "/bar/baz/garply", NULL); r3_tree_insert_path(n, "/bar/qux/foo", NULL); r3_tree_insert_path(n, "/bar/qux/baz", NULL); r3_tree_insert_path(n, "/bar/qux/quux", NULL); r3_tree_insert_path(n, "/bar/qux/corge", NULL); r3_tree_insert_path(n, "/bar/qux/grault", NULL); r3_tree_insert_path(n, "/bar/qux/garply", NULL); r3_tree_insert_path(n, "/bar/quux/foo", NULL); r3_tree_insert_path(n, "/bar/quux/baz", NULL); r3_tree_insert_path(n, "/bar/quux/qux", NULL); r3_tree_insert_path(n, "/bar/quux/corge", NULL); r3_tree_insert_path(n, "/bar/quux/grault", NULL); r3_tree_insert_path(n, "/bar/quux/garply", NULL); r3_tree_insert_path(n, "/bar/corge/foo", NULL); r3_tree_insert_path(n, "/bar/corge/baz", NULL); r3_tree_insert_path(n, "/bar/corge/qux", NULL); r3_tree_insert_path(n, "/bar/corge/quux", NULL); r3_tree_insert_path(n, "/bar/corge/grault", NULL); r3_tree_insert_path(n, "/bar/corge/garply", NULL); r3_tree_insert_path(n, "/bar/grault/foo", NULL); r3_tree_insert_path(n, "/bar/grault/baz", NULL); r3_tree_insert_path(n, "/bar/grault/qux", NULL); r3_tree_insert_path(n, "/bar/grault/quux", NULL); r3_tree_insert_path(n, "/bar/grault/corge", NULL); r3_tree_insert_path(n, "/bar/grault/garply", NULL); r3_tree_insert_path(n, "/bar/garply/foo", NULL); r3_tree_insert_path(n, "/bar/garply/baz", NULL); r3_tree_insert_path(n, "/bar/garply/qux", NULL); r3_tree_insert_path(n, "/bar/garply/quux", NULL); r3_tree_insert_path(n, "/bar/garply/corge", NULL); r3_tree_insert_path(n, "/bar/garply/grault", NULL); r3_tree_insert_path(n, "/baz/foo/bar", NULL); r3_tree_insert_path(n, "/baz/foo/qux", NULL); r3_tree_insert_path(n, "/baz/foo/quux", NULL); r3_tree_insert_path(n, "/baz/foo/corge", NULL); r3_tree_insert_path(n, "/baz/foo/grault", NULL); r3_tree_insert_path(n, "/baz/foo/garply", NULL); r3_tree_insert_path(n, "/baz/bar/foo", NULL); r3_tree_insert_path(n, "/baz/bar/qux", NULL); r3_tree_insert_path(n, "/baz/bar/quux", NULL); r3_tree_insert_path(n, "/baz/bar/corge", NULL); r3_tree_insert_path(n, "/baz/bar/grault", NULL); r3_tree_insert_path(n, "/baz/bar/garply", NULL); r3_tree_insert_path(n, "/baz/qux/foo", NULL); r3_tree_insert_path(n, "/baz/qux/bar", NULL); r3_tree_insert_path(n, "/baz/qux/quux", NULL); r3_tree_insert_path(n, "/baz/qux/corge", NULL); r3_tree_insert_path(n, "/baz/qux/grault", NULL); r3_tree_insert_path(n, "/baz/qux/garply", NULL); r3_tree_insert_path(n, "/baz/quux/foo", NULL); r3_tree_insert_path(n, "/baz/quux/bar", NULL); r3_tree_insert_path(n, "/baz/quux/qux", NULL); r3_tree_insert_path(n, "/baz/quux/corge", NULL); r3_tree_insert_path(n, "/baz/quux/grault", NULL); r3_tree_insert_path(n, "/baz/quux/garply", NULL); r3_tree_insert_path(n, "/baz/corge/foo", NULL); r3_tree_insert_path(n, "/baz/corge/bar", NULL); r3_tree_insert_path(n, "/baz/corge/qux", NULL); r3_tree_insert_path(n, "/baz/corge/quux", NULL); r3_tree_insert_path(n, "/baz/corge/grault", NULL); r3_tree_insert_path(n, "/baz/corge/garply", NULL); r3_tree_insert_path(n, "/baz/grault/foo", NULL); r3_tree_insert_path(n, "/baz/grault/bar", NULL); r3_tree_insert_path(n, "/baz/grault/qux", NULL); r3_tree_insert_path(n, "/baz/grault/quux", NULL); r3_tree_insert_path(n, "/baz/grault/corge", NULL); r3_tree_insert_path(n, "/baz/grault/garply", NULL); r3_tree_insert_path(n, "/baz/garply/foo", NULL); r3_tree_insert_path(n, "/baz/garply/bar", NULL); r3_tree_insert_path(n, "/baz/garply/qux", NULL); r3_tree_insert_path(n, "/baz/garply/quux", NULL); r3_tree_insert_path(n, "/baz/garply/corge", NULL); r3_tree_insert_path(n, "/baz/garply/grault", NULL); r3_tree_insert_path(n, "/qux/foo/bar", NULL); r3_tree_insert_path(n, "/qux/foo/baz", NULL); r3_tree_insert_path(n, "/qux/foo/quux", NULL); r3_tree_insert_path(n, "/qux/foo/corge", NULL); r3_tree_insert_path(n, "/qux/foo/grault", NULL); r3_tree_insert_path(n, "/qux/foo/garply", NULL); r3_tree_insert_path(n, "/qux/bar/foo", NULL); r3_tree_insert_path(n, "/qux/bar/baz", NULL); r3_tree_insert_path(n, "/qux/bar/quux", NULL); r3_tree_insert_path(n, "/qux/bar/corge", &route_data); r3_tree_insert_path(n, "/qux/bar/grault", NULL); r3_tree_insert_path(n, "/qux/bar/garply", NULL); r3_tree_insert_path(n, "/qux/baz/foo", NULL); r3_tree_insert_path(n, "/qux/baz/bar", NULL); r3_tree_insert_path(n, "/qux/baz/quux", NULL); r3_tree_insert_path(n, "/qux/baz/corge", NULL); r3_tree_insert_path(n, "/qux/baz/grault", NULL); r3_tree_insert_path(n, "/qux/baz/garply", NULL); r3_tree_insert_path(n, "/qux/quux/foo", NULL); r3_tree_insert_path(n, "/qux/quux/bar", NULL); r3_tree_insert_path(n, "/qux/quux/baz", NULL); r3_tree_insert_path(n, "/qux/quux/corge", NULL); r3_tree_insert_path(n, "/qux/quux/grault", NULL); r3_tree_insert_path(n, "/qux/quux/garply", NULL); r3_tree_insert_path(n, "/qux/corge/foo", NULL); r3_tree_insert_path(n, "/qux/corge/bar", NULL); r3_tree_insert_path(n, "/qux/corge/baz", NULL); r3_tree_insert_path(n, "/qux/corge/quux", NULL); r3_tree_insert_path(n, "/qux/corge/grault", NULL); r3_tree_insert_path(n, "/qux/corge/garply", NULL); r3_tree_insert_path(n, "/qux/grault/foo", NULL); r3_tree_insert_path(n, "/qux/grault/bar", NULL); r3_tree_insert_path(n, "/qux/grault/baz", NULL); r3_tree_insert_path(n, "/qux/grault/quux", NULL); r3_tree_insert_path(n, "/qux/grault/corge", NULL); r3_tree_insert_path(n, "/qux/grault/garply", NULL); r3_tree_insert_path(n, "/qux/garply/foo", NULL); r3_tree_insert_path(n, "/qux/garply/bar", NULL); r3_tree_insert_path(n, "/qux/garply/baz", NULL); r3_tree_insert_path(n, "/qux/garply/quux", NULL); r3_tree_insert_path(n, "/qux/garply/corge", NULL); r3_tree_insert_path(n, "/qux/garply/grault", NULL); r3_tree_insert_path(n, "/quux/foo/bar", NULL); r3_tree_insert_path(n, "/quux/foo/baz", NULL); r3_tree_insert_path(n, "/quux/foo/qux", NULL); r3_tree_insert_path(n, "/quux/foo/corge", NULL); r3_tree_insert_path(n, "/quux/foo/grault", NULL); r3_tree_insert_path(n, "/quux/foo/garply", NULL); r3_tree_insert_path(n, "/quux/bar/foo", NULL); r3_tree_insert_path(n, "/quux/bar/baz", NULL); r3_tree_insert_path(n, "/quux/bar/qux", NULL); r3_tree_insert_path(n, "/quux/bar/corge", NULL); r3_tree_insert_path(n, "/quux/bar/grault", NULL); r3_tree_insert_path(n, "/quux/bar/garply", NULL); r3_tree_insert_path(n, "/quux/baz/foo", NULL); r3_tree_insert_path(n, "/quux/baz/bar", NULL); r3_tree_insert_path(n, "/quux/baz/qux", NULL); r3_tree_insert_path(n, "/quux/baz/corge", NULL); r3_tree_insert_path(n, "/quux/baz/grault", NULL); r3_tree_insert_path(n, "/quux/baz/garply", NULL); r3_tree_insert_path(n, "/quux/qux/foo", NULL); r3_tree_insert_path(n, "/quux/qux/bar", NULL); r3_tree_insert_path(n, "/quux/qux/baz", NULL); r3_tree_insert_path(n, "/quux/qux/corge", NULL); r3_tree_insert_path(n, "/quux/qux/grault", NULL); r3_tree_insert_path(n, "/quux/qux/garply", NULL); r3_tree_insert_path(n, "/quux/corge/foo", NULL); r3_tree_insert_path(n, "/quux/corge/bar", NULL); r3_tree_insert_path(n, "/quux/corge/baz", NULL); r3_tree_insert_path(n, "/quux/corge/qux", NULL); r3_tree_insert_path(n, "/quux/corge/grault", NULL); r3_tree_insert_path(n, "/quux/corge/garply", NULL); r3_tree_insert_path(n, "/quux/grault/foo", NULL); r3_tree_insert_path(n, "/quux/grault/bar", NULL); r3_tree_insert_path(n, "/quux/grault/baz", NULL); r3_tree_insert_path(n, "/quux/grault/qux", NULL); r3_tree_insert_path(n, "/quux/grault/corge", NULL); r3_tree_insert_path(n, "/quux/grault/garply", NULL); r3_tree_insert_path(n, "/quux/garply/foo", NULL); r3_tree_insert_path(n, "/quux/garply/bar", NULL); r3_tree_insert_path(n, "/quux/garply/baz", NULL); r3_tree_insert_path(n, "/quux/garply/qux", NULL); r3_tree_insert_path(n, "/quux/garply/corge", NULL); r3_tree_insert_path(n, "/quux/garply/grault", NULL); r3_tree_insert_path(n, "/corge/foo/bar", NULL); r3_tree_insert_path(n, "/corge/foo/baz", NULL); r3_tree_insert_path(n, "/corge/foo/qux", NULL); r3_tree_insert_path(n, "/corge/foo/quux", NULL); r3_tree_insert_path(n, "/corge/foo/grault", NULL); r3_tree_insert_path(n, "/corge/foo/garply", NULL); r3_tree_insert_path(n, "/corge/bar/foo", NULL); r3_tree_insert_path(n, "/corge/bar/baz", NULL); r3_tree_insert_path(n, "/corge/bar/qux", NULL); r3_tree_insert_path(n, "/corge/bar/quux", NULL); r3_tree_insert_path(n, "/corge/bar/grault", NULL); r3_tree_insert_path(n, "/corge/bar/garply", NULL); r3_tree_insert_path(n, "/corge/baz/foo", NULL); r3_tree_insert_path(n, "/corge/baz/bar", NULL); r3_tree_insert_path(n, "/corge/baz/qux", NULL); r3_tree_insert_path(n, "/corge/baz/quux", NULL); r3_tree_insert_path(n, "/corge/baz/grault", NULL); r3_tree_insert_path(n, "/corge/baz/garply", NULL); r3_tree_insert_path(n, "/corge/qux/foo", NULL); r3_tree_insert_path(n, "/corge/qux/bar", NULL); r3_tree_insert_path(n, "/corge/qux/baz", NULL); r3_tree_insert_path(n, "/corge/qux/quux", NULL); r3_tree_insert_path(n, "/corge/qux/grault", NULL); r3_tree_insert_path(n, "/corge/qux/garply", NULL); r3_tree_insert_path(n, "/corge/quux/foo", NULL); r3_tree_insert_path(n, "/corge/quux/bar", NULL); r3_tree_insert_path(n, "/corge/quux/baz", NULL); r3_tree_insert_path(n, "/corge/quux/qux", NULL); r3_tree_insert_path(n, "/corge/quux/grault", NULL); r3_tree_insert_path(n, "/corge/quux/garply", NULL); r3_tree_insert_path(n, "/corge/grault/foo", NULL); r3_tree_insert_path(n, "/corge/grault/bar", NULL); r3_tree_insert_path(n, "/corge/grault/baz", NULL); r3_tree_insert_path(n, "/corge/grault/qux", NULL); r3_tree_insert_path(n, "/corge/grault/quux", NULL); r3_tree_insert_path(n, "/corge/grault/garply", NULL); r3_tree_insert_path(n, "/corge/garply/foo", NULL); r3_tree_insert_path(n, "/corge/garply/bar", NULL); r3_tree_insert_path(n, "/corge/garply/baz", NULL); r3_tree_insert_path(n, "/corge/garply/qux", NULL); r3_tree_insert_path(n, "/corge/garply/quux", NULL); r3_tree_insert_path(n, "/corge/garply/grault", NULL); r3_tree_insert_path(n, "/grault/foo/bar", NULL); r3_tree_insert_path(n, "/grault/foo/baz", NULL); r3_tree_insert_path(n, "/grault/foo/qux", NULL); r3_tree_insert_path(n, "/grault/foo/quux", NULL); r3_tree_insert_path(n, "/grault/foo/corge", NULL); r3_tree_insert_path(n, "/grault/foo/garply", NULL); r3_tree_insert_path(n, "/grault/bar/foo", NULL); r3_tree_insert_path(n, "/grault/bar/baz", NULL); r3_tree_insert_path(n, "/grault/bar/qux", NULL); r3_tree_insert_path(n, "/grault/bar/quux", NULL); r3_tree_insert_path(n, "/grault/bar/corge", NULL); r3_tree_insert_path(n, "/grault/bar/garply", NULL); r3_tree_insert_path(n, "/grault/baz/foo", NULL); r3_tree_insert_path(n, "/grault/baz/bar", NULL); r3_tree_insert_path(n, "/grault/baz/qux", NULL); r3_tree_insert_path(n, "/grault/baz/quux", NULL); r3_tree_insert_path(n, "/grault/baz/corge", NULL); r3_tree_insert_path(n, "/grault/baz/garply", NULL); r3_tree_insert_path(n, "/grault/qux/foo", NULL); r3_tree_insert_path(n, "/grault/qux/bar", NULL); r3_tree_insert_path(n, "/grault/qux/baz", NULL); r3_tree_insert_path(n, "/grault/qux/quux", NULL); r3_tree_insert_path(n, "/grault/qux/corge", NULL); r3_tree_insert_path(n, "/grault/qux/garply", NULL); r3_tree_insert_path(n, "/grault/quux/foo", NULL); r3_tree_insert_path(n, "/grault/quux/bar", NULL); r3_tree_insert_path(n, "/grault/quux/baz", NULL); r3_tree_insert_path(n, "/grault/quux/qux", NULL); r3_tree_insert_path(n, "/grault/quux/corge", NULL); r3_tree_insert_path(n, "/grault/quux/garply", NULL); r3_tree_insert_path(n, "/grault/corge/foo", NULL); r3_tree_insert_path(n, "/grault/corge/bar", NULL); r3_tree_insert_path(n, "/grault/corge/baz", NULL); r3_tree_insert_path(n, "/grault/corge/qux", NULL); r3_tree_insert_path(n, "/grault/corge/quux", NULL); r3_tree_insert_path(n, "/grault/corge/garply", NULL); r3_tree_insert_path(n, "/grault/garply/foo", NULL); r3_tree_insert_path(n, "/grault/garply/bar", NULL); r3_tree_insert_path(n, "/grault/garply/baz", NULL); r3_tree_insert_path(n, "/grault/garply/qux", NULL); r3_tree_insert_path(n, "/grault/garply/quux", NULL); r3_tree_insert_path(n, "/grault/garply/corge", NULL); r3_tree_insert_path(n, "/garply/foo/bar", NULL); r3_tree_insert_path(n, "/garply/foo/baz", NULL); r3_tree_insert_path(n, "/garply/foo/qux", NULL); r3_tree_insert_path(n, "/garply/foo/quux", NULL); r3_tree_insert_path(n, "/garply/foo/corge", NULL); r3_tree_insert_path(n, "/garply/foo/grault", NULL); r3_tree_insert_path(n, "/garply/bar/foo", NULL); r3_tree_insert_path(n, "/garply/bar/baz", NULL); r3_tree_insert_path(n, "/garply/bar/qux", NULL); r3_tree_insert_path(n, "/garply/bar/quux", NULL); r3_tree_insert_path(n, "/garply/bar/corge", NULL); r3_tree_insert_path(n, "/garply/bar/grault", NULL); r3_tree_insert_path(n, "/garply/baz/foo", NULL); r3_tree_insert_path(n, "/garply/baz/bar", NULL); r3_tree_insert_path(n, "/garply/baz/qux", NULL); r3_tree_insert_path(n, "/garply/baz/quux", NULL); r3_tree_insert_path(n, "/garply/baz/corge", NULL); r3_tree_insert_path(n, "/garply/baz/grault", NULL); r3_tree_insert_path(n, "/garply/qux/foo", NULL); r3_tree_insert_path(n, "/garply/qux/bar", NULL); r3_tree_insert_path(n, "/garply/qux/baz", NULL); r3_tree_insert_path(n, "/garply/qux/quux", NULL); r3_tree_insert_path(n, "/garply/qux/corge", NULL); r3_tree_insert_path(n, "/garply/qux/grault", NULL); r3_tree_insert_path(n, "/garply/quux/foo", NULL); r3_tree_insert_path(n, "/garply/quux/bar", NULL); r3_tree_insert_path(n, "/garply/quux/baz", NULL); r3_tree_insert_path(n, "/garply/quux/qux", NULL); r3_tree_insert_path(n, "/garply/quux/corge", NULL); r3_tree_insert_path(n, "/garply/quux/grault", NULL); r3_tree_insert_path(n, "/garply/corge/foo", NULL); r3_tree_insert_path(n, "/garply/corge/bar", NULL); r3_tree_insert_path(n, "/garply/corge/baz", NULL); r3_tree_insert_path(n, "/garply/corge/qux", NULL); r3_tree_insert_path(n, "/garply/corge/quux", NULL); r3_tree_insert_path(n, "/garply/corge/grault", NULL); r3_tree_insert_path(n, "/garply/grault/foo", NULL); r3_tree_insert_path(n, "/garply/grault/bar", NULL); r3_tree_insert_path(n, "/garply/grault/baz", NULL); r3_tree_insert_path(n, "/garply/grault/qux", NULL); r3_tree_insert_path(n, "/garply/grault/quux", NULL); r3_tree_insert_path(n, "/garply/grault/corge", NULL); r3_tree_compile(n); // r3_tree_dump(n, 0); // match_entry *entry = calloc( sizeof(entry) , 1 ); node *m; m = r3_tree_match(n , "/qux/bar/corge", NULL); fail_if( m == NULL ); // r3_tree_dump( m, 0 ); ck_assert_int_eq( *((int*) m->data), 999 ); printf("Benchmarking...\n"); BENCHMARK(string_dispatch) r3_tree_matchl(n , "/qux/bar/corge", strlen("/qux/bar/corge"), NULL); END_BENCHMARK() bench_print_summary(&B); FILE *fp = fopen("bench_str.csv", "a+"); fprintf(fp, "%ld,%.2f\n", unixtime(), (B.N * B.R) / (B.end - B.start)); fclose(fp); }
END_TEST START_TEST(test_sanity_cxx) { gu::Atomic<int64_t> i(1); int64_t const k(3); fail_if(i() != 1); fail_if(i() == k); fail_if((i = k) != k); fail_if(i() != k); fail_if(i.fetch_and_zero() != k); fail_if(i() != 0); fail_if(i.fetch_and_add(5) != 0); fail_if(i() != 5); fail_if(i.add_and_fetch(3) != 8); fail_if(i() != 8); fail_if((++i)() != 9); fail_if(i() != 9); fail_if((--i)() != 8); fail_if(i() != 8); i += 3; fail_if(i() != 11); }
END_TEST START_TEST (test_compile) { str_array *t; node * n; n = r3_tree_create(10); node *m; edge *e ; r3_tree_insert_path(n, "/zoo", NULL); r3_tree_insert_path(n, "/foo", NULL); r3_tree_insert_path(n, "/bar", NULL); r3_tree_compile(n); fail_if( n->combined_pattern ); fail_if( NULL == r3_node_find_edge_str(n, "/", strlen("/") ) ); #ifdef DEBUG r3_tree_dump(n, 0); #endif r3_tree_insert_path(n, "/foo/{id}", NULL); r3_tree_insert_path(n, "/{id}", NULL); r3_tree_compile(n); r3_tree_compile(n); // test double compile #ifdef DEBUG r3_tree_dump(n, 0); #endif /* fail_if(n->edges[0]->child->combined_pattern == NULL); e = r3_node_find_edge_str(n, "/", strlen("/") ); fail_if( NULL == e ); */ /* printf( "%s\n", e->pattern ); printf( "%s\n", e->child->combined_pattern ); printf( "%s\n", n->edges[0]->child->combined_pattern); printf( "%s\n", n->combined_pattern ); */ match_entry * entry; entry = match_entry_createl( "foo" , strlen("/foo") ); m = r3_tree_matchl( n , "/foo", strlen("/foo"), entry); fail_if( NULL == m ); entry = match_entry_createl( "/zoo" , strlen("/zoo") ); m = r3_tree_matchl( n , "/zoo", strlen("/zoo"), entry); fail_if( NULL == m ); entry = match_entry_createl( "/bar" , strlen("/bar") ); m = r3_tree_matchl( n , "/bar", strlen("/bar"), entry); fail_if( NULL == m ); entry = match_entry_createl( "/xxx" , strlen("/xxx") ); m = r3_tree_matchl( n , "/xxx", strlen("/xxx"), entry); fail_if( NULL == m ); entry = match_entry_createl( "/foo/xxx" , strlen("/foo/xxx") ); m = r3_tree_matchl( n , "/foo/xxx", strlen("/foo/xxx"), entry); fail_if( NULL == m ); entry = match_entry_createl( "/some_id" , strlen("/some_id") ); m = r3_tree_matchl( n , "/some_id", strlen("/some_id"), entry); fail_if( NULL == m ); ck_assert_int_gt( m->endpoint , 0 ); // should not be an endpoint }
// Initialises core and backend objects + some common tests static inline void core_test_init () { long ret; action_t act; mark_point(); gu_config_t* config = gu_config_create (); fail_if (config == NULL); Core = gcs_core_create (config, NULL, "core_test", "aaa.bbb.ccc.ddd:xxxx", 0, 0); fail_if (NULL == Core); Backend = gcs_core_get_backend (Core); fail_if (NULL == Backend); Seqno = 0; // reset seqno ret = core_test_set_payload_size (FRAG_SIZE); fail_if (-EBADFD != ret, "Expected -EBADFD, got: %ld (%s)", ret, strerror(-ret)); ret = gcs_core_open (Core, "yadda-yadda", "owkmevc", 1); fail_if (-EINVAL != ret, "Expected -EINVAL, got %ld (%s)", ret, strerror(-ret)); ret = gcs_core_open (Core, "yadda-yadda", "dummy://", 1); fail_if (0 != ret, "Failed to open core connection: %ld (%s)", ret, strerror(-ret)); // receive first configuration message fail_if (CORE_RECV_ACT (&act, NULL, UNKNOWN_SIZE, GCS_ACT_CONF)); fail_if (core_test_check_conf(act.out, true, 0, 1)); free (act.out); // this will configure backend to have desired fragment size ret = core_test_set_payload_size (FRAG_SIZE); fail_if (0 != ret, "Failed to set up the message payload size: %ld (%s)", ret, strerror(-ret)); // try to send an action to check that everything's alright ret = gcs_core_send (Core, act1, sizeof(act1_str), GCS_ACT_TORDERED); fail_if (ret != sizeof(act1_str), "Expected %d, got %d (%s)", sizeof(act1_str), ret, strerror (-ret)); gu_warn ("Next CORE_RECV_ACT fails under valgrind"); act.in = act1; fail_if (CORE_RECV_ACT (&act, act1_str, sizeof(act1_str),GCS_ACT_TORDERED)); ret = gcs_core_send_join (Core, Seqno); fail_if (ret != 0, "gcs_core_send_join(): %ld (%s)", ret, strerror(-ret)); // no action to be received (we're joined already) ret = gcs_core_send_sync (Core, Seqno); fail_if (ret != 0, "gcs_core_send_sync(): %ld (%s)", ret, strerror(-ret)); fail_if (CORE_RECV_ACT(&act,NULL,sizeof(gcs_seqno_t),GCS_ACT_SYNC)); fail_if (Seqno != gcs_seqno_gtoh(*(gcs_seqno_t*)act.out)); gcs_core_send_lock_step (Core, true); mark_point(); }
END_TEST START_TEST (test_get_entries) { xmlXPathObject *xpath_obj = NULL; xmlDoc *doc = NULL; xmlNodeSet *nodes; struct gcal_event known_value; struct gcal_event extracted; int res; gcal_init_event(&known_value); gcal_init_event(&extracted); res = build_doc_tree(&doc, xml_data); fail_if(res == -1, "failed to build document tree!"); xpath_obj = atom_get_entries(doc); fail_if(xpath_obj == NULL, "failed to get entry node list!"); nodes = xpath_obj->nodesetval; fail_if(nodes->nodeNr != 4, "should return 4 entries!"); res = atom_extract_data(nodes->nodeTab[0], &extracted); fail_if(res == -1, "failed to extract data from node!"); known_value.common.title = "an event with location"; known_value.common.id = "http://www.google.com/calendar/feeds/gcal4tester%40gmail.com/private/full/saq81ktu4iqv7r20b8ctv70q7s"; known_value.common.edit_uri = "http://www.google.com/calendar/feeds/gcal4tester%40gmail.com/private/full/saq81ktu4iqv7r20b8ctv70q7s/63342246051"; known_value.content = "I should be there"; /* The event is not recurrent: for empty fields, I use a empty string */ known_value.dt_recurrent = ""; known_value.dt_start = "2008-03-26T18:00:00.000-05:00"; known_value.dt_end = "2008-03-26T19:00:00.000-05:00"; known_value.where = "my house"; known_value.status = "http://schemas.google.com/g/2005#event.confirmed"; known_value.common.updated = "2008-03-26T20:20:51.000Z"; fail_if(strcmp(known_value.common.title, extracted.common.title), "failed field extraction"); fail_if(strcmp(known_value.common.id, extracted.common.id), "failed field extraction"); fail_if(strcmp(known_value.common.edit_uri, extracted.common.edit_uri), "failed field extraction"); fail_if(strcmp(known_value.content, extracted.content), "failed field extraction"); fail_if(strcmp(known_value.dt_recurrent, extracted.dt_recurrent), "failed field extraction"); fail_if(strcmp(known_value.dt_start, extracted.dt_start), "failed field extraction"); fail_if(strcmp(known_value.dt_end, extracted.dt_end), "failed field extraction"); fail_if(strcmp(known_value.where, extracted.where), "failed field extraction"); fail_if(strcmp(known_value.status, extracted.status), "failed field extraction"); fail_if(strcmp(known_value.common.updated, extracted.common.updated), "failed field extraction"); if (xpath_obj) xmlXPathFreeObject(xpath_obj); gcal_destroy_entry(&extracted); clean_doc_tree(&doc); }
END_TEST START_TEST (test_pqueue_send_and_receive_three_groups) { OMX_U32 i; OMX_PTR p_received = NULL; OMX_ERRORTYPE error = OMX_ErrorNone; int *p_item = NULL; tiz_pqueue_t *p_queue = NULL; TIZ_LOG (TIZ_TRACE, "test_pqueue_send_and_receive_three_groups"); error = tiz_pqueue_init (&p_queue, 2, &pqueue_cmp, NULL, "tizkrn"); fail_if (error != OMX_ErrorNone); for (i = 0; i < 3; i++) { p_item = (int *) tiz_mem_alloc (sizeof (int)); fail_if (p_item == NULL); *p_item = i; error = tiz_pqueue_send (p_queue, p_item, 0); TIZ_LOG (TIZ_TRACE, "error [%X]", error); fail_if (error != OMX_ErrorNone); } for (i = 3; i < 7; i++) { p_item = (int *) tiz_mem_alloc (sizeof (int)); fail_if (p_item == NULL); *p_item = i; error = tiz_pqueue_send (p_queue, p_item, 1); TIZ_LOG (TIZ_TRACE, "error [%X]", error); fail_if (error != OMX_ErrorNone); } for (i = 7; i < 10; i++) { p_item = (int *) tiz_mem_alloc (sizeof (int)); fail_if (p_item == NULL); *p_item = i; error = tiz_pqueue_send (p_queue, p_item, 2); TIZ_LOG (TIZ_TRACE, "error [%X]", error); fail_if (error != OMX_ErrorNone); } TIZ_LOG (TIZ_TRACE, "queue length %d", tiz_pqueue_length (p_queue)); fail_if (10 != tiz_pqueue_length (p_queue)); for (i = 0; i < 3; i++) { error = tiz_pqueue_receive (p_queue, &p_received); fail_if (error != OMX_ErrorNone); fail_if (p_received == NULL); p_item = (int *) p_received; TIZ_LOG (TIZ_TRACE, "item [%d]", *p_item); fail_if (*p_item != i); tiz_mem_free (p_received); } for (i = 3; i < 7; i++) { error = tiz_pqueue_receive (p_queue, &p_received); fail_if (error != OMX_ErrorNone); fail_if (p_received == NULL); p_item = (int *) p_received; TIZ_LOG (TIZ_TRACE, "item [%d]", *p_item); fail_if (*p_item != i); tiz_mem_free (p_received); } for (i = 7; i <= 10; i++) { error = tiz_pqueue_receive (p_queue, &p_received); if (i > 9) { fail_if (error != OMX_ErrorNoMore); } else { fail_if (error != OMX_ErrorNone); } fail_if (p_received == NULL); p_item = (int *) p_received; if (i < 10) { TIZ_LOG (TIZ_TRACE, "item [%d]", *p_item); fail_if (*p_item != i); tiz_mem_free (p_received); } } tiz_pqueue_destroy (p_queue); }
END_TEST START_TEST(test_dn_write_file) { const char *tf = "/HADOOFUS_TEST_WRITE_FILE", *client = "HADOOFUS_CLIENT", *err; bool s; struct hdfs_datanode *dn; struct hdfs_object *e = NULL, *bl, *fs, *bls; uint64_t begin, end; s = hdfs_delete(h, tf, false/*recurse*/, &e); if (e) fail("exception: %s", hdfs_exception_get_message(e)); hdfs_create(h, tf, 0644, client, true/*overwrite*/, false/*createparent*/, 1/*replication*/, blocksz, &e); if (e) fail("exception: %s", hdfs_exception_get_message(e)); begin = _now(); // write first block (full) bl = hdfs_addBlock(h, tf, client, NULL, &e); if (e) fail("exception: %s", hdfs_exception_get_message(e)); dn = hdfs_datanode_new(bl, client, HDFS_DATANODE_AP_1_0, &err); ck_assert_msg((intptr_t)dn, "error connecting to datanode: %s", err); hdfs_object_free(bl); err = hdfs_datanode_write_file(dn, fd, blocksz, 0, _i/*crcs*/); fail_if(err, "error writing block: %s", err); hdfs_datanode_delete(dn); // write second block (partial) bl = hdfs_addBlock(h, tf, client, NULL, &e); if (e) fail("exception: %s", hdfs_exception_get_message(e)); dn = hdfs_datanode_new(bl, client, HDFS_DATANODE_AP_1_0, &err); ck_assert_msg((intptr_t)dn, "error connecting to datanode: %s", err); hdfs_object_free(bl); err = hdfs_datanode_write_file(dn, fd, towrite-blocksz, blocksz, _i/*crcs*/); fail_if(err, "error writing block: %s", err); hdfs_datanode_delete(dn); end = _now(); fprintf(stderr, "Wrote %d MB from file in %ld ms%s, %02g MB/s\n", towrite/1024/1024, end - begin, _i? " (with crcs)":"", (double)towrite/(end-begin)/1024*1000/1024); fs = hdfs_getFileInfo(h, tf, &e); if (e) fail("exception: %s", hdfs_exception_get_message(e)); ck_assert(fs->ob_val._file_status._size == towrite); hdfs_object_free(fs); s = hdfs_complete(h, tf, client, &e); if (e) fail("exception: %s", hdfs_exception_get_message(e)); ck_assert_msg(s, "did not complete"); bls = hdfs_getBlockLocations(h, tf, 0, towrite, &e); if (e) fail("exception: %s", hdfs_exception_get_message(e)); begin = _now(); for (int i = 0; i < bls->ob_val._located_blocks._num_blocks; i++) { struct hdfs_object *bl = bls->ob_val._located_blocks._blocks[i]; dn = hdfs_datanode_new(bl, client, HDFS_DATANODE_AP_1_0, &err); ck_assert_msg((intptr_t)dn, "error connecting to datanode: %s", err); err = hdfs_datanode_read_file(dn, 0/*offset-in-block*/, bl->ob_val._located_block._len, ofd, i*blocksz/*fd offset*/, _i/*crcs*/); hdfs_datanode_delete(dn); if (err == HDFS_DATANODE_ERR_NO_CRCS) { fprintf(stderr, "Warning: test server doesn't support " "CRCs, skipping validation.\n"); _i = 0; // reconnect, try again without validating CRCs (for // isi_hdfs_d) dn = hdfs_datanode_new(bl, client, HDFS_DATANODE_AP_1_0, &err); ck_assert_msg((intptr_t)dn, "error connecting to datanode: %s", err); err = hdfs_datanode_read_file(dn, 0/*offset-in-block*/, bl->ob_val._located_block._len, ofd, i*blocksz, false/*crcs*/); hdfs_datanode_delete(dn); } fail_if(err, "error reading block: %s", err); } end = _now(); fprintf(stderr, "Read %d MB to file in %ld ms%s, %02g MB/s\n", towrite/1024/1024, end - begin, _i? " (with crcs)":"", (double)towrite/(end-begin)/1024*1000/1024); hdfs_object_free(bls); fail_if(filecmp(fd, ofd, towrite), "read differed from write"); s = hdfs_delete(h, tf, false/*recurse*/, &e); if (e) fail("exception: %s", hdfs_exception_get_message(e)); ck_assert_msg(s, "delete returned false"); }
END_TEST /* * Test case based on captured data where * replies are sent from a different IP than the * one the client unicasted to. */ START_TEST(test_dhcp_relayed) { const u8_t relay_offer[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, 0x08, 0x00, 0x45, 0x00, 0x01, 0x38, 0xfd, 0x53, 0x00, 0x00, 0x40, 0x11, 0x78, 0x46, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x51, 0x35, 0xb6, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08, 0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1, 0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04, 0x00, 0x00, 0x54, 0x49, 0x35, 0x01, 0x02, 0x36, 0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff }; const u8_t relay_ack1[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, 0x08, 0x00, 0x45, 0x00, 0x01, 0x38, 0xfd, 0x55, 0x00, 0x00, 0x40, 0x11, 0x78, 0x44, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x51, 0x35, 0xb6, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08, 0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1, 0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04, 0x00, 0x00, 0x54, 0x49, 0x35, 0x01, 0x05, 0x36, 0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff }; const u8_t relay_ack2[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, 0x08, 0x00, 0x45, 0x00, 0x01, 0x38, 0xfa, 0x18, 0x00, 0x00, 0x40, 0x11, 0x7b, 0x81, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24, 0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x49, 0x8b, 0x6e, 0xab, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x8a, 0x33, 0x05, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08, 0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1, 0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04, 0x00, 0x00, 0x54, 0x60, 0x35, 0x01, 0x05, 0x36, 0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff }; const u8_t arp_resp[] = { 0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, // DEST 0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, // SRC 0x08, 0x06, // Type: ARP 0x00, 0x01, // HW: Ethernet 0x08, 0x00, // PROTO: IP 0x06, // HW size 0x04, // PROTO size 0x00, 0x02, // OPCODE: Reply 0x12, 0x34, 0x56, 0x78, 0x9a, 0xab, // Target MAC 0x4f, 0x8a, 0x32, 0x01, // Target IP 0x00, 0x23, 0xc1, 0x00, 0x06, 0x50, // src mac 0x4f, 0x8a, 0x33, 0x05, // src ip // Padding follows.. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; struct ip_addr addr; struct ip_addr netmask; struct ip_addr gw; int i; u32_t xid; LWIP_UNUSED_ARG(_i); tcase = TEST_LWIP_DHCP_RELAY; setdebug(0); IP4_ADDR(&addr, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0); netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input); dhcp_start(&net_test); fail_unless(txpacket == 1); // DHCP discover sent // Interface down fail_if(netif_is_up(&net_test)); // IP addresses should be zero fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(struct ip_addr))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(struct ip_addr))); fail_if(memcmp(&gw, &net_test.gw, sizeof(struct ip_addr))); fail_unless(txpacket == 1); // Nothing more sent xid = htonl(net_test.dhcp->xid); memcpy(&relay_offer[46], &xid, 4); // insert correct transaction id send_pkt(&net_test, relay_offer, sizeof(relay_offer)); // request sent? fail_unless(txpacket == 2, "txpkt = %d, should be 2", txpacket); xid = htonl(net_test.dhcp->xid); // xid updated memcpy(&relay_ack1[46], &xid, 4); // insert transaction id send_pkt(&net_test, relay_ack1, sizeof(relay_ack1)); for (i = 0; i < 25; i++) { tick_lwip(); } fail_unless(txpacket == 4, "txpkt should be 5, is %d", txpacket); // ARP requests sent // Interface up fail_unless(netif_is_up(&net_test)); // Now it should have taken the IP IP4_ADDR(&addr, 79, 138, 51, 5); IP4_ADDR(&netmask, 255, 255, 254, 0); IP4_ADDR(&gw, 79, 138, 50, 1); fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(struct ip_addr))); fail_if(memcmp(&netmask, &net_test.netmask, sizeof(struct ip_addr))); fail_if(memcmp(&gw, &net_test.gw, sizeof(struct ip_addr))); fail_unless(txpacket == 4, "txpacket = %d", txpacket); for (i = 0; i < 108000 - 25; i++) { tick_lwip(); } fail_unless(netif_is_up(&net_test)); fail_unless(txpacket == 6, "txpacket = %d", txpacket); // We need to send arp response here.. send_pkt(&net_test, arp_resp, sizeof(arp_resp)); fail_unless(txpacket == 7, "txpacket = %d", txpacket); fail_unless(netif_is_up(&net_test)); xid = htonl(net_test.dhcp->xid); // xid updated memcpy(&relay_ack2[46], &xid, 4); // insert transaction id send_pkt(&net_test, relay_ack2, sizeof(relay_ack2)); for (i = 0; i < 100000; i++) { tick_lwip(); } fail_unless(txpacket == 7, "txpacket = %d", txpacket); netif_remove(&net_test); }
void test_multichannel_checks() { GstAudioChannelPosition pos_2_mixed[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_MONO, GST_AUDIO_CHANNEL_POSITION_NONE }; GstAudioChannelPosition pos_2_none[2] = { GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE }; GstAudioChannelPosition pos_2_flr[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT }; GstAudioChannelPosition pos_2_frr[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT }; GstStructure *s; xmlfile = "test_multichannel_checks"; std_log(LOG_FILENAME_LINE, "Test Started test_multichannel_checks"); s = gst_structure_new ("audio/x-raw-int", "channels", G_TYPE_INT, 2, NULL); /* this should not work and issue a warning: FRONT_MONO + NONE */ // _gst_check_expecting_log = TRUE; // gst_audio_set_channel_positions (s, pos_2_mixed); // _gst_check_expecting_log = FALSE; // fail_if (structure_contains_channel_positions (s)); /* this should work: NONE + NONE */ gst_audio_set_channel_positions (s, pos_2_none); fail_unless (structure_contains_channel_positions (s)); gst_structure_remove_field (s, "channel-positions"); /* this should also work: FRONT_LEFT + FRONT_RIGHT */ gst_audio_set_channel_positions (s, pos_2_flr); fail_unless (structure_contains_channel_positions (s)); gst_structure_remove_field (s, "channel-positions"); /* this should not work and issue a warning: FRONT_RIGHT twice */ // _gst_check_expecting_log = TRUE; // gst_audio_set_channel_positions (s, pos_2_frr); // _gst_check_expecting_log = FALSE; /* FIXME: did I misunderstand _set_structure_channel_positions_list? */ #if 0 /* this should not work and issue a warning: FRONT_RIGHT twice */ _gst_check_expecting_log = TRUE; gst_audio_set_structure_channel_positions_list (s, pos_2_frr, 2); _gst_check_expecting_log = FALSE; /* this should not work and issue a warning: FRONT_MONO + NONE */ _gst_check_expecting_log = TRUE; gst_audio_set_structure_channel_positions_list (s, pos_2_mixed, 2); _gst_check_expecting_log = FALSE; /* this should not work either (channel count mismatch) */ _gst_check_expecting_log = TRUE; gst_audio_set_structure_channel_positions_list (s, pos_2_none, 44); _gst_check_expecting_log = FALSE; fail_if (structure_contains_channel_positions (s)); #endif gst_structure_free (s); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
GST_END_TEST GST_START_TEST (connect_chain_of_elements) { gchar *padname = NULL; KmsConnectData *data1, *data2; gchar *filter_factory; GstBus *bus; loop = g_main_loop_new (NULL, TRUE); pipeline = gst_pipeline_new (__FUNCTION__); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline); data1 = kms_connect_data_create (0); data2 = kms_connect_data_create (MAX_CHECKS); data2->data_probe = (KmsProbeType) data_probe_cb; data2->audio_probe = (KmsProbeType) audio_probe_cb; data2->video_probe = (KmsProbeType) video_probe_cb; gst_element_set_state (pipeline, GST_STATE_PLAYING); data1->src = gst_element_factory_make ("dummysrc", NULL); data1->sink = gst_element_factory_make ("filterelement", NULL); data2->src = data1->sink; data2->sink = gst_element_factory_make ("dummysink", NULL); g_signal_connect (data1->src, "pad-added", G_CALLBACK (src_pads_added), data1); g_signal_connect (data1->sink, "pad-added", G_CALLBACK (sink_pads_added), data1); g_signal_connect (data2->src, "pad-added", G_CALLBACK (src_pads_added), data2); g_signal_connect (data2->sink, "pad-added", G_CALLBACK (sink_pads_added), data2); g_signal_connect (data2->sink, "pad-removed", G_CALLBACK (sink_pads_removed), data2); gst_bin_add_many (GST_BIN (pipeline), data1->src, data1->sink, data2->sink, NULL); /*******************************/ /* Connect dummysrc to filter */ /*******************************/ /* request src pad using action */ g_signal_emit_by_name (data1->src, "request-new-pad", KMS_ELEMENT_PAD_TYPE_VIDEO, NULL, GST_PAD_SRC, &data1->video_src); fail_if (data1->video_src == NULL); g_signal_emit_by_name (data1->src, "request-new-pad", KMS_ELEMENT_PAD_TYPE_AUDIO, NULL, GST_PAD_SRC, &data1->audio_src); fail_if (data1->audio_src == NULL); g_signal_emit_by_name (data1->src, "request-new-pad", KMS_ELEMENT_PAD_TYPE_DATA, NULL, GST_PAD_SRC, &data1->data_src); fail_if (data1->data_src == NULL); GST_DEBUG ("Video pad name %s", data1->video_src); GST_DEBUG ("Audio pad name %s", data1->audio_src); GST_DEBUG ("Data pad name %s", data1->data_src); filter_factory = "videoflip"; GST_DEBUG ("Setting property uri to : %s", filter_factory); g_object_set (G_OBJECT (data1->sink), "filter_factory", filter_factory, NULL); g_object_set (G_OBJECT (data1->src), "video", TRUE, "audio", TRUE, "data", TRUE, NULL); /*******************************/ /* Connect filter to dummysink */ /*******************************/ /* request src pad using action */ g_signal_emit_by_name (data2->src, "request-new-pad", KMS_ELEMENT_PAD_TYPE_VIDEO, NULL, GST_PAD_SRC, &data2->video_src); fail_if (data2->video_src == NULL); g_signal_emit_by_name (data2->src, "request-new-pad", KMS_ELEMENT_PAD_TYPE_AUDIO, NULL, GST_PAD_SRC, &data2->audio_src); fail_if (data2->audio_src == NULL); g_signal_emit_by_name (data2->src, "request-new-pad", KMS_ELEMENT_PAD_TYPE_DATA, NULL, GST_PAD_SRC, &data2->data_src); fail_if (data2->data_src == NULL); GST_DEBUG ("Video pad name %s", data2->video_src); GST_DEBUG ("Audio pad name %s", data2->audio_src); GST_DEBUG ("Data pad name %s", data2->data_src); g_object_set (G_OBJECT (data2->sink), "video", TRUE, "audio", TRUE, "data", TRUE, NULL); g_timeout_add_seconds (4, print_timedout_pipeline, NULL); gst_element_sync_state_with_parent (data1->src); gst_element_sync_state_with_parent (data1->sink); gst_element_sync_state_with_parent (data2->sink); g_main_loop_run (loop); gst_element_set_state (pipeline, GST_STATE_NULL); gst_bus_remove_signal_watch (bus); g_object_unref (bus); g_object_unref (pipeline); g_free (padname); g_main_loop_unref (loop); kms_connect_data_destroy (data1); kms_connect_data_destroy (data2); }
static inline void change_state (CustomData *core, OMX_STATETYPE state) { fail_if (OMX_SendCommand (core->omx_handle, OMX_CommandStateSet, state, NULL) != OMX_ErrorNone); }
END_TEST //-------------------- START_TEST (test_iter_db) { GlyrQuery q; setup (&q,GLYR_GET_LYRICS,10); glyr_opt_artist (&q,"Equi"); glyr_opt_title (&q,"lala"); GlyrDatabase * db = setup_db(); GlyrQuery nugget; setup (&nugget,GLYR_GET_COVERART,40); glyr_opt_artist (&nugget,"A very special artist"); glyr_opt_album (&nugget,"A very special album"); GTimer * insert_time = g_timer_new(); const int N = 5000; for (int i = 0; i < N; i++) { GlyrMemCache * ct = glyr_cache_new(); glyr_cache_set_data (ct,g_strdup_printf ("test# %d",i+1),-1); ct->dsrc = g_strdup_printf ("Dummy url %d",i+1); if (i % 2) ct->rating = N ; else ct->rating = N ; if (i % 23) glyr_db_insert (db,&q,ct); else glyr_db_insert (db,&nugget,ct); glyr_cache_free (ct); } g_timer_stop (insert_time); g_message ("Used %.5f seconds to insert..",g_timer_elapsed (insert_time,NULL) ); /* Check if N items are in DB */ int cdb = count_db_items (db); g_message ("Counted %d items",cdb); fail_unless (cdb == N, NULL); /* Test if case-insensitivity works */ glyr_opt_artist (&q,"eQuI"); glyr_opt_title (&q,"LALA"); float fine_grained = 0.0; GTimer * grain_time = g_timer_new(); g_timer_start (insert_time); GlyrMemCache * c, * ptr; for (int i = 1; i <= N/10; i++) { g_timer_start (grain_time); /* Get a list of the caches */ if (i % 10) c = glyr_db_lookup (db,&q); else c = glyr_db_lookup (db,&nugget); g_timer_stop (grain_time); fine_grained += g_timer_elapsed (grain_time,NULL); ptr = c; fail_if (ptr == NULL); int last_rating = INT_MAX; int ctr = 0; while (ptr) { ctr++; fail_unless (last_rating >= ptr->rating); last_rating = ptr->rating; ptr = ptr->next; } glyr_free_list (c); /* Test if we got exactly 10 or 42 items, (honoring number setting) */ if (i % 10) fail_unless (ctr == 10); else fail_unless (ctr == 40); } g_timer_stop (insert_time); g_message ("Used %.5f seconds to lookup..",g_timer_elapsed (insert_time,NULL) ); g_message ("Used %.5f for actual lookup..",fine_grained); glyr_db_destroy (db); glyr_query_destroy (&q); glyr_query_destroy (&nugget); g_timer_destroy (insert_time); g_timer_destroy (grain_time); }
/* make sure our script gets called with the right parameters */ static void test_pb_utils_install_plugins_do_callout (gchar ** details, GstInstallPluginsContext * ctx, const gchar * script, GstInstallPluginsReturn expected_result) { #ifdef G_OS_UNIX GstInstallPluginsReturn ret; GError *err = NULL; gchar *path; path = g_strdup_printf ("%s/gst-plugins-base-unit-test-helper.%s.%lu", g_get_tmp_dir (), (g_get_user_name ())? g_get_user_name () : "nobody", (gulong) getpid ()); if (!g_file_set_contents (path, script, -1, &err)) { GST_DEBUG ("Failed to write test script to %s: %s", path, err->message); g_error_free (err); goto done; } if (chmod (path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) { GST_DEBUG ("Could not set mode u+rwx on '%s'", path); goto done; } /* test gst_install_plugins_supported() I */ g_setenv ("GST_INSTALL_PLUGINS_HELPER", "/i/do/not/ex.ist!", 1); fail_if (gst_install_plugins_supported ()); GST_LOG ("setting GST_INSTALL_PLUGINS_HELPER to '%s'", path); g_setenv ("GST_INSTALL_PLUGINS_HELPER", path, 1); /* test gst_install_plugins_supported() II */ fail_unless (gst_install_plugins_supported ()); /* test sync callout */ ret = gst_install_plugins_sync (details, ctx); fail_unless (ret == GST_INSTALL_PLUGINS_HELPER_MISSING || ret == expected_result, "gst_install_plugins_sync() failed with unexpected ret %d, which is " "neither HELPER_MISSING nor %d", ret, expected_result); /* test async callout */ marker = -333; ret = gst_install_plugins_async (details, ctx, result_cb, (gpointer) & marker); fail_unless (ret == GST_INSTALL_PLUGINS_HELPER_MISSING || ret == GST_INSTALL_PLUGINS_STARTED_OK, "gst_install_plugins_async() failed with unexpected ret %d", ret); if (ret == GST_INSTALL_PLUGINS_STARTED_OK) { while (marker == -333) { g_usleep (500); g_main_context_iteration (NULL, FALSE); } /* and check that the callback was called with the expected code */ fail_unless_equals_int (marker, expected_result); } done: unlink (path); g_free (path); #endif /* G_OS_UNIX */ }
static void test_photography_settings (GstElement * cam) { GTypeClass *tclass; gfloat ev_comp, orig_ev_comp; guint iso_speed = 100, orig_iso_speed; GstFlashMode flash, orig_flash; GstWhiteBalanceMode wb, orig_wb; GstColourToneMode ct, orig_ct; GstSceneMode sm, orig_sm; GstFlickerReductionMode flm, orig_flm; GstFocusMode fm, orig_fm; gfloat zoom, orig_zoom; if (!GST_IS_PHOTOGRAPHY (cam)) { GST_WARNING ("omitting photography settings test, " "photography interface not implemented"); return; } for (ev_comp = -3.0; ev_comp <= 3.0; ev_comp += 0.5) { orig_ev_comp = ev_comp; gst_photography_set_ev_compensation (GST_PHOTOGRAPHY (cam), ev_comp); gst_photography_get_ev_compensation (GST_PHOTOGRAPHY (cam), &ev_comp); fail_if (orig_ev_comp != ev_comp, "setting photography ev compensation failed"); ev_comp = orig_ev_comp; g_usleep (PHOTO_SETTING_DELAY_US); } /* FIXME: what are the actual iso values? */ for (iso_speed = 100; iso_speed <= 800; iso_speed *= 2) { orig_iso_speed = iso_speed; gst_photography_set_iso_speed (GST_PHOTOGRAPHY (cam), iso_speed); gst_photography_get_iso_speed (GST_PHOTOGRAPHY (cam), &iso_speed); fail_if (orig_iso_speed != iso_speed, "setting photography iso speed failed"); iso_speed = orig_iso_speed; g_usleep (PHOTO_SETTING_DELAY_US); } tclass = g_type_class_ref (GST_TYPE_FLASH_MODE); for (flash = 0; flash < G_ENUM_CLASS (tclass)->n_values; flash++) { orig_flash = flash; gst_photography_set_flash_mode (GST_PHOTOGRAPHY (cam), flash); gst_photography_get_flash_mode (GST_PHOTOGRAPHY (cam), &flash); fail_if (orig_flash != flash, "setting photography flash failed"); flash = orig_flash; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); tclass = g_type_class_ref (GST_TYPE_WHITE_BALANCE_MODE); for (wb = 0; wb < G_ENUM_CLASS (tclass)->n_values; wb++) { orig_wb = wb; gst_photography_set_white_balance_mode (GST_PHOTOGRAPHY (cam), wb); gst_photography_get_white_balance_mode (GST_PHOTOGRAPHY (cam), &wb); fail_if (orig_wb != wb, "setting photography white balance mode failed"); wb = orig_wb; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); tclass = g_type_class_ref (GST_TYPE_COLOUR_TONE_MODE); for (ct = 0; ct < G_ENUM_CLASS (tclass)->n_values; ct++) { orig_ct = ct; gst_photography_set_colour_tone_mode (GST_PHOTOGRAPHY (cam), ct); gst_photography_get_colour_tone_mode (GST_PHOTOGRAPHY (cam), &ct); fail_if (orig_ct != ct, "setting photography colour tone mode failed"); ct = orig_ct; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); tclass = g_type_class_ref (GST_TYPE_SCENE_MODE); for (sm = 0; sm < G_ENUM_CLASS (tclass)->n_values; sm++) { orig_sm = sm; gst_photography_set_scene_mode (GST_PHOTOGRAPHY (cam), sm); gst_photography_get_scene_mode (GST_PHOTOGRAPHY (cam), &sm); fail_if (orig_sm != sm, "setting photography scene mode failed"); sm = orig_sm; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); tclass = g_type_class_ref (GST_TYPE_FOCUS_MODE); for (fm = 0; fm < G_ENUM_CLASS (tclass)->n_values; fm++) { orig_fm = fm; gst_photography_set_focus_mode (GST_PHOTOGRAPHY (cam), fm); gst_photography_get_focus_mode (GST_PHOTOGRAPHY (cam), &fm); fail_if (orig_fm != fm, "setting photography focus mode failed"); fm = orig_fm; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); tclass = g_type_class_ref (GST_TYPE_FLICKER_REDUCTION_MODE); for (flm = 0; flm < G_ENUM_CLASS (tclass)->n_values; flm++) { orig_flm = flm; gst_photography_set_flicker_mode (GST_PHOTOGRAPHY (cam), flm); gst_photography_get_flicker_mode (GST_PHOTOGRAPHY (cam), &flm); fail_if (orig_flm != flm, "setting photography flicker mode failed"); flm = orig_flm; g_usleep (PHOTO_SETTING_DELAY_US); } g_type_class_unref (tclass); for (zoom = 1.0; zoom <= 10.0; zoom += 1.0) { orig_zoom = zoom; gst_photography_set_zoom (GST_PHOTOGRAPHY (cam), zoom); gst_photography_get_zoom (GST_PHOTOGRAPHY (cam), &zoom); fail_if (orig_zoom != zoom, "setting photography zoom failed"); zoom = orig_zoom; g_usleep (PHOTO_SETTING_DELAY_US); } }
void datamul_4_2_tests(uint32_t chunksize, float32_t eps) { uint32_t r, c, rows, cols; float32_t errf; uint64_t frames=8; uint32_t rawchannels=2; uint32_t cokchannels=4; float32_t*inputdata; float32_t*outputdata; float32_t*targetdata; float32_t freq=500; ambix_matrix_t eye = {0, 0, NULL}; STARTTEST(""); inputdata =data_sine(frames, rawchannels, freq); targetdata=data_sine(frames, cokchannels, freq); outputdata=(float32_t*)malloc(sizeof(float32_t)*frames*cokchannels); fail_if((NULL==outputdata), __LINE__, "couldn't allocate outputdata"); ambix_matrix_init(cokchannels, rawchannels, &eye); rows=eye.rows; cols=eye.cols; for(r=0; r<rows; r++) { for(c=0; c<cols; c++) { eye.data[r][c]=(1+r+c)%2; } } #if 0 matrix_print(&eye); printf("input\n"); data_print(inputdata, rawchannels*frames); #endif fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_multiply_float32(outputdata, &eye, inputdata, frames), __LINE__, "data multilplication failed"); #if 0 printf("output\n"); data_print(outputdata, cokchannels*frames); printf("target\n"); data_print(targetdata, cokchannels*frames); #endif errf=data_diff(__LINE__, targetdata, outputdata, frames*cokchannels, eps); fail_if(!(errf<eps), __LINE__, "diffing data multiplication returned %f (>%f)", errf, eps); #if 0 printf("matrix:\n"); matrix_print(&eye); printf("input :\n"); data_print(inputdata, frames*channels); printf("output:\n"); data_print(outputdata,frames*channels); #endif ambix_matrix_deinit(&eye); free(inputdata); free(outputdata); free(targetdata); }