static gpointer
push_abuffers (gpointer data)
{
  GstSegment segment;
  GstPad *pad = data;
  gint i, j, k;
  GstClockTime timestamp = 0;
  GstAudioInfo info;
  GstCaps *caps;
  guint buf_size = 1000;

  if (audiodelay)
    g_usleep (2000);

  if (early_video)
    timestamp = 50 * GST_MSECOND;

  gst_pad_send_event (pad, gst_event_new_stream_start ("test"));

  gst_audio_info_set_format (&info, GST_AUDIO_FORMAT_S8, buf_size, channels,
      NULL);
  caps = gst_audio_info_to_caps (&info);
  gst_pad_send_event (pad, gst_event_new_caps (caps));
  gst_caps_unref (caps);

  gst_segment_init (&segment, GST_FORMAT_TIME);
  gst_pad_send_event (pad, gst_event_new_segment (&segment));

  for (i = 0; i < n_abuffers; i++) {
    GstBuffer *buf = gst_buffer_new_and_alloc (channels * buf_size);

    if (per_channel) {
      GstMapInfo map;
      guint8 *in_data;

      gst_buffer_map (buf, &map, GST_MAP_WRITE);
      in_data = map.data;

      for (j = 0; j < buf_size; j++) {
        for (k = 0; k < channels; k++) {
          in_data[j * channels + k] = fill_value_per_channel[k];
        }
      }

      gst_buffer_unmap (buf, &map);
    } else {
      gst_buffer_memset (buf, 0, fill_value, channels * buf_size);
    }

    GST_BUFFER_TIMESTAMP (buf) = timestamp;
    timestamp += 1 * GST_SECOND;
    if (audio_drift)
      timestamp += 50 * GST_MSECOND;
    else if (i == 4 && audio_nondiscont)
      timestamp += 30 * GST_MSECOND;
    GST_BUFFER_DURATION (buf) = timestamp - GST_BUFFER_TIMESTAMP (buf);

    fail_unless (gst_pad_chain (pad, buf) == GST_FLOW_OK);
  }
  gst_pad_send_event (pad, gst_event_new_eos ());

  return NULL;
}
Пример #2
0
static void
run_test (const GstCaps * caps, gint src_width, gint src_height,
    gint dest_width, gint dest_height, gint method,
    GCallback src_handoff, gpointer src_handoff_user_data,
    GCallback sink_handoff, gpointer sink_handoff_user_data)
{
  GstElement *pipeline;
  GstElement *src, *videoconvert, *capsfilter1, *identity, *scale,
      *capsfilter2, *sink;
  GstMessage *msg;
  GstBus *bus;
  GstCaps *copy;
  guint n_buffers = 0;

  /* skip formats that videoconvert can't handle */
  if (!videoconvert_supports_caps (caps))
    return;

  pipeline = gst_element_factory_make ("pipeline", "pipeline");
  fail_unless (pipeline != NULL);

  src = gst_element_factory_make ("videotestsrc", "src");
  fail_unless (src != NULL);
  g_object_set (G_OBJECT (src), "num-buffers", 1, NULL);

  videoconvert = gst_element_factory_make ("videoconvert", "csp");
  fail_unless (videoconvert != NULL);

  capsfilter1 = gst_element_factory_make ("capsfilter", "filter1");
  fail_unless (capsfilter1 != NULL);
  copy = gst_caps_copy (caps);
  gst_caps_set_simple (copy, "width", G_TYPE_INT, src_width, "height",
      G_TYPE_INT, src_height, "framerate", GST_TYPE_FRACTION, 30, 1, NULL);
  g_object_set (G_OBJECT (capsfilter1), "caps", copy, NULL);
  gst_caps_unref (copy);

  identity = gst_element_factory_make ("identity", "identity");
  fail_unless (identity != NULL);
  if (src_handoff) {
    g_object_set (G_OBJECT (identity), "signal-handoffs", TRUE, NULL);
    g_signal_connect (identity, "handoff", G_CALLBACK (src_handoff),
        src_handoff_user_data);
  }

  scale = gst_element_factory_make ("videoscale", "scale");
  fail_unless (scale != NULL);
  g_object_set (G_OBJECT (scale), "method", method, NULL);

  capsfilter2 = gst_element_factory_make ("capsfilter", "filter2");
  fail_unless (capsfilter2 != NULL);
  copy = gst_caps_copy (caps);
  gst_caps_set_simple (copy, "width", G_TYPE_INT, dest_width, "height",
      G_TYPE_INT, dest_height, NULL);
  g_object_set (G_OBJECT (capsfilter2), "caps", copy, NULL);
  gst_caps_unref (copy);

  sink = gst_element_factory_make ("fakesink", "sink");
  fail_unless (sink != NULL);
  g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, "async", FALSE, NULL);
  g_signal_connect (sink, "handoff", G_CALLBACK (on_sink_handoff), &n_buffers);
  if (sink_handoff) {
    g_signal_connect (sink, "handoff", G_CALLBACK (sink_handoff),
        sink_handoff_user_data);
  }

  gst_bin_add_many (GST_BIN (pipeline), src, videoconvert, capsfilter1,
      identity, scale, capsfilter2, sink, NULL);

  fail_unless (gst_element_link_pads_full (src, "src", videoconvert, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (videoconvert, "src", capsfilter1,
          "sink", LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (capsfilter1, "src", identity, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (identity, "src", scale, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (scale, "src", capsfilter2, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (capsfilter2, "src", sink, "sink",
          LINK_CHECK_FLAGS));

  bus = gst_element_get_bus (pipeline);
  fail_unless (bus != NULL);

  fail_unless (gst_element_set_state (pipeline,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);

  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
      GST_MESSAGE_EOS | GST_MESSAGE_ERROR | GST_MESSAGE_WARNING);

  fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_EOS);

  fail_unless (gst_element_set_state (pipeline,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);

  fail_unless (n_buffers == 1);

  gst_object_unref (pipeline);
  gst_message_unref (msg);
  gst_object_unref (bus);
}
Пример #3
0
static void
_test_negotiation (const gchar * src_templ, const gchar * sink_templ,
    gint width, gint height, gint par_n, gint par_d)
{
  GstElement *pipeline;
  GstElement *src, *capsfilter1, *scale, *capsfilter2, *sink;
  GstBus *bus;
  GMainLoop *loop;
  GstCaps *caps;
  TestNegotiationData data = { 0, 0, 0, 0, FALSE, NULL };
  GstPad *pad;

  GST_DEBUG ("Running test for src templ caps '%s' and sink templ caps '%s'",
      src_templ, sink_templ);

  pipeline = gst_element_factory_make ("pipeline", "pipeline");
  fail_unless (pipeline != NULL);

  src = gst_element_factory_make ("videotestsrc", "src");
  fail_unless (src != NULL);
  g_object_set (G_OBJECT (src), "num-buffers", 1, NULL);

  capsfilter1 = gst_element_factory_make ("capsfilter", "filter1");
  fail_unless (capsfilter1 != NULL);
  caps = gst_caps_from_string (src_templ);
  fail_unless (caps != NULL);
  g_object_set (G_OBJECT (capsfilter1), "caps", caps, NULL);
  gst_caps_unref (caps);

  scale = gst_element_factory_make ("videoscale", "scale");
  fail_unless (scale != NULL);

  capsfilter2 = gst_element_factory_make ("capsfilter", "filter2");
  fail_unless (capsfilter2 != NULL);
  caps = gst_caps_from_string (sink_templ);
  fail_unless (caps != NULL);
  g_object_set (G_OBJECT (capsfilter2), "caps", caps, NULL);
  gst_caps_unref (caps);

  pad = gst_element_get_static_pad (capsfilter2, "sink");
  fail_unless (pad != NULL);
  g_signal_connect (pad, "notify::caps",
      G_CALLBACK (_test_negotiation_notify_caps), &data);
  gst_object_unref (pad);

  sink = gst_element_factory_make ("fakesink", "sink");
  fail_unless (sink != NULL);
  g_object_set (sink, "async", FALSE, NULL);

  gst_bin_add_many (GST_BIN (pipeline), src, capsfilter1, scale, capsfilter2,
      sink, NULL);

  fail_unless (gst_element_link_pads_full (src, "src", capsfilter1, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (capsfilter1, "src", scale, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (scale, "src", capsfilter2, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (capsfilter2, "src", sink, "sink",
          LINK_CHECK_FLAGS));

  loop = g_main_loop_new (NULL, FALSE);

  bus = gst_element_get_bus (pipeline);
  fail_unless (bus != NULL);
  gst_bus_add_signal_watch (bus);

  data.loop = loop;
  data.width = width;
  data.height = height;
  data.par_n = par_n;
  data.par_d = par_d;
  data.ok = FALSE;

  g_signal_connect (bus, "message", G_CALLBACK (_test_negotiation_message),
      &data);

  gst_bus_remove_signal_watch (bus);
  gst_object_unref (bus);

  fail_unless (gst_element_set_state (pipeline,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);

  g_main_loop_run (loop);

  fail_unless (data.ok == TRUE);

  fail_unless (gst_element_set_state (pipeline,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);

  gst_object_unref (pipeline);
  g_main_loop_unref (loop);
}
END_TEST 

START_TEST ( test_RenderCubicBezier_hasRequiredAttributes )
{
    fail_unless( P->hasRequiredAttributes() );
    P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless( P->hasRequiredAttributes() );
    P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,std::numeric_limits<double>::quiet_NaN()),RelAbsVector(60.0,70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(std::numeric_limits<double>::quiet_NaN(),50.0),RelAbsVector(60.0,70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(std::numeric_limits<double>::quiet_NaN(),70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,std::numeric_limits<double>::quiet_NaN()));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint1(RelAbsVector(20.0,std::numeric_limits<double>::quiet_NaN()),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint1(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint1(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless( P->hasRequiredAttributes() );
    P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless( P->hasRequiredAttributes() );
    P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,std::numeric_limits<double>::quiet_NaN()),RelAbsVector(60.0,70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(std::numeric_limits<double>::quiet_NaN(),50.0),RelAbsVector(60.0,70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(std::numeric_limits<double>::quiet_NaN(),70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,std::numeric_limits<double>::quiet_NaN()));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint2(RelAbsVector(20.0,std::numeric_limits<double>::quiet_NaN()),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint2(RelAbsVector(std::numeric_limits<double>::quiet_NaN(),30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless(! P->hasRequiredAttributes() );
    P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless( P->hasRequiredAttributes() );
}
Пример #5
0
int main(void)
{
    sp_log_set_level("debug");

    /*
     * str_legacy_to_utf8_lossy
     */
    char *w = str_legacy_to_utf8_lossy("ascii", "MS-ANSI");
    fail_unless(w);
    fail_unless(strcmp(w, "ascii") == 0);

#if 1
    w = str_legacy_to_utf8_lossy("abc \x40, should fail: \x81 \x8D \x8F \x9D \x9D", "MS-ANSI");
    fail_unless(w);
    fail_unless(strcmp(w, "abc @, should fail: ? ? ? ? ?") == 0);
#endif

    /*
     * str_utf8_to_legacy
     */

    /* See http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
     */

    /* this is "aring auml ouml" in composed UTF-8  */
    w = str_utf8_to_legacy("\xc3\xa5\xc3\xa4\xc3\xb6", "WINDOWS-1252");
    fail_unless(w);
    fail_unless(strcmp(w, "\xe5\xe4\xf6") == 0);
    free(w);

    /* this is "aring auml ouml" in de-composed UTF-8  */
    const char *utf8_decomposed_string = "a\xcc\x8a""a\xcc\x88""o\xcc\x88";
    fail_unless(strlen(utf8_decomposed_string) == 9);
    w = str_utf8_to_legacy(utf8_decomposed_string, "WINDOWS-1252");
    fail_unless(w);
    fail_unless(strcmp(w, "\xe5\xe4\xf6") == 0);
    free(w);

    /*
     * str_unescape_unicode
     */
    w = str_unescape_unicode("\\U000000e5\\u00e4\\U000000F6");
    fail_unless(w);
    fail_unless(strcmp(w, "\xc3\xa5\xc3\xa4\xc3\xb6") == 0);
    free(w);




    const char *user_command = "\xa8\xb0\xba\xa4\xf8";
    printf("user_command = [%s]\n", user_command);
    char *c1 = str_legacy_to_utf8(user_command, "WINDOWS-1252");
    fail_unless(c1);
    printf("converted string = [%s]\n", c1);

    const char *c1_utf8 = "\xc2\xa8\xc2\xb0\xc2\xba\xc2\xa4\xc3\xb8";
    fail_unless(strcmp(c1, c1_utf8) == 0);

    char *c2 = str_utf8_to_escaped_legacy(c1_utf8, "WINDOWS-1252");
    fail_unless(c2);
    printf("converted string = [%s]\n", c2);

    fail_unless(strcmp(c2, user_command) == 0);
    
    free(c1);
    free(c2);

    return 0;
}
Пример #6
0
END_TEST

START_TEST(test_source_wrapper)
{
	MockedSource *source;
	MafwRegistry *registry;
	GHashTable *metadata;
	DBusMessage *c;
	DBusMessage *replmsg;
	DBusMessageIter iter_array, iter_msg;
	gint i;
	const gchar *objlist[] = {"testobject", "testobject1", NULL};

	metadata = mockbus_mkmeta("title", "Easy", NULL);

	registry = mafw_registry_get_instance();
	mockbus_reset();
	wrapper_init();

	source = mocked_source_new("mocksource", "mocksource", Loop);

	mock_appearing_extension(FAKE_SOURCE_SERVICE, FALSE);
	mafw_registry_add_extension(MAFW_REGISTRY(registry),
                                    MAFW_EXTENSION(source));

	/* Browse */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_BROWSE,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_BOOLEAN(FALSE),
				      MAFW_DBUS_STRING("!(rating=sucks)"),
				      MAFW_DBUS_STRING("-year"),
				      MAFW_DBUS_C_STRVZ("title", "artist"),
				      MAFW_DBUS_UINT32(0),
				      MAFW_DBUS_UINT32(11)));
	replmsg = append_browse_res(NULL, &iter_msg, &iter_array, 1408, -1, 0,
                                    "testobject", metadata, "", 0, "");
	replmsg = append_browse_res(replmsg, &iter_msg, &iter_array, 1408, 0, 0,
                                    "", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);
	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_UINT32(1408)));

	mockbus_deliver(NULL);
	fail_unless(source->browse_called == 1);

	source->repeat_browse = 25;
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_BROWSE,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_BOOLEAN(FALSE),
				      MAFW_DBUS_STRING("!(rating=sucks)"),
				      MAFW_DBUS_STRING("-year"),
				      MAFW_DBUS_C_STRVZ("title", "artist"),
				      MAFW_DBUS_UINT32(0),
				      MAFW_DBUS_UINT32(11)));
	replmsg = NULL;
	for (i=0; i<25; i++)
		replmsg = append_browse_res(replmsg, &iter_msg, &iter_array,
                                            1408, -1, 0,
                                            "testobject", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);
	replmsg = append_browse_res(NULL, &iter_msg, &iter_array, 1408, 0, 0,
                                    "", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);
	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_UINT32(1408)));

	mockbus_deliver(NULL);
	fail_unless(source->browse_called == 2);

	source->repeat_browse = 830;
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_BROWSE,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_BOOLEAN(FALSE),
				      MAFW_DBUS_STRING("!(rating=sucks)"),
				      MAFW_DBUS_STRING("-year"),
				      MAFW_DBUS_C_STRVZ("title", "artist"),
				      MAFW_DBUS_UINT32(0),
				      MAFW_DBUS_UINT32(11)));
	replmsg = NULL;
	for (i=0; i<25; i++)
		replmsg = append_browse_res(replmsg, &iter_msg, &iter_array,
                                            1408, -1, 0,
                                            "testobject", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);
	replmsg = NULL;
	for (i=0; i<75; i++)
		replmsg = append_browse_res(replmsg, &iter_msg, &iter_array,
                                            1408, -1, 0,
                                            "testobject", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);
	replmsg = NULL;
	for (i=0; i<225; i++)
		replmsg = append_browse_res(replmsg, &iter_msg, &iter_array,
                                            1408, -1, 0,
                                            "testobject", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);
	replmsg = NULL;
	for (i=0; i<500; i++)
		replmsg = append_browse_res(replmsg, &iter_msg, &iter_array,
                                            1408, -1, 0,
                                            "testobject", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);
	replmsg = NULL;
	for (i=0; i<5; i++)
		replmsg = append_browse_res(replmsg, &iter_msg, &iter_array,
                                            1408, -1, 0,
                                            "testobject", metadata, "", 0, "");
	replmsg = append_browse_res(replmsg, &iter_msg, &iter_array, 1408, 0, 0,
				"", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);

	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_UINT32(1408)));

	mockbus_deliver(NULL);
	fail_unless(source->browse_called == 3);

	/* Cancel browse */
	source->repeat_browse = 25;
	source->dont_send_last = TRUE;
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_BROWSE,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_BOOLEAN(FALSE),
				      MAFW_DBUS_STRING(""),
				      MAFW_DBUS_STRING(""),
				      MAFW_DBUS_C_STRVZ("title", "artist"),
				      MAFW_DBUS_UINT32(0),
				      MAFW_DBUS_UINT32(11)));
	replmsg = NULL;
	for (i=0; i<25; i++)
		replmsg = append_browse_res(replmsg, &iter_msg, &iter_array,
                                            1408, -1, 0,
                                            "testobject", metadata, "", 0, "");
	dbus_message_iter_close_container(&iter_msg, &iter_array);
	mockbus_expect(replmsg);
	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_UINT32(1408)));
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_CANCEL_BROWSE,
					      MAFW_DBUS_UINT32(1408)));

	mockbus_expect(mafw_dbus_reply(c));
	mockbus_deliver(NULL);
	mockbus_deliver(NULL);

	g_timeout_add(100, quit_mainloop_on_tout, NULL);
	g_main_loop_run(Loop);

	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_CANCEL_BROWSE,
					      MAFW_DBUS_UINT32(31337)));

	mockbus_expect(mafw_dbus_reply(c));

	mockbus_deliver(NULL);
	fail_unless(source->cancel_browse_called == 2);
	mockbus_finish();

	/* Get metadata */
	mockbus_incoming(c =
                         mafw_dbus_method(
                                 MAFW_SOURCE_METHOD_GET_METADATA,
                                 MAFW_DBUS_STRING("testobject"),
                                 MAFW_DBUS_C_STRVZ("title", "artist")));

	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_METADATA(metadata)));

	mockbus_deliver(NULL);
	fail_unless(source->get_metadata_called == 1);

	/* Get metadatas */
	mockbus_incoming(c =
                         mafw_dbus_method(
                                 MAFW_SOURCE_METHOD_GET_METADATAS,
                                 MAFW_DBUS_C_STRVZ("testobject", "testobject2"),
                                 MAFW_DBUS_C_STRVZ("title", "artist")));

	mockbus_expect(mdatas_repl(c, objlist, metadata, FALSE));

	mockbus_deliver(NULL);
	fail_unless(source->get_metadata_called == 1);

	/* Set metadata */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_SET_METADATA,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_METADATA(metadata)));

	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_STRING("testobject"),
				       MAFW_DBUS_C_STRVZ("pertti", "pasanen")));

	mockbus_deliver(NULL);
	fail_unless(source->set_metadata_called == 1);

	/* Create object */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_CREATE_OBJECT,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_METADATA(metadata)));

	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_STRING("testobject")));

	mockbus_deliver(NULL);
	fail_unless(source->create_object_called == 1);

	/* Destroy object */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_DESTROY_OBJECT,
					      MAFW_DBUS_STRING("testobject")));

	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_STRING("testobject")));

	mockbus_deliver(NULL);
	fail_unless(source->destroy_object_called == 1);

	/* Signals */
	mockbus_expect(mafw_dbus_signal(MAFW_SOURCE_SIGNAL_METADATA_CHANGED,
					MAFW_DBUS_STRING("testobj")));
	g_signal_emit_by_name(source, "metadata-changed", "testobj");

	mockbus_expect(mafw_dbus_signal(MAFW_SOURCE_SIGNAL_CONTAINER_CHANGED,
				MAFW_DBUS_STRING("testobj")));
	g_signal_emit_by_name(source, "container-changed", "testobj");

        mockbus_expect(mafw_dbus_signal(MAFW_SOURCE_SIGNAL_UPDATING,
                                        MAFW_DBUS_INT32(25),
                                        MAFW_DBUS_INT32(4),
                                        MAFW_DBUS_INT32(6),
                                        MAFW_DBUS_INT32(12)));
        g_signal_emit_by_name(source, "updating", 25, 4, 6, 12);

	mockbus_finish();
	mafw_metadata_release(metadata);
}
Пример #7
0
END_TEST

#define END_CMD "zEND"
#define INSTREAM_CMD "zINSTREAM"
static void test_idsession_commands(int split, int instream)
{
    char buf[20480];
    size_t i, len=0, j=0;
    char *recvdata;
    char *p = buf;
    const char *replies[2 + sizeof(basic_tests)/sizeof(basic_tests[0])];

    /* test all commands that must be accepted inside an IDSESSION */
    for (i=0;i < sizeof(basic_tests)/sizeof(basic_tests[0]); i++) {
	const struct basic_test *test = &basic_tests[i];
	if (test->skiproot && isroot)
	    continue;
	if (test->ids == IDS_OK) {
	    fail_unless(p+strlen(test->command)+2 < buf+sizeof(buf), "Buffer too small");
	    *p++ = 'z';
	    strcpy(p, test->command);
	    p += strlen(test->command);
	    *p++ = '\0';
	    if (test->extra) {
		fail_unless(p+strlen(test->extra) < buf+sizeof(buf), "Buffer too small");
		strcpy(p, test->extra);
		p += strlen(test->extra);
	    }
	    replies[j++] = test->reply;
	}
	if (instream && test->ids == IDS_END) {
	    uint32_t chunk;
	    /* IDS_END - in middle of other commands, perfect for inserting
	     * INSTREAM */
	    fail_unless(p+sizeof(INSTREAM_CMD)+544< buf+sizeof(buf), "Buffer too small");
	    memcpy(p, INSTREAM_CMD, sizeof(INSTREAM_CMD));
	    p += sizeof(INSTREAM_CMD);
	    p += prepare_instream(p, 0, 552);
	    replies[j++] = EXPECT_INSTREAM0;
	    fail_unless(p+sizeof(INSTREAM_CMD)+16388< buf+sizeof(buf), "Buffer too small");
	    memcpy(p, INSTREAM_CMD, sizeof(INSTREAM_CMD));
	    p += sizeof(INSTREAM_CMD);
	    chunk=htonl(16384);
	    memcpy(p, &chunk, 4);
	    p+=4;
	    memset(p, 0x5a, 16384);
	    p += 16384;
	    *p++='\0';
	    *p++='\0';
	    *p++='\0';
	    *p++='\0';
	    replies[j++] = "stream: OK";
	}
    }
    fail_unless(p+sizeof(END_CMD) < buf+sizeof(buf), "Buffer too small");
    memcpy(p, END_CMD, sizeof(END_CMD));
    p += sizeof(END_CMD);

    if (split) {
	/* test corner-cases: 1-byte sends */
	for (i=0;i<(size_t)(p-buf);i++)
	    fail_unless((size_t)send(sockd, &buf[i], 1, 0) == 1, "send() failed: %u, %s\n", i, strerror(errno));
    } else {
	fail_unless(send(sockd, buf, p-buf, 0) == p-buf,"send() failed: %s\n", strerror(errno));
    }
    recvdata = recvfull(sockd, &len);
    p = recvdata;
    for (i=0;i < sizeof(basic_tests)/sizeof(basic_tests[0]); i++) {
	const struct basic_test *test = &basic_tests[i];
	if (test->skiproot && isroot)
	    continue;
	if (test->ids == IDS_OK) {
	    unsigned id;
	    char *q = strchr(p, ':');
	    fail_unless_fmt(!!q, "No ID in reply: %s\n", p);
	    *q = '\0';
	    fail_unless_fmt(sscanf(p, "%u", &id) == 1,"Wrong ID in reply: %s\n", p);
	    fail_unless(id > 0, "ID cannot be zero");
	    fail_unless_fmt(id <= j, "ID too big: %u, max: %u\n", id, j);
	    q += 2;
	    fail_unless_fmt(!strcmp(q, replies[id-1]),
			    "Wrong ID reply for ID %u: %s, expected %s\n",
			    id,
			    q, replies[id-1]);
	    p = q + strlen(q)+1;
	}
    }
    free(recvdata);
    conn_teardown();
}
Пример #8
0
END_TEST


START_TEST (test_L3_Compartment_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Compartment_t *c = 
    Compartment_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) c) == SBML_COMPARTMENT );
  fail_unless( SBase_getMetaId    ((SBase_t *) c) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) c) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) c) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) c) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) c) == 1 );

  fail_unless( Compartment_getNamespaces     (c) != NULL );
  fail_unless( XMLNamespaces_getLength(Compartment_getNamespaces(c)) == 2 );


  fail_unless( Compartment_getId     (c) == NULL );
  fail_unless( Compartment_getName   (c) == NULL );
  fail_unless( Compartment_getUnits  (c) == NULL );
  fail_unless( Compartment_getOutside(c) == NULL );

  fail_unless( util_isNaN(Compartment_getSpatialDimensionsAsDouble(c))   );
  fail_unless( util_isNaN(Compartment_getVolume(c)));
  fail_unless( Compartment_getConstant(c) == 1   );

  fail_unless( !Compartment_isSetId     (c) );
  fail_unless( !Compartment_isSetSpatialDimensions (c) );
  fail_unless( !Compartment_isSetName   (c) );
  fail_unless( !Compartment_isSetSize   (c) );
  fail_unless( !Compartment_isSetVolume (c) );
  fail_unless( !Compartment_isSetUnits  (c) );
  fail_unless( !Compartment_isSetOutside(c) );
  fail_unless( !Compartment_isSetConstant(c) );

  Compartment_free(c);
}
Пример #9
0
END_TEST


START_TEST (test_L3_Compartment_initDefaults)
{
  Compartment_t *c = Compartment_create(3, 1);
    
  Compartment_setId(c, "A");
  fail_unless( Compartment_isSetId     (c) );
  fail_unless( !Compartment_isSetName   (c) );
  fail_unless( !Compartment_isSetSize   (c) );
  fail_unless( !Compartment_isSetVolume (c) );
  fail_unless( !Compartment_isSetUnits  (c) );
  fail_unless( !Compartment_isSetConstant  (c) );
  fail_unless( !Compartment_isSetSpatialDimensions  (c) );

  Compartment_initDefaults(c);

  fail_unless( !strcmp(Compartment_getId     (c), "A"));
  fail_unless( Compartment_getName   (c) == NULL );
  fail_unless( !strcmp(Compartment_getUnits(c), "litre") );

  fail_unless( Compartment_getSpatialDimensions(c) == 3   );
  fail_unless( Compartment_getSize(c) == 1 );
  fail_unless( Compartment_getConstant         (c) == 1   );

  fail_unless( Compartment_isSetId     (c) );
  fail_unless( !Compartment_isSetName   (c) );
  fail_unless( !Compartment_isSetSize   (c) );
  fail_unless( !Compartment_isSetVolume (c) );
  fail_unless( Compartment_isSetUnits  (c) );
  fail_unless( Compartment_isSetConstant  (c) );
  fail_unless( Compartment_isSetSpatialDimensions  (c) );
  
  Compartment_free(c);
}
Пример #10
0
END_TEST


START_TEST(test_recovering_allocations)
  {
  Core c;
  bool completely_free = false;

  // unit test init gives us os indexes 0 and 8
  c.unit_test_init();
  fail_unless(c.reserve_processing_unit(0) == true);
  fail_unless(c.reserve_processing_unit(8) == true);
  fail_unless(c.reserve_processing_unit(1) == false);
  fail_unless(c.reserve_processing_unit(9) == false);
  fail_unless(c.get_open_processing_unit() == -1);
  fail_unless(c.free_pu_index(0, completely_free) == true);
  fail_unless(completely_free == false);
  fail_unless(c.is_free() == false);
  fail_unless(c.free_pu_index(8, completely_free) == true);
  fail_unless(completely_free == true);
  fail_unless(c.is_free() == true);
  }
Пример #11
0
END_TEST

START_TEST(test_rtcm3_read_write_header)
{
  u8 buff[22];

  gps_time_t t = {
    .wn = 22,
    .tow = 22.222
  };

  rtcm3_write_header(buff, 1234, 2269, t, 1, 22, 1, 6);

  u16 type, id;
  u8 sync, n_sat, div_free, smooth;
  double tow;

  rtcm3_read_header(buff, &type, &id, &tow, &sync, &n_sat, &div_free, &smooth);

  fail_unless(type == 1234, "type decode error, decoded %d, expected 1234", type);
  fail_unless(id == 2269, "id decode error, decoded %d, expected 2269", id);
  fail_unless(fabs(tow - t.tow) < 1e3, "TOW decode error, decoded %f, expected %f", tow, t.tow);
  fail_unless(sync == 1, "id decode error, decoded %d, expected 1", id);
  fail_unless(n_sat == 22, "n_sat decode error, decoded %d, expected 22", n_sat);
  fail_unless(div_free == 1, "div_free decode error, decoded %d, expected 1", div_free);
  fail_unless(smooth == 6, "smooth decode error, decoded %d, expected 6", smooth);
}
END_TEST


START_TEST(test_rtcm3_encode_decode)
{
  navigation_measurement_t nm_orig[22];
  navigation_measurement_t nm[22];

  seed_rng();

  for (u8 i=0; i<22; i++) {
    nm[i].raw_pseudorange = frand(19e6, 21e6);
    nm[i].carrier_phase = frand(-5e5, 5e5);
    nm[i].lock_time = frand(0, 1000);
    nm[i].snr = frand(0, 20);
  }

  memcpy(nm_orig, nm, sizeof(nm));

  gps_time_t t = {
    .wn = 1234,
    .tow = frand(0, 604800)
  };

  u8 buff[355];

  rtcm3_encode_1002(buff, 1234, t, 22, nm, 0);

  navigation_measurement_t nm_out[22];
  double tow_out;
  u8 sync, n_sat = 222;
  u16 id;

  s8 ret = rtcm3_decode_1002(buff, &id, &tow_out, &n_sat, 0, &sync);

  fail_unless(ret >= 0, "rtcm3_decode_1002 returned an error (%d)", ret);
  fail_unless(id == 1234, "decoded station id as %d, expected 1234", id);
  fail_unless(n_sat == 22, "decoded n_sat as %d, expected 22", n_sat);
  fail_unless(fabs(tow_out - t.tow) < 1e-3, "decoded TOW as %f, expected %f, error %f",
      tow_out, t.tow, tow_out - t.tow);

  ret = rtcm3_decode_1002(buff, &id, &tow_out, &n_sat, nm_out, &sync);

  for (u8 i=0; i<22; i++) {
    double pr_err = nm[i].raw_pseudorange - nm_out[i].raw_pseudorange;
    fail_unless(fabs(pr_err) < 0.02, "[%d] pseudorange error > 0.04m - "
        "decoded %f, expected %f, error %f", i, nm_out[i].raw_pseudorange, nm[i].raw_pseudorange, pr_err);

    double carr_err = nm[i].carrier_phase - nm_out[i].carrier_phase;
    fail_unless(fabs(carr_err) < 0.003, "carrier phase error (fractional part) > 0.003 cycles - "
        "[%d] decoded %f, expected %f, error %f", i, nm_out[i].carrier_phase, nm[i].carrier_phase, carr_err);

    double snr_err = nm[i].snr - nm_out[i].snr;
    /* Calculate error bound on SNR given logarithmic error bound on CNR. */
    double err_bound = nm[i].snr * (pow(10.0, 1.0 / 40.0) - 1);
    fail_unless(fabs(snr_err) < err_bound, "SNR error > 0.003 - "
        "[%d] decoded %f, expected %f, error %f, bound %f", i, nm_out[i].snr, nm[i].snr, snr_err, err_bound);

    fail_unless((nm_out[i].lock_time == 0) && (nm[i].lock_time == 0),
        "lock time should be zero when adjusting int. amb. - [%d] decoded %f",
        i, nm_out[i].lock_time, nm[i].lock_time);

    double cp_adj = nm[i].carrier_phase - nm_orig[i].carrier_phase;
    fail_unless(fmod(cp_adj, 1.0) == 0,
        "carrier phase adjusted by non integer amount %f -> %f (%f)",
        nm_orig[i].carrier_phase, nm[i].carrier_phase, cp_adj);
  }

  /* Re-encode after adjustment, now there should be no further adjustment and
   * the lock time should be correct. */

  for (u8 i=0; i<22; i++)
    nm[i].lock_time = frand(0, 1000);

  rtcm3_encode_1002(buff, 1234, t, 22, nm, 0);
  rtcm3_decode_1002(buff, &id, &tow_out, &n_sat, nm_out, &sync);

  for (u8 i=0; i<22; i++) {
    double cp_adj = nm_out[i].carrier_phase - nm[i].carrier_phase;
    fail_unless(cp_adj < 0.003, "carrier phase re-adjusted %f -> %f (%f)",
        nm[i].carrier_phase, nm_out[i].carrier_phase, cp_adj);

    fail_unless(nm_out[i].lock_time <= nm[i].lock_time,
        "lock time error, should always be less than input lock time - [%d] decoded %f, expected %f",
        i, nm_out[i].lock_time, nm[i].lock_time);
  }
}
END_TEST


Suite* rtcm3_suite(void)
{
  Suite *s = suite_create("RTCMv3");

  TCase *tc_core = tcase_create("Core");
  tcase_add_test(tc_core, test_rtcm3_check_frame);
  tcase_add_test(tc_core, test_rtcm3_write_frame);
  tcase_add_test(tc_core, test_rtcm3_read_write_header);
  tcase_add_test(tc_core, test_rtcm3_encode_decode);
  suite_add_tcase(s, tc_core);

  return s;
}
Пример #12
0
END_TEST


START_TEST(test_reserving_and_freeing)
  {
  Core c;
  bool completely_free;

  // unit test init gives us os indexes 0 and 8
  c.unit_test_init();
  c.mark_as_busy(0);
  c.mark_as_busy(8);

  fail_unless(c.get_open_processing_unit() == -1);
  
  // make sure freeing an index we don't have does nothing
  fail_unless(c.free_pu_index(1, completely_free) == false);
  fail_unless(completely_free == false);
  fail_unless(c.get_open_processing_unit() == -1);

  // make sure an actual free works
  fail_unless(c.free_pu_index(0, completely_free) == true);
  fail_unless(completely_free == false);
  fail_unless(c.get_open_processing_unit() == 0);
  fail_unless(c.free_pu_index(0, completely_free) == true);
  fail_unless(completely_free == false);
  fail_unless(c.free_pu_index(8, completely_free) == true);
  fail_unless(completely_free == true);
  int index = c.get_open_processing_unit();
  fail_unless(index != -1, "Open processing unit is %d, shouldn't be -1");
  index = c.get_open_processing_unit();
  fail_unless(index != -1, "Open processing unit is %d, shouldn't be -1");
  }
Пример #13
0
static void
run_shm_transmitter_test (gint flags)
{
  GError *error = NULL;
  FsTransmitter *trans;
  FsStreamTransmitter *st;
  GstBus *bus = NULL;
  GParameter params[1];
  GList *local_cands = NULL;
  GstStateChangeReturn ret;
  FsCandidate *cand;
  GList *remote_cands = NULL;
  int param_count = 0;

  done = FALSE;
  connected_count = 0;
  g_cond_init (&cond);
  g_mutex_init (&test_mutex);

  buffer_count[0] = 0;
  buffer_count[1] = 0;
  received_known[0] = 0;
  received_known[1] = 0;

  got_candidates[0] = FALSE;
  got_candidates[1] = FALSE;
  got_prepared[0] = FALSE;
  got_prepared[1] = FALSE;

  if (unlink ("/tmp/src1") < 0 && errno != ENOENT)
    fail ("Could not unlink /tmp/src1: %s", strerror (errno));
  if (unlink ("/tmp/src2") < 0 && errno != ENOENT)
    fail ("Could not unlink /tmp/src2: %s", strerror (errno));


  local_cands = g_list_append (local_cands, fs_candidate_new (NULL, 1,
          FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_UDP, "/tmp/src1", 0));
  local_cands = g_list_append (local_cands, fs_candidate_new (NULL, 2,
          FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_UDP, "/tmp/src2", 0));

  if (flags & FLAG_LOCAL_CANDIDATES)
  {
    memset (params, 0, sizeof (GParameter));

    params[0].name = "preferred-local-candidates";
    g_value_init (&params[0].value, FS_TYPE_CANDIDATE_LIST);
    g_value_take_boxed (&params[0].value, local_cands);

    param_count = 1;
  }


  associate_on_source = !(flags & FLAG_NO_SOURCE);

  if ((flags & FLAG_NOT_SENDING) && (flags & FLAG_RECVONLY_FILTER))
  {
    buffer_count[0] = 20;
    received_known[0] = 20;
  }

  trans = fs_transmitter_new ("shm", 2, 0, &error);

  if (error)
    ts_fail ("Error creating transmitter: (%s:%d) %s",
      g_quark_to_string (error->domain), error->code, error->message);
  ts_fail_if (trans == NULL, "No transmitter create, yet error is still NULL");
  g_clear_error (&error);

  if (flags & FLAG_RECVONLY_FILTER)
    ts_fail_unless (g_signal_connect (trans, "get-recvonly-filter",
            G_CALLBACK (get_recvonly_filter), NULL));


  pipeline = setup_pipeline (trans, G_CALLBACK (_handoff_handler));

  bus = gst_element_get_bus (pipeline);
  gst_bus_add_watch (bus, bus_error_callback, NULL);

  gst_bus_enable_sync_message_emission (bus);
  g_signal_connect (bus, "sync-message::error",
      G_CALLBACK (sync_error_handler), NULL);

  gst_object_unref (bus);

  st = fs_transmitter_new_stream_transmitter (trans, NULL,
      param_count, params, &error);

  if (param_count)
    g_value_unset (&params[0].value);

  if (error)
    ts_fail ("Error creating stream transmitter: (%s:%d) %s",
        g_quark_to_string (error->domain), error->code, error->message);
  ts_fail_if (st == NULL, "No stream transmitter created, yet error is NULL");
  g_clear_error (&error);

  g_object_set (st, "sending", !(flags & FLAG_NOT_SENDING), NULL);

  ts_fail_unless (g_signal_connect (st, "new-local-candidate",
      G_CALLBACK (_new_local_candidate), trans),
    "Could not connect new-local-candidate signal");
  ts_fail_unless (g_signal_connect (st, "local-candidates-prepared",
      G_CALLBACK (_candidate_prepared), NULL),
    "Could not connect local-candidates-prepared signal");
  ts_fail_unless (g_signal_connect (st, "error",
      G_CALLBACK (stream_transmitter_error), NULL),
    "Could not connect error signal");
  ts_fail_unless (g_signal_connect (st, "known-source-packet-received",
      G_CALLBACK (_known_source_packet_received), NULL),
    "Could not connect known-source-packet-received signal");
  ts_fail_unless (g_signal_connect (st, "state-changed",
      G_CALLBACK (_state_changed), NULL),
    "Could not connect state-changed signal");

  if (!fs_stream_transmitter_gather_local_candidates (st, &error))
  {
    if (error)
      ts_fail ("Could not start gathering local candidates (%s:%d) %s",
          g_quark_to_string (error->domain), error->code, error->message);
    else
      ts_fail ("Could not start gathering candidates"
          " (without a specified error)");
  }
  else
  {
    ts_fail_unless (error == NULL);
  }
  g_clear_error (&error);

  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
  ts_fail_if (ret == GST_STATE_CHANGE_FAILURE,
      "Could not set the pipeline to playing");

  if (!(flags & FLAG_LOCAL_CANDIDATES))
  {
    ret = fs_stream_transmitter_force_remote_candidates (st, local_cands,
        &error);
    fs_candidate_list_destroy (local_cands);
    if (error)
      ts_fail ("Error while adding candidate: (%s:%d) %s",
          g_quark_to_string (error->domain), error->code, error->message);
    ts_fail_unless (ret == TRUE, "No detailed error from add_remote_candidate");
  }
  else
  {
    ts_fail_unless (error == NULL);
  }
  g_clear_error (&error);

  cand = fs_candidate_new (NULL, 1,
          FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_UDP, NULL, 0);
  cand->username = g_strdup ("/tmp/src1");
  remote_cands = g_list_prepend (remote_cands, cand);
  cand = fs_candidate_new (NULL, 2,
          FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_UDP, NULL, 0);
  cand->username = g_strdup ("/tmp/src2");
  remote_cands = g_list_prepend (remote_cands, cand);
  ret = fs_stream_transmitter_force_remote_candidates (st, remote_cands, &error);
  fs_candidate_list_destroy (remote_cands);
  if (error)
    ts_fail ("Error while adding candidate: (%s:%d) %s",
      g_quark_to_string (error->domain), error->code, error->message);
  ts_fail_unless (ret == TRUE, "No detailed error from add_remote_candidate");
  g_clear_error (&error);

  g_mutex_lock (&test_mutex);
  while (connected_count < 2)
    g_cond_wait (&cond, &test_mutex);
  g_mutex_unlock (&test_mutex);

  setup_fakesrc (trans, pipeline, 1);
  setup_fakesrc (trans, pipeline, 2);

  g_mutex_lock (&test_mutex);
  while (!done)
    g_cond_wait (&cond, &test_mutex);
  g_mutex_unlock (&test_mutex);

  fail_unless (got_prepared[0] == TRUE);
  fail_unless (got_prepared[1] == TRUE);
  fail_unless (got_candidates[0] == TRUE);
  fail_unless (got_candidates[1] == TRUE);

  gst_element_set_state (pipeline, GST_STATE_NULL);

  if (st)
  {
    fs_stream_transmitter_stop (st);
    g_object_unref (st);
  }

  g_object_unref (trans);

  gst_object_unref (pipeline);

  g_cond_clear (&cond);
  g_mutex_clear (&test_mutex);
}
Пример #14
0
static void
test_videoframe_audiolevel_generic (void)
{
  GstElement *alevel;
  GstPad *asink, *vsink, *asrc, *vsrc, *aoutput_sink, *voutput_sink;
  GThread *athread, *vthread;
  GstBus *bus;
  guint i;

  got_eos = FALSE;
  audio_buffer_count = 0;
  video_buffer_count = 0;
  num_msgs = 0;

  g_queue_init (&v_timestamp_q);
  g_queue_init (&msg_timestamp_q);

  alevel = gst_element_factory_make ("videoframe-audiolevel", NULL);
  fail_unless (alevel != NULL);

  bus = gst_bus_new ();
  gst_element_set_bus (alevel, bus);
  gst_bus_set_sync_handler (bus, on_message, NULL, NULL);

  asink = gst_element_get_static_pad (alevel, "asink");
  fail_unless (asink != NULL);

  vsink = gst_element_get_static_pad (alevel, "vsink");
  fail_unless (vsink != NULL);

  asrc = gst_element_get_static_pad (alevel, "asrc");
  aoutput_sink = gst_pad_new ("sink", GST_PAD_SINK);
  fail_unless (aoutput_sink != NULL);
  fail_unless (gst_pad_link (asrc, aoutput_sink) == GST_PAD_LINK_OK);

  vsrc = gst_element_get_static_pad (alevel, "vsrc");
  voutput_sink = gst_pad_new ("sink", GST_PAD_SINK);
  fail_unless (voutput_sink != NULL);
  fail_unless (gst_pad_link (vsrc, voutput_sink) == GST_PAD_LINK_OK);

  gst_pad_set_chain_function (aoutput_sink, output_achain);
  gst_pad_set_event_function (aoutput_sink, output_aevent);

  gst_pad_set_chain_function (voutput_sink, output_vchain);
  gst_pad_set_event_function (voutput_sink, output_vevent);

  gst_pad_set_active (aoutput_sink, TRUE);
  gst_pad_set_active (voutput_sink, TRUE);
  fail_unless (gst_element_set_state (alevel,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);

  athread = g_thread_new ("athread", (GThreadFunc) push_abuffers, asink);
  vthread = g_thread_new ("vthread", (GThreadFunc) push_vbuffers, vsink);

  g_thread_join (vthread);
  g_thread_join (athread);

  fail_unless (got_eos);
  fail_unless_equals_int (audio_buffer_count, n_abuffers);
  fail_unless_equals_int (video_buffer_count, n_vbuffers);
  if (!long_video)
    fail_unless_equals_int (num_msgs, n_vbuffers);

  fail_unless_equals_int (g_queue_get_length (&v_timestamp_q), n_vbuffers);
  /* num_msgs is equal to n_vbuffers except in the case of long_video */
  fail_unless_equals_int (g_queue_get_length (&msg_timestamp_q), num_msgs);

  for (i = 0; i < g_queue_get_length (&msg_timestamp_q); i++) {
    GstClockTime *vt = g_queue_pop_head (&v_timestamp_q);
    GstClockTime *mt = g_queue_pop_head (&msg_timestamp_q);
    fail_unless (vt != NULL);
    fail_unless (mt != NULL);
    if (!video_gaps && !video_overlaps && !early_video)
      fail_unless_equals_uint64 (*vt, *mt);
    g_free (vt);
    g_free (mt);
  }

  /* teardown */
  gst_element_set_state (alevel, GST_STATE_NULL);
  gst_bus_set_flushing (bus, TRUE);
  gst_object_unref (bus);
  g_queue_foreach (&v_timestamp_q, (GFunc) g_free, NULL);
  g_queue_foreach (&msg_timestamp_q, (GFunc) g_free, NULL);
  g_queue_clear (&v_timestamp_q);
  g_queue_clear (&msg_timestamp_q);
  gst_pad_unlink (asrc, aoutput_sink);
  gst_object_unref (asrc);
  gst_pad_unlink (vsrc, voutput_sink);
  gst_object_unref (vsrc);
  gst_object_unref (asink);
  gst_object_unref (vsink);
  gst_pad_set_active (aoutput_sink, FALSE);
  gst_object_unref (aoutput_sink);
  gst_pad_set_active (voutput_sink, FALSE);
  gst_object_unref (voutput_sink);
  gst_object_unref (alevel);
}
Пример #15
0
END_TEST


START_TEST (test_L3_Event_createWithNS )
{
  XMLNamespaces_t *xmlns = XMLNamespaces_create();
  XMLNamespaces_add(xmlns, "http://www.sbml.org", "testsbml");
  SBMLNamespaces_t *sbmlns = SBMLNamespaces_create(3,1);
  SBMLNamespaces_addNamespaces(sbmlns,xmlns);

  Event_t *e = 
    Event_createWithNS (sbmlns);


  fail_unless( SBase_getTypeCode  ((SBase_t *) e) == SBML_EVENT );
  fail_unless( SBase_getMetaId    ((SBase_t *) e) == NULL );
  fail_unless( SBase_getNotes     ((SBase_t *) e) == NULL );
  fail_unless( SBase_getAnnotation((SBase_t *) e) == NULL );

  fail_unless( SBase_getLevel       ((SBase_t *) e) == 3 );
  fail_unless( SBase_getVersion     ((SBase_t *) e) == 1 );

  fail_unless( Event_getNamespaces     (e) != NULL );
  fail_unless( XMLNamespaces_getLength(Event_getNamespaces(e)) == 2 );


  fail_unless( Event_getId     (e) == NULL );
  fail_unless( Event_getName   (e) == NULL );
  fail_unless( Event_getUseValuesFromTriggerTime(e) == 1   );

  fail_unless( !Event_isSetId     (e) );
  fail_unless( !Event_isSetName   (e) );
  fail_unless( !Event_isSetUseValuesFromTriggerTime(e) );

  Event_free(e);
  XMLNamespaces_free(xmlns);
  SBMLNamespaces_free(sbmlns);
}
Пример #16
0
static void
test_video_sendonly (const gchar * video_enc_name, GstStaticCaps expected_caps,
    const gchar * pattern_sdp_sendonly_str,
    const gchar * pattern_sdp_recvonly_str, gboolean play_after_negotiation)
{
  HandOffData *hod;
  GMainLoop *loop = g_main_loop_new (NULL, TRUE);
  GstSDPMessage *pattern_sdp, *offer, *answer;
  GstElement *pipeline = gst_pipeline_new (NULL);
  GstElement *videotestsrc = gst_element_factory_make ("videotestsrc", NULL);
  GstElement *video_enc = gst_element_factory_make (video_enc_name, NULL);
  GstElement *rtpendpointsender =
      gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *rtpendpointreceiver =
      gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *outputfakesink = gst_element_factory_make ("fakesink", NULL);

  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  gst_bus_add_watch (bus, gst_bus_async_signal_func, NULL);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);
  g_object_unref (bus);

  fail_unless (gst_sdp_message_new (&pattern_sdp) == GST_SDP_OK);
  fail_unless (gst_sdp_message_parse_buffer ((const guint8 *)
          pattern_sdp_sendonly_str, -1, pattern_sdp) == GST_SDP_OK);
  g_object_set (rtpendpointsender, "pattern-sdp", pattern_sdp, NULL);
  fail_unless (gst_sdp_message_free (pattern_sdp) == GST_SDP_OK);

  fail_unless (gst_sdp_message_new (&pattern_sdp) == GST_SDP_OK);
  fail_unless (gst_sdp_message_parse_buffer ((const guint8 *)
          pattern_sdp_recvonly_str, -1, pattern_sdp) == GST_SDP_OK);
  g_object_set (rtpendpointreceiver, "pattern-sdp", pattern_sdp, NULL);
  fail_unless (gst_sdp_message_free (pattern_sdp) == GST_SDP_OK);

  hod = g_slice_new (HandOffData);
  hod->expected_caps = expected_caps;
  hod->loop = loop;

  g_object_set (G_OBJECT (outputfakesink), "signal-handoffs", TRUE, NULL);
  g_signal_connect (G_OBJECT (outputfakesink), "handoff",
      G_CALLBACK (fakesink_hand_off), hod);

  /* Add elements */
  gst_bin_add_many (GST_BIN (pipeline), videotestsrc, video_enc,
      rtpendpointsender, NULL);
  gst_element_link (videotestsrc, video_enc);
  gst_element_link_pads (video_enc, NULL, rtpendpointsender, "video_sink");

  gst_bin_add_many (GST_BIN (pipeline), rtpendpointreceiver, outputfakesink,
      NULL);
  kms_element_link_pads (rtpendpointreceiver, "video_src_%u", outputfakesink,
      "sink");

  if (!play_after_negotiation)
    gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* SDP negotiation */
  mark_point ();
  g_signal_emit_by_name (rtpendpointsender, "generate-offer", &offer);
  fail_unless (offer != NULL);

  mark_point ();
  g_signal_emit_by_name (rtpendpointreceiver, "process-offer", offer, &answer);
  fail_unless (answer != NULL);

  mark_point ();
  g_signal_emit_by_name (rtpendpointsender, "process-answer", answer);
  gst_sdp_message_free (offer);
  gst_sdp_message_free (answer);

  if (play_after_negotiation)
    gst_element_set_state (pipeline, GST_STATE_PLAYING);

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "test_sendonly_before_entering_loop");

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "test_sendonly_end");

  gst_element_set_state (pipeline, GST_STATE_NULL);
  g_object_unref (pipeline);
  g_slice_free (HandOffData, hod);
}
Пример #17
0
END_TEST

START_TEST(test_source_errors)
{
	ErrorSource *source;
	MafwRegistry *registry;
	DBusMessage *c;
	GError *error = NULL;
	const gchar *domain_str;
	GHashTable *metadata;
	GHashTable *metadata_empty;

	registry = mafw_registry_get_instance();
	mockbus_reset();
	wrapper_init();

	source = ERROR_SOURCE(error_source_new("mocksource", "mocksource",
                                               Loop));

	mock_appearing_extension(FAKE_SOURCE_SERVICE, FALSE);
	mafw_registry_add_extension(MAFW_REGISTRY(registry),
                                    MAFW_EXTENSION(source));

	g_set_error(&error, MAFW_EXTENSION_ERROR, MAFW_EXTENSION_ERROR_FAILED,
		    "Error source fails in everything it does.");
	domain_str = g_quark_to_string(error->domain);
	metadata = mockbus_mkmeta("title", "Easy", NULL);
	metadata_empty = mockbus_mkmeta(NULL);

	/* Browse */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_BROWSE,
					  MAFW_DBUS_STRING("testobject"),
					  MAFW_DBUS_BOOLEAN(FALSE),
					  MAFW_DBUS_STRING("!(rating=sucks)"),
					  MAFW_DBUS_STRING("-year"),
					  MAFW_DBUS_C_STRVZ("title", "artist"),
					  MAFW_DBUS_UINT32(0),
					  MAFW_DBUS_UINT32(11)));
	mockbus_expect(mafw_dbus_gerror(c, error));

	mockbus_deliver(NULL);
	fail_unless(source->browse_called == 1);

	/* Cancel browse */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_CANCEL_BROWSE,
					      MAFW_DBUS_UINT32(31337)));

	mockbus_expect(mafw_dbus_gerror(c, error));

	mockbus_deliver(NULL);
	fail_unless(source->cancel_browse_called == 1);

	/* Get metadata */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_GET_METADATA,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_C_STRVZ("title", "artist")));

	mockbus_expect(mafw_dbus_gerror(c, error));
	mockbus_deliver(NULL);
	fail_unless(source->get_metadata_called == 1);

	/* Set metadata */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_SET_METADATA,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_METADATA(metadata)));
	mockbus_expect(mafw_dbus_reply(c, MAFW_DBUS_STRING("testobject"),
				       MAFW_DBUS_C_STRVZ("pertti", "pasanen"),
				       MAFW_DBUS_STRING(domain_str),
				       MAFW_DBUS_INT32(error->code),
				       MAFW_DBUS_STRING(error->message)));
	mockbus_deliver(NULL);
	fail_unless(source->get_metadata_called == 1);

	/* Create object */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_CREATE_OBJECT,
				      MAFW_DBUS_STRING("testobject"),
				      MAFW_DBUS_METADATA(metadata)));
	mockbus_expect(mafw_dbus_gerror(c, error));

	mockbus_deliver(NULL);
	fail_unless(source->create_object_called == 1);

	/* Destroy object */
	mockbus_incoming(c = mafw_dbus_method(MAFW_SOURCE_METHOD_DESTROY_OBJECT,
					      MAFW_DBUS_STRING("testobject")));

	mockbus_expect(mafw_dbus_gerror(c, error));

	mockbus_deliver(NULL);
	fail_unless(source->destroy_object_called == 1);

	mockbus_finish();
	g_error_free(error);
	mafw_metadata_release(metadata);
	mafw_metadata_release(metadata_empty);
}
Пример #18
0
END_TEST

START_TEST(test_get_received_node_entry)
  {
  fail_unless(get_received_node_entry("pickle") != NULL);
  }
Пример #19
0
END_TEST

#define TIMEOUT_REPLY "TIMED OUT WAITING FOR COMMAND\n"

START_TEST (test_connections)
{
    int rc;
    int i;
    struct rlimit rlim;
    int *sock;
    int nf, maxfd=0;
    fail_unless_fmt(getrlimit(RLIMIT_NOFILE, &rlim) != -1,
		    "Failed to get RLIMIT_NOFILE: %s\n", strerror(errno));
    nf = rlim.rlim_cur - 5;
    sock = malloc(sizeof(int)*nf);

    fail_unless(!!sock, "malloc failed\n");

    for (i=0;i<nf;i++) {
	/* just open connections, and let them time out */
	conn_setup_mayfail(1);
	if (sockd == -1) {
	    nf = i;
	    break;
	}
	sock[i] = sockd;
	if (sockd > maxfd)
	    maxfd = sockd;
    }
    rc = fork();
    fail_unless(rc != -1, "fork() failed: %s\n", strerror(errno));
    if (rc == 0) {
	char dummy;
	int ret;
	fd_set rfds;
	FD_ZERO(&rfds);
	for (i=0;i<nf;i++) {
	    FD_SET(sock[i], &rfds);
	}
	while (1) {
	    ret = select(maxfd+1, &rfds, NULL, NULL, NULL);
	    if (ret < 0)
		break;
	    for (i=0;i<nf;i++) {
		if (FD_ISSET(sock[i], &rfds)) {
		    if (recv(sock[i], &dummy, 1, 0) == 0) {
			close(sock[i]);
			FD_CLR(sock[i], &rfds);
		    }
		}
	    }
	}
	free(sock);
	exit(0);
    } else {
	for (i=0;i<nf;i++) {
	    close(sock[i]);
	}
	free(sock);
	/* now see if clamd is able to do anything else */
	for (i=0;i<10;i++) {
	    conn_setup();
	    test_command("RELOAD", sizeof("RELOAD")-1, NULL, "RELOADING\n", sizeof("RELOADING\n")-1);
	    conn_teardown();
	}
    }
}
Пример #20
0
GST_END_TEST
GST_START_TEST (negotiation_offerer)
{
  GArray *audio_codecs_array, *video_codecs_array;
  gchar *audio_codecs[] = { "OPUS/48000/1", "AMR/8000/1", NULL };
  gchar *video_codecs[] = { "H263-1998/90000", "VP8/90000", NULL };
  gchar *offerer_sess_id, *answerer_sess_id;
  GstElement *offerer = gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *answerer = gst_element_factory_make ("rtpendpoint", NULL);
  GstSDPMessage *offer = NULL, *answer = NULL;
  GstSDPMessage *offerer_local_sdp = NULL, *offerer_remote_sdp = NULL;
  gchar *offerer_local_sdp_str, *offerer_remote_sdp_str;
  GstSDPMessage *answerer_local_sdp = NULL, *answerer_remote_sdp = NULL;
  gchar *answerer_local_sdp_str, *answerer_remote_sdp_str;
  gchar *sdp_str = NULL;
  const GstSDPConnection *connection;
  gboolean answer_ok;

  audio_codecs_array = create_codecs_array (audio_codecs);
  video_codecs_array = create_codecs_array (video_codecs);
  g_object_set (offerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (audio_codecs_array), "num-video-medias", 1, "video-codecs",
      g_array_ref (video_codecs_array), NULL);
  g_object_set (answerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (audio_codecs_array), "num-video-medias", 1, "video-codecs",
      g_array_ref (video_codecs_array), NULL);
  g_array_unref (audio_codecs_array);
  g_array_unref (video_codecs_array);

  /* Session creation */
  g_signal_emit_by_name (offerer, "create-session", &offerer_sess_id);
  GST_DEBUG_OBJECT (offerer, "Created session with id '%s'", offerer_sess_id);
  g_signal_emit_by_name (answerer, "create-session", &answerer_sess_id);
  GST_DEBUG_OBJECT (answerer, "Created session with id '%s'", answerer_sess_id);

  /* SDP negotiation */
  g_signal_emit_by_name (offerer, "generate-offer", offerer_sess_id, &offer);
  fail_unless (offer != NULL);
  GST_DEBUG ("Offer:\n%s", (sdp_str = gst_sdp_message_as_text (offer)));
  g_free (sdp_str);
  sdp_str = NULL;
  connection = gst_sdp_message_get_connection (offer);

  fail_unless (g_strcmp0 (connection->address, "0.0.0.0"));
  fail_unless (g_strcmp0 (connection->address, "::"));

  g_signal_emit_by_name (answerer, "process-offer", answerer_sess_id, offer,
      &answer);
  fail_unless (answer != NULL);
  GST_DEBUG ("Answer:\n%s", (sdp_str = gst_sdp_message_as_text (answer)));
  g_free (sdp_str);
  sdp_str = NULL;

  g_signal_emit_by_name (offerer, "process-answer", offerer_sess_id, answer,
      &answer_ok);
  fail_unless (answer_ok);

  gst_sdp_message_free (offer);
  gst_sdp_message_free (answer);

  g_signal_emit_by_name (offerer, "get-local-sdp", offerer_sess_id,
      &offerer_local_sdp);
  fail_unless (offerer_local_sdp != NULL);
  g_signal_emit_by_name (offerer, "get-remote-sdp", offerer_sess_id,
      &offerer_remote_sdp);
  fail_unless (offerer_remote_sdp != NULL);

  g_signal_emit_by_name (answerer, "get-local-sdp", answerer_sess_id,
      &answerer_local_sdp);
  fail_unless (answerer_local_sdp != NULL);
  g_signal_emit_by_name (answerer, "get-remote-sdp", answerer_sess_id,
      &answerer_remote_sdp);
  fail_unless (answerer_remote_sdp != NULL);

  offerer_local_sdp_str = gst_sdp_message_as_text (offerer_local_sdp);
  offerer_remote_sdp_str = gst_sdp_message_as_text (offerer_remote_sdp);

  answerer_local_sdp_str = gst_sdp_message_as_text (answerer_local_sdp);
  answerer_remote_sdp_str = gst_sdp_message_as_text (answerer_remote_sdp);

  GST_DEBUG ("Offerer local SDP\n%s", offerer_local_sdp_str);
  GST_DEBUG ("Offerer remote SDPr\n%s", offerer_remote_sdp_str);
  GST_DEBUG ("Answerer local SDP\n%s", answerer_local_sdp_str);
  GST_DEBUG ("Answerer remote SDP\n%s", answerer_remote_sdp_str);

  fail_unless (g_strcmp0 (offerer_local_sdp_str, answerer_remote_sdp_str) == 0);
  fail_unless (g_strcmp0 (offerer_remote_sdp_str, answerer_local_sdp_str) == 0);

  g_free (offerer_local_sdp_str);
  g_free (offerer_remote_sdp_str);
  g_free (answerer_local_sdp_str);
  g_free (answerer_remote_sdp_str);

  gst_sdp_message_free (offerer_local_sdp);
  gst_sdp_message_free (offerer_remote_sdp);
  gst_sdp_message_free (answerer_local_sdp);
  gst_sdp_message_free (answerer_remote_sdp);

  g_object_unref (offerer);
  g_object_unref (answerer);
  g_free (offerer_sess_id);
  g_free (answerer_sess_id);
}
END_TEST 

START_TEST (test_RenderCubicBezier_setBasePoint2 )
{
    fail_unless(P->basePoint2_X().getAbsoluteValue() < 1e-9);
    fail_unless(P->basePoint2_X().getRelativeValue() < 1e-9);
    fail_unless(P->basePoint2_Y().getAbsoluteValue() < 1e-9);
    fail_unless(P->basePoint2_Y().getRelativeValue() < 1e-9);
    fail_unless(P->basePoint2_Z().getAbsoluteValue() < 1e-9);
    fail_unless(P->basePoint2_Z().getRelativeValue() < 1e-9);
    P->setBasePoint2(RelAbsVector(20.0,30.0),RelAbsVector(40.0,50.0),RelAbsVector(60.0,70.0));
    fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 20.0) / 20.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 30.0) / 30.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 40.0) / 40.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 50.0) / 50.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_Z().getAbsoluteValue() - 60.0) / 60.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_Z().getRelativeValue() - 70.0) / 70.0) < 1e-9);
    P->setBasePoint2(RelAbsVector(2.0,3.0),RelAbsVector(4.0,5.0));
    fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 2.0) / 2.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 3.0) / 3.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 4.0) / 4.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 5.0) / 5.0) < 1e-9);
    fail_unless(P->basePoint2_Z().getAbsoluteValue() < 1e-9);
    fail_unless(P->basePoint2_Z().getRelativeValue() < 1e-9);
    P->setBasePoint2_X(RelAbsVector(3.2,2.3));
    fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 3.2) / 3.2) < 1e-9);
    fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 2.3) / 2.3) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 4.0) / 4.0) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 5.0) / 5.0) < 1e-9);
    fail_unless(P->basePoint2_Z().getAbsoluteValue() < 1e-9);
    fail_unless(P->basePoint2_Z().getRelativeValue() < 1e-9);
    P->setBasePoint2_Y(RelAbsVector(1.1,2.2));
    fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 3.2) / 3.2) < 1e-9);
    fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 2.3) / 2.3) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 1.1) / 1.1) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 2.2) / 2.2) < 1e-9);
    fail_unless(P->basePoint2_Z().getAbsoluteValue() < 1e-9);
    fail_unless(P->basePoint2_Z().getRelativeValue() < 1e-9);
    P->setBasePoint2_Z(RelAbsVector(5.5,6.6));
    fail_unless(fabs((P->basePoint2_X().getAbsoluteValue() - 3.2) / 3.2) < 1e-9);
    fail_unless(fabs((P->basePoint2_X().getRelativeValue() - 2.3) / 2.3) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getAbsoluteValue() - 1.1) / 1.1) < 1e-9);
    fail_unless(fabs((P->basePoint2_Y().getRelativeValue() - 2.2) / 2.2) < 1e-9);
    fail_unless(fabs((P->basePoint2_Z().getAbsoluteValue() - 5.5) / 5.5) < 1e-9);
    fail_unless(fabs((P->basePoint2_Z().getRelativeValue() - 6.6) / 6.6) < 1e-9);
}
Пример #22
0
END_TEST

START_TEST(test_hndshk_parse)
{
     char line1[] = "GET /chat HTTP/1.1\r\nHost:localhost\r\nUpgrade:websocket\r\nOrigin:http://localhost\r\n";
     char line2[] = "Host:localhost";

     struct websck_hndshk acthnd; /* actual handshake */
     struct websck_hndshk exphnd; /* expected handshake */

     int same;
     const char *val;

     hndshk_init(&acthnd);
     hndshk_init(&exphnd);

     hndshk_set_startline("GET /chat HTTP/1.1", strlen("GET /chat HTTP/1.1"), &exphnd);

     strcpy(exphnd.fields[0].name, "Host");
     strcpy(exphnd.fields[0].value, "localhost");

     strcpy(exphnd.fields[1].name, "Upgrade");
     strcpy(exphnd.fields[1].value, "websocket");

     strcpy(exphnd.fields[2].name, "Origin");
     strcpy(exphnd.fields[2].value, "http://localhost");

     strcpy(exphnd.fields[3].name, "Sec-WebSocket-Key");
     strcpy(exphnd.fields[3].value, "dGhlIHNhbXBsZSBub25jZQ==");

     exphnd.numfld = 4;

     /* parse valid hand handshake fields */
     hndshk_parse(line1, strlen(line1), &acthnd);

     same = strcmp(exphnd.startline, acthnd.startline) == 0;
     val = acthnd.startline;
     fail_unless(same, "Failed to parse the start line %s", val);

     same = strcmp(exphnd.fields[0].name, acthnd.fields[0].name) == 0;
     val = acthnd.fields[0].name;
     fail_unless(same, "Failed to parse the Host %s", val);
 
     same = strcmp(exphnd.fields[0].value, acthnd.fields[0].value) == 0;
     val = acthnd.fields[0].value;
     fail_unless(same, "Failed to parse the Host value %s", val);

     same = strcmp(exphnd.fields[1].name, acthnd.fields[1].name) == 0;
     val = acthnd.fields[1].name;
     fail_unless(same, "Failed to parse the Upgrade %s", val);

     same = strcmp(exphnd.fields[1].value, acthnd.fields[1].value) == 0;
     val = acthnd.fields[1].value;
     fail_unless(same, "Failed to parse the Upgrade value %s", val);

     same = strcmp(exphnd.fields[2].name, acthnd.fields[2].name) == 0;
     val = acthnd.fields[2].name;
     fail_unless(same, "Failed to parse the Origin %s", val);

     same = strcmp(exphnd.fields[2].value, acthnd.fields[2].value) == 0;
     val = acthnd.fields[2].value;
     fail_unless(same, "Failed to parse the Origin value %s", val);

     /* parse invalid handshake fields */
     hndshk_init(&acthnd);
     hndshk_parse(line2, strlen(line2), &acthnd);

     same = strcmp(exphnd.fields[0].name, acthnd.fields[0].name) == 0;
     val = acthnd.fields[0].name;
     fail_unless(!same, "Succeed to parse the Host %s", val);
}
END_TEST

START_TEST ( test_RenderCubicBezier_read )
{
  std::string s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                  "<element xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"RenderCubicBezier\" x=\"10\" y=\"20\"\n"
                  " basePoint1_x=\"15%\" basePoint1_y=\"25%\"\n"
                  " basePoint2_x=\"35%\" basePoint2_y=\"55\" />\n"
                ;

  XMLInputStream* pStream= new XMLInputStream(s.c_str(),false);
  XMLNode* pNode = new XMLNode(*pStream);

  RenderCubicBezier p(*pNode);
  fail_unless(fabs((p.x().getAbsoluteValue() - 10.0) / 10.0) < 1e-9 );
  fail_unless(p.x().getRelativeValue() < 1e-9);
  fail_unless(fabs((p.y().getAbsoluteValue() - 20.0) / 20.0) < 1e-9 );
  fail_unless(p.y().getRelativeValue() < 1e-9);
  fail_unless(p.z().getAbsoluteValue() < 1e-9);
  fail_unless(p.z().getRelativeValue() < 1e-9);
  // base point 1
  fail_unless(p.basePoint1_X().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.basePoint1_X().getRelativeValue() - 15.0) / 15.0) < 1e-9 );
  fail_unless(p.basePoint1_Y().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.basePoint1_Y().getRelativeValue() - 25.0) / 25.0) < 1e-9 );
  fail_unless(p.basePoint1_Z().getAbsoluteValue() < 1e-9);
  fail_unless(p.basePoint1_Z().getRelativeValue() < 1e-9);
  // base point 2
  fail_unless(p.basePoint2_X().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.basePoint2_X().getRelativeValue() - 35.0) / 35.0) < 1e-9 );
  fail_unless(fabs((p.basePoint2_Y().getAbsoluteValue() - 55.0) / 55.0) < 1e-9 );
  fail_unless(p.basePoint2_Y().getRelativeValue() < 1e-9);
  fail_unless(p.basePoint2_Z().getAbsoluteValue() < 1e-9);
  fail_unless(p.basePoint2_Z().getRelativeValue() < 1e-9);

  delete pNode;
  delete pStream;

  s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
      "<element xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"RenderPoint\" x=\"30%\" y=\"50%\" z=\"3\"\n"
      " basePoint1_x=\"15%\" basePoint1_y=\"25%\" basePoint1_z=\"23%\"\n"
      " basePoint2_x=\"35%\" basePoint2_y=\"55\" basePoint2_z=\"13\"/>\n"
    ;

  pStream= new XMLInputStream(s.c_str(),false);
  pNode = new XMLNode(*pStream);

  p = RenderCubicBezier(*pNode);
  fail_unless(fabs((p.x().getRelativeValue() - 30.0) / 30.0) < 1e-9 );
  fail_unless(p.x().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.y().getRelativeValue() - 50.0) / 50.0) < 1e-9 );
  fail_unless(p.y().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.z().getAbsoluteValue() - 3.0) / 3.0) < 1e-9 );
  fail_unless(p.z().getRelativeValue() < 1e-9);
  // base point 1
  fail_unless(p.basePoint1_X().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.basePoint1_X().getRelativeValue() - 15.0) / 15.0) < 1e-9 );
  fail_unless(p.basePoint1_Y().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.basePoint1_Y().getRelativeValue() - 25.0) / 25.0) < 1e-9 );
  fail_unless(p.basePoint1_Z().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.basePoint1_Z().getRelativeValue() - 23.0) / 23.0) < 1e-9);
  // base point 2
  fail_unless(p.basePoint2_X().getAbsoluteValue() < 1e-9);
  fail_unless(fabs((p.basePoint2_X().getRelativeValue() - 35.0) / 35.0) < 1e-9 );
  fail_unless(fabs((p.basePoint2_Y().getAbsoluteValue() - 55.0) / 55.0) < 1e-9 );
  fail_unless(p.basePoint2_Y().getRelativeValue() < 1e-9);
  fail_unless(fabs((p.basePoint2_Z().getAbsoluteValue() - 13.0) / 13.0) < 1e-9);
  fail_unless(p.basePoint2_Z().getRelativeValue() < 1e-9);

  delete pNode;
  delete pStream;
}
Пример #24
0
END_TEST

START_TEST(cas_attribute_authz_test) {
  int should_fail, should_succeed1, should_succeed2,
      should_decline1, should_decline2;
  cas_saml_attr *attrs = NULL;
  cas_attr_builder *builder;
  require_line require_line_array[2];
  cas_cfg *c;
  int i;
  require_line *r;

  /* Manually create some SAML attributes.  These attributes represent
   * a CAS attribute payload returned by CAS.  This test will apply an
   * authorization policy to these attributes to test its behavior.
   */
  struct test_data {
      const char *const k;
      const char *const v;
  } test_data_list[] = {
      {"key1", "val1"},
      {"key1", "val2"},
      {"key2", "val3"},
      {"should", "succeed"},
      {0, 0} /* NULL terminator */
  };

  // Build a CAS attribute structure.
  builder = cas_attr_builder_new(pool, &attrs);
  i = 0;
  while (1) {
      struct test_data d = test_data_list[i];
      if (d.v == NULL) break;

      cas_attr_builder_add(builder, d.k, d.v);
      i++;
  }

  c = ap_get_module_config(request->server->module_config,
                           &auth_cas_module);

  /* Create two 'Require' config structures representing the
   * configured authorization policy.  Although we create two, we'll
   * apply different combinations of them in the tests which
   * follow. */
  r = &(require_line_array[0]);
  r->method_mask = AP_METHOD_BIT;
  r->requirement = apr_pstrdup(pool, "cas-attribute hopefully:fail");

  r = &(require_line_array[1]);
  r->method_mask = AP_METHOD_BIT;
  r->requirement = apr_pstrdup(pool, "cas-attribute should:succeed");

  /* When mod_auth_cas is authoritative, an attribute payload which
   * fails to pass the policy check should result in
   * HTTP_UNAUTHORIZED. */
  c->CASAuthoritative = 1;
  should_fail = cas_authorize_worker(request, attrs, &(require_line_array[0]), 1, c);

  /* When mod_auth_cas is authoritative, an attribute payload which
   * does pass the policy check should succeed. */
  c->CASAuthoritative = 1;
  should_succeed1 = cas_authorize_worker(request, attrs, &(require_line_array[1]), 1, c);

  /* When mod_auth_cas is *not* authoritative, an attribute payload
   * which does pass the policy check should succeed. */
  c->CASAuthoritative = 0;
  should_succeed2 = cas_authorize_worker(request, attrs, &(require_line_array[0]), 2, c);

  /* Regardless of whether mod_auth_cas is authoritative, the empty
   * list of Require directives means mod_auth_cas has no policy to
   * check and should DECLINE. */
  c->CASAuthoritative = 1;
  should_decline1 = cas_authorize_worker(request, attrs, NULL, 0, c);
  c->CASAuthoritative = 0;
  should_decline2 = cas_authorize_worker(request, attrs, NULL, 0, c);

  fail_unless((should_fail == HTTP_UNAUTHORIZED) &&
              (should_succeed1 == OK) &&
              (should_succeed2 == OK) &&
              (should_decline1 == DECLINED) &&
              (should_decline2 == DECLINED));
}
Пример #25
0
END_TEST

START_TEST(next_job_test)
  {
  all_jobs alljobs;
  struct job *result;
  result = next_job(NULL,NULL);

  fail_unless(result == NULL, "null input parameters fail");

  result = next_job(&alljobs,NULL);
  fail_unless(result == NULL, "NULL input iterator fail");

  struct job *test_job1 = job_alloc();
  strcpy(test_job1->ji_qs.ji_jobid, "test_job1");
  int rc = insert_job(&alljobs,test_job1);
  fail_unless(rc == PBSE_NONE, "job insert fail1");

  struct job *test_job2 = job_alloc();
  strcpy(test_job2->ji_qs.ji_jobid, "test_job2");
  rc = insert_job(&alljobs,test_job2);
  fail_unless(rc == PBSE_NONE, "job insert fail2");

  struct job *test_job3 = job_alloc();
  strcpy(test_job3->ji_qs.ji_jobid, "test_job3");
  rc = insert_job(&alljobs,test_job3);
  fail_unless(rc == PBSE_NONE, "job insert fai3");

  struct job *test_job4 = job_alloc();
  strcpy(test_job4->ji_qs.ji_jobid, "test_job4");
  rc = insert_job(&alljobs,test_job4);
  fail_unless(rc == PBSE_NONE, "job insert fail4");

  struct job *test_job5 = job_alloc();
  strcpy(test_job5->ji_qs.ji_jobid, "test_job5");
  rc = insert_job(&alljobs,test_job5);
  fail_unless(rc == PBSE_NONE, "job insert fail5");

  /* first transverse to see if we get all 5 jobs */
  all_jobs_iterator *iter;
  alljobs.lock();
  iter = alljobs.get_iterator();
  alljobs.unlock();

  job *pjob = next_job(&alljobs,iter);
  int jobcount = 0;

  while(pjob != NULL)
    {
    jobcount++;
    pjob = next_job(&alljobs,iter);
    }

  fail_unless(jobcount == 5, "Expected job counts to be 5, but it was %d",
    jobcount);

  all_jobs_iterator *iter2;
  alljobs.lock();
  iter2 = alljobs.get_iterator();
  alljobs.unlock();

  /* simulate another thread had added more jobs to the alljobs */
  struct job *test_job6 = job_alloc();
  strcpy(test_job6->ji_qs.ji_jobid, "test_job6");
  rc = insert_job(&alljobs,test_job6);
  fail_unless(rc == PBSE_NONE, "job insert fail6");

  pjob = next_job(&alljobs,iter2);
  jobcount = 0;

  while(pjob != NULL)
    {
    jobcount++;
    fail_unless(pjob->ji_qs.ji_jobid[0] != (char)254, 
      "get_next returned a deleted job");
    pjob = next_job(&alljobs,iter2);
    }

  fail_unless(jobcount == 6, "Expected job counts to be 6, but it was %d",
    jobcount);
  }
Пример #26
0
static void
check_tags_empty (const GstTagList * list)
{
  GST_DEBUG ("taglist: %" GST_PTR_FORMAT, list);
  fail_unless ((list == NULL) || (gst_tag_list_is_empty (list)));
}
Пример #27
0
static void
check_pad_template (GstPadTemplate * tmpl)
{
  const GValue *list_val, *fmt_val;
  GstStructure *s;
  gboolean *formats_supported;
  GstCaps *caps;
  guint i, num_formats;

  num_formats = get_num_formats ();
  formats_supported = g_new0 (gboolean, num_formats);

  caps = gst_pad_template_get_caps (tmpl);

  /* If this fails, we need to update this unit test */
  fail_unless_equals_int (gst_caps_get_size (caps), 2);
  /* Remove the ANY caps features structure */
  caps = gst_caps_truncate (caps);
  s = gst_caps_get_structure (caps, 0);

  fail_unless (gst_structure_has_name (s, "video/x-raw"));

  list_val = gst_structure_get_value (s, "format");
  fail_unless (list_val != NULL);
  /* If this fails, we need to update this unit test */
  fail_unless (GST_VALUE_HOLDS_LIST (list_val));

  for (i = 0; i < gst_value_list_get_size (list_val); ++i) {
    GstVideoFormat fmt;
    const gchar *fmt_str;

    fmt_val = gst_value_list_get_value (list_val, i);
    fail_unless (G_VALUE_HOLDS_STRING (fmt_val));
    fmt_str = g_value_get_string (fmt_val);
    GST_LOG ("format string: '%s'", fmt_str);
    fmt = gst_video_format_from_string (fmt_str);
    if (fmt == GST_VIDEO_FORMAT_UNKNOWN)
      g_error ("Unknown raw format '%s' in pad template caps", fmt_str);
    formats_supported[(guint) fmt] = TRUE;
  }

  gst_caps_unref (caps);

  for (i = 2; i < num_formats; ++i) {
    if (!formats_supported[i]) {
      const gchar *fmt_str = gst_video_format_to_string ((GstVideoFormat) i);

      switch (i) {
        case GST_VIDEO_FORMAT_v210:
        case GST_VIDEO_FORMAT_v216:
        case GST_VIDEO_FORMAT_NV12:
        case GST_VIDEO_FORMAT_NV16:
        case GST_VIDEO_FORMAT_NV21:
        case GST_VIDEO_FORMAT_NV24:
        case GST_VIDEO_FORMAT_UYVP:
        case GST_VIDEO_FORMAT_A420:
        case GST_VIDEO_FORMAT_YUV9:
        case GST_VIDEO_FORMAT_YVU9:
        case GST_VIDEO_FORMAT_IYU1:
        case GST_VIDEO_FORMAT_r210:{
          static gboolean shown_fixme[100] = { FALSE, };

          if (!shown_fixme[i]) {
            GST_FIXME ("FIXME: add %s support to videoscale", fmt_str);
            shown_fixme[i] = TRUE;
          }
          break;
        }
        case GST_VIDEO_FORMAT_BGR16:
        case GST_VIDEO_FORMAT_BGR15:
        case GST_VIDEO_FORMAT_RGB8P:
        case GST_VIDEO_FORMAT_I420_10BE:
        case GST_VIDEO_FORMAT_I420_10LE:
        case GST_VIDEO_FORMAT_I422_10BE:
        case GST_VIDEO_FORMAT_I422_10LE:
        case GST_VIDEO_FORMAT_Y444_10BE:
        case GST_VIDEO_FORMAT_Y444_10LE:
        case GST_VIDEO_FORMAT_GBR:
        case GST_VIDEO_FORMAT_GBR_10BE:
        case GST_VIDEO_FORMAT_GBR_10LE:
        case GST_VIDEO_FORMAT_NV12_64Z32:
          GST_LOG ("Ignoring lack of support for format %s", fmt_str);
          break;
        default:
          g_error ("videoscale doesn't support format '%s'", fmt_str);
          break;
      }
    }
  }

  g_free (formats_supported);
}
Пример #28
0
END_TEST


START_TEST (test_L3_Event_useValuesFromTriggerTime)
{
  fail_unless(Event_isSetUseValuesFromTriggerTime(E) == 0);

  Event_setUseValuesFromTriggerTime(E, 1);

  fail_unless(Event_getUseValuesFromTriggerTime(E) == 1);
  fail_unless(Event_isSetUseValuesFromTriggerTime(E) == 1);

  int ret = Event_unsetUseValuesFromTriggerTime(E);

  fail_unless(ret == LIBSBML_OPERATION_SUCCESS);
  fail_unless(Event_getUseValuesFromTriggerTime(E) == 1);
  fail_unless(Event_isSetUseValuesFromTriggerTime(E) == 0);

  Event_setUseValuesFromTriggerTime(E, 0);

  fail_unless(Event_getUseValuesFromTriggerTime(E) == 0);
  fail_unless(Event_isSetUseValuesFromTriggerTime(E) == 1);

  ret = Event_unsetUseValuesFromTriggerTime(E);

  fail_unless(ret == LIBSBML_OPERATION_SUCCESS);
  fail_unless(Event_getUseValuesFromTriggerTime(E) == 0);
  fail_unless(Event_isSetUseValuesFromTriggerTime(E) == 0);

}
Пример #29
0
static gboolean
verify_buffer (buffer_verify_data_s * vdata, GstBuffer * buffer)
{
  if (vdata->discard) {
    /* check separate header NALs */
    gint i = vdata->buffer_counter;
    guint ofs;

    /* SEI with start code prefix with 2 0-bytes */
    ofs = i == 1;

    fail_unless (i <= 2);
    fail_unless (gst_buffer_get_size (buffer) == ctx_headers[i].size - ofs);
    fail_unless (gst_buffer_memcmp (buffer, 0, ctx_headers[i].data + ofs,
            gst_buffer_get_size (buffer)) == 0);
  } else {
    GstMapInfo map;

    gst_buffer_map (buffer, &map, GST_MAP_READ);
    fail_unless (map.size > 4);
    /* only need to check avc and bs-to-nal output case */
    if (GST_READ_UINT24_BE (map.data) == 0x01) {
      /* in bs-to-nal, a leading 0x00 is stripped from output */
      fail_unless (gst_buffer_get_size (buffer) ==
          vdata->data_to_verify_size - 1);
      fail_unless (gst_buffer_memcmp (buffer, 0, vdata->data_to_verify + 1,
              vdata->data_to_verify_size - 1) == 0);
      gst_buffer_unmap (buffer, &map);
      return TRUE;
    } else if (GST_READ_UINT32_BE (map.data) == 0x01) {
      /* this is not avc, use default tests from parser.c */
      gst_buffer_unmap (buffer, &map);
      return FALSE;
    }
    /* header is merged in initial frame */
    if (vdata->buffer_counter == 0) {
      guint8 *data = map.data;

      fail_unless (map.size == vdata->data_to_verify_size +
          ctx_headers[0].size + ctx_headers[1].size + ctx_headers[2].size);
      fail_unless (GST_READ_UINT32_BE (data) == ctx_headers[0].size - 4);
      fail_unless (memcmp (data + 4, ctx_headers[0].data + 4,
              ctx_headers[0].size - 4) == 0);
      data += ctx_headers[0].size;
      fail_unless (GST_READ_UINT32_BE (data) == ctx_headers[1].size - 4);
      fail_unless (memcmp (data + 4, ctx_headers[1].data + 4,
              ctx_headers[1].size - 4) == 0);
      data += ctx_headers[1].size;
      fail_unless (GST_READ_UINT32_BE (data) == ctx_headers[2].size - 4);
      fail_unless (memcmp (data + 4, ctx_headers[2].data + 4,
              ctx_headers[2].size - 4) == 0);
      data += ctx_headers[2].size;
      fail_unless (GST_READ_UINT32_BE (data) == vdata->data_to_verify_size - 4);
      fail_unless (memcmp (data + 4, vdata->data_to_verify + 4,
              vdata->data_to_verify_size - 4) == 0);
    } else {
      fail_unless (GST_READ_UINT32_BE (map.data) == map.size - 4);
      fail_unless (map.size == vdata->data_to_verify_size);
      fail_unless (memcmp (map.data + 4, vdata->data_to_verify + 4,
              map.size - 4) == 0);
    }
    gst_buffer_unmap (buffer, &map);
    return TRUE;
  }

  return FALSE;
}
Пример #30
0
END_TEST

START_TEST(svr_setjobstate_test)
  {
  struct job test_job;
  int result = PBSE_NONE;

  memset(&test_job, 0, sizeof(test_job));

  /*initialize_globals*/
  server.sv_qs_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t));
  server.sv_attr_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t));
  server.sv_jobstates_mutex = (pthread_mutex_t *)calloc(1, sizeof(pthread_mutex_t));

  pthread_mutex_init(server.sv_qs_mutex,NULL);
  pthread_mutex_init(server.sv_attr_mutex,NULL);
  pthread_mutex_init(server.sv_jobstates_mutex,NULL);

  result = svr_setjobstate(NULL, 0, 0, 0);
  fail_unless(result == PBSE_BAD_PARAMETER, "NULL input pointer fail");

  result = svr_setjobstate(&test_job, 0, 0, 0);
  fail_unless(result == PBSE_NONE, "svr_setjobstate fail");

  result = svr_setjobstate(&test_job, 1, 2, 3);
  fail_unless(result == PBSE_NONE, "svr_setjobstate fail");

  test_job.ji_qs.ji_state = JOB_STATE_RUNNING;
  test_job.ji_wattr[JOB_ATR_exec_host].at_val.at_str = strdup("napali/0");
  fail_unless(svr_setjobstate(&test_job, JOB_STATE_QUEUED, JOB_SUBSTATE_QUEUED, FALSE) == PBSE_NONE);
  fail_unless(test_job.ji_wattr[JOB_ATR_exec_host].at_val.at_str == NULL);

  test_job.ji_qs.ji_state = JOB_STATE_RUNNING;
  test_job.ji_wattr[JOB_ATR_exec_host].at_val.at_str = strdup("lei/0");
  test_job.ji_wattr[JOB_ATR_checkpoint].at_val.at_str = strdup("enabled");
  test_job.ji_qs.ji_svrflags |= JOB_SVFLG_CHECKPOINT_FILE;
  fail_unless(svr_setjobstate(&test_job, JOB_STATE_QUEUED, JOB_SUBSTATE_QUEUED, FALSE) == PBSE_NONE);
  fail_unless(test_job.ji_wattr[JOB_ATR_exec_host].at_val.at_str != NULL, "exec_host list got removed when it shouldn't have...");

  decrement_count = 0;
  fail_unless(svr_setjobstate(&test_job, JOB_STATE_COMPLETE, JOB_SUBSTATE_COMPLETE, FALSE) == PBSE_NONE);
  fail_unless(decrement_count == 2);

  decrement_count = 0;
  fail_unless(svr_setjobstate(&test_job, JOB_STATE_COMPLETE, JOB_SUBSTATE_COMPLETE, FALSE) == PBSE_NONE);
  fail_unless(decrement_count == 0);
  }