Пример #1
0
END_TEST

START_TEST(test_query_apply)
{
    HySack sack = test_globals.sack;
    HyQuery q;
    HyPackageList plist;

    q = hy_query_create(sack);
    hy_query_filter(q, HY_PKG_NAME, HY_NOT | HY_GLOB, "j*");
    struct _HyQuery _q = *q;
    fail_unless(_q.result == NULL);
    ck_assert_int_gt(_q.nfilters, 0);
    ck_assert_int_eq(_q.applied, 0);
    hy_query_apply(q);
    _q = *q;
    fail_unless(_q.result != NULL);
    ck_assert_int_eq(_q.nfilters, 0);
    ck_assert_int_eq(_q.applied, 1);
    hy_query_filter(q, HY_PKG_NAME, HY_NOT | HY_GLOB, "p*");
    _q = *q;
    fail_unless(_q.result != NULL);
    ck_assert_int_gt(_q.nfilters, 0);
    ck_assert_int_eq(_q.applied, 0);
    plist = hy_query_run(q);

    ck_assert_int_eq(hy_packagelist_count(plist), 6);
    hy_packagelist_free(plist);
    hy_query_free(q);
}
Пример #2
0
END_TEST

START_TEST(test_uinput_check_syspath_time)
{
	struct libevdev *dev;
	struct libevdev_uinput *uidev, *uidev2;
	const char *syspath, *syspath2;
	int fd, fd2;
	int rc;

	dev = libevdev_new();
	ck_assert(dev != NULL);
	libevdev_set_name(dev, TEST_DEVICE_NAME);
	libevdev_enable_event_type(dev, EV_SYN);
	libevdev_enable_event_type(dev, EV_REL);
	libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
	libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);

	fd = open(UINPUT_NODE, O_RDWR);
	ck_assert_int_gt(fd, -1);
	fd2 = open(UINPUT_NODE, O_RDWR);
	ck_assert_int_gt(fd2, -1);

	rc = libevdev_uinput_create_from_device(dev, fd, &uidev);
	ck_assert_int_eq(rc, 0);

	/* sleep for 1.5 seconds. sysfs resolution is 1 second, so
	   creating both devices without delay means
	   libevdev_uinput_get_syspath can't actually differ between
	   them. By waiting, we get different ctime for uidev and uidev2,
	   and exercise that part of the code.
	 */
	usleep(1500000);

	/* create a second one to test the syspath time filtering code */
	rc = libevdev_uinput_create_from_device(dev, fd2, &uidev2);
	ck_assert_int_eq(rc, 0);

	syspath = libevdev_uinput_get_syspath(uidev);
	ck_assert(syspath != NULL);

	/* get syspath twice returns same pointer */
	syspath2 = libevdev_uinput_get_syspath(uidev);
	ck_assert(syspath == syspath2);

	/* second dev has different syspath */
	syspath2 = libevdev_uinput_get_syspath(uidev2);
	ck_assert(strcmp(syspath, syspath2) != 0);

	libevdev_free(dev);
	libevdev_uinput_destroy(uidev);
	libevdev_uinput_destroy(uidev2);

	close(fd);
	close(fd2);
}
Пример #3
0
END_TEST

START_TEST(test_ck_assert_int_gt)
{
  int x = 2;
  int y = 3;
  ck_assert_int_gt(y, x);
  ck_assert_int_gt(y, y);
  #define LINENO_ck_assert_int_gt _STR(__LINE__)
}
Пример #4
0
END_TEST

START_TEST(service_request_inval_service_selection) {
  ck_assert_int_gt(nuts_msg_service_request_print(&msg_buf, "inval"), 0);
  ck_assert_int_eq(nuts_srv_service_invoke(handler, &env, msg_buf.data, msg_buf.size), NUTS_DONE);
  ck_assert_int_eq(selected_invocations, 0);
  ck_assert_int_gt(buf_s2c->size, 0);
  ck_assert_int_eq(nuts_packet_read(buf_s2c, keystore, 0, &payload, &npayload), buf_s2c->size);
  ck_assert_int_gt(nuts_msg_disconnect_scan(payload, npayload, NULL, NULL), 0);
}
Пример #5
0
END_TEST

START_TEST(service_request_inval_service_selected) {
  ck_assert_int_gt(nuts_msg_service_request_print(&msg_buf, "continue"), 0);
  ck_assert_int_eq(nuts_srv_service_invoke(handler, &env, msg_buf.data, msg_buf.size), NUTS_CONTINUE);
  ck_assert_int_eq(selected_invocations, 1);
  ck_assert_int_gt(buf_s2c->size, 0);
  ck_assert_int_eq(nuts_packet_read(buf_s2c, keystore, 0, &payload, &npayload), buf_s2c->size);
  ck_assert_int_gt(nuts_msg_service_accept_scan(payload, npayload, &cstr), 0);
  ck_assert_str_eq(cstr, "continue");
}
Пример #6
0
END_TEST

START_TEST(test_uinput_create_device_from_fd)
{
	struct libevdev *dev, *dev2;
	struct libevdev_uinput *uidev;
	int fd, fd2;
	unsigned int type, code;
	int rc;
	const char *devnode;

	dev = libevdev_new();
	ck_assert(dev != NULL);
	libevdev_set_name(dev, TEST_DEVICE_NAME);
	libevdev_enable_event_type(dev, EV_SYN);
	libevdev_enable_event_type(dev, EV_REL);
	libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
	libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);

	fd = open(UINPUT_NODE, O_RDWR);
	ck_assert_int_gt(fd, -1);

	rc = libevdev_uinput_create_from_device(dev, fd, &uidev);
	ck_assert_int_eq(rc, 0);
	ck_assert(uidev != NULL);

	ck_assert_int_eq(libevdev_uinput_get_fd(uidev), fd);

	devnode = libevdev_uinput_get_devnode(uidev);
	ck_assert(devnode != NULL);

	fd2 = open(devnode, O_RDONLY);
	ck_assert_int_gt(fd2, -1);
	rc = libevdev_new_from_fd(fd2, &dev2);
	ck_assert_int_eq(rc, 0);

	for (type = 0; type < EV_CNT; type++) {
		int max = libevdev_event_type_get_max(type);
		if (max == -1)
			continue;

		for (code = 0; code < max; code++) {
			ck_assert_int_eq(libevdev_has_event_code(dev, type, code),
					 libevdev_has_event_code(dev2, type, code));
		}
	}

	libevdev_free(dev);
	libevdev_free(dev2);
	libevdev_uinput_destroy(uidev);
	close(fd);
	close(fd2);
}
Пример #7
0
END_TEST

START_TEST(test_uinput_check_syspath_name)
{
	struct libevdev *dev;
	struct libevdev_uinput *uidev, *uidev2;
	const char *syspath, *syspath2;
	int fd, fd2;
	int rc;

	dev = libevdev_new();
	ck_assert(dev != NULL);
	libevdev_set_name(dev, TEST_DEVICE_NAME);
	libevdev_enable_event_type(dev, EV_SYN);
	libevdev_enable_event_type(dev, EV_REL);
	libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
	libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);

	fd = open(UINPUT_NODE, O_RDWR);
	ck_assert_int_gt(fd, -1);
	fd2 = open(UINPUT_NODE, O_RDWR);
	ck_assert_int_gt(fd2, -1);

	rc = libevdev_uinput_create_from_device(dev, fd, &uidev);
	ck_assert_int_eq(rc, 0);

	/* create a second one to stress the syspath filtering code */
	libevdev_set_name(dev, TEST_DEVICE_NAME " 2");
	rc = libevdev_uinput_create_from_device(dev, fd2, &uidev2);
	ck_assert_int_eq(rc, 0);

	syspath = libevdev_uinput_get_syspath(uidev);
	ck_assert(syspath != NULL);

	/* get syspath twice returns same pointer */
	syspath2 = libevdev_uinput_get_syspath(uidev);
	ck_assert(syspath == syspath2);

	/* second dev has different syspath */
	syspath2 = libevdev_uinput_get_syspath(uidev2);
	ck_assert(strcmp(syspath, syspath2) != 0);

	libevdev_free(dev);
	libevdev_uinput_destroy(uidev);
	libevdev_uinput_destroy(uidev2);

	close(fd);
	close(fd2);
}
Пример #8
0
END_TEST


START_TEST(test_pcre_pattern_more)
{
    match_entry * entry;
    entry = match_entry_createl( "/user/123" , strlen("/user/123") );
    node * n = r3_tree_create(10);

    int var0 = 5;
    int var1 = 100;
    int var2 = 200;
    int var3 = 300;

    info("var0: %p\n", &var0);
    info("var1: %p\n", &var1);
    info("var2: %p\n", &var2);
    info("var3: %p\n", &var3);

    r3_tree_insert_path(n, "/user/{id:\\d+}", &var1);
    r3_tree_insert_path(n, "/user2/{id:\\d+}", &var2);
    r3_tree_insert_path(n, "/user3/{id:\\d{3}}", &var3);
    r3_tree_insert_path(n, "/user", &var0);
    r3_tree_compile(n);
    // r3_tree_dump(n, 0);
    node *matched;

    matched = r3_tree_matchl(n, "/user/123", strlen("/user/123"), entry);
    fail_if(matched == NULL);
    ck_assert_int_gt(entry->vars->len, 0);
    ck_assert_str_eq(entry->vars->tokens[0],"123");

    info("matched %p\n", matched->data);
    info("matched %p\n", matched->data);
    ck_assert_int_eq( *((int*) matched->data), var1);

    matched = r3_tree_matchl(n, "/user2/123", strlen("/user2/123"), entry);
    fail_if(matched == NULL);
    ck_assert_int_gt(entry->vars->len, 0);
    ck_assert_str_eq(entry->vars->tokens[0],"123");
    ck_assert_int_eq( *((int*)matched->data), var2);

    matched = r3_tree_matchl(n, "/user3/123", strlen("/user3/123"), entry);
    fail_if(matched == NULL);
    ck_assert_int_gt(entry->vars->len, 0);
    ck_assert_str_eq(entry->vars->tokens[0],"123");
    ck_assert_int_eq( *((int*)matched->data), var3);
}
Пример #9
0
END_TEST


START_TEST (test_pcre_patterns_insert)
{
    node * n = r3_tree_create(10);

    // r3_tree_insert_path(n, "/foo-{user}-{id}", NULL, NULL);
    // r3_tree_dump(n, 0);
    r3_tree_insert_path(n, "/post/{handle:\\d+}-{id:\\d+}", NULL);
    r3_tree_compile(n);
    r3_tree_dump(n, 0);

    node *matched;
    matched = r3_tree_matchl(n, "/post/111-222", strlen("/post/111-222"), NULL);
    ck_assert(matched);
    ck_assert_int_gt(matched->endpoint, 0);

    // incomplete string shouldn't match
    matched = r3_tree_matchl(n, "/post/111-", strlen("/post/111-"), NULL);
    ck_assert(matched);
    ck_assert_int_eq(matched->endpoint, 0);

    r3_tree_free(n);
}
Пример #10
0
END_TEST

START_TEST(test_http_disabled)
{
	const gchar *header = "GET /iframe HTTP/1.1\n\n";

	ck_assert(g_file_set_contents("test_http_disabled.ini",
		"[quick.io]\n"
		"public-address =", -1, NULL));
	test_setup_with_config("test_http_disabled.ini");
	unlink("test_http_disabled.ini");

	gint err;
	gchar buff[0xffff];
	qev_fd_t s = test_socket();

	err = send(s, header, strlen(header), 0);
	ck_assert_int_eq(strlen(header), err);

	err = recv(s, buff, sizeof(buff), 0);
	ck_assert_int_gt(err, 0);
	buff[err] = '\0';

	ck_assert(strstr(buff, "501 Not Implemented") != NULL);
	ck_assert(strstr(buff, "window.parent.postMessage") != NULL);

	close(s);
}
Пример #11
0
} END_TEST

START_TEST(test_dup_over_stdio) {
	int fd = -1;

	/* save stdin fd  */
	int saved_stdin = dup(STDIN_FILENO);

	/* fd pointer is NULL */
	ck_assert(! dup_over_stdio(NULL));

	/* fd number is -1 */
	fd = -1;
	ck_assert(! dup_over_stdio(&fd));


	/* dup not used but open STDIN fd */
	fd = STDIN_FILENO ;
	ck_assert(dup_over_stdio(&fd));
	ck_assert_int_gt(fd,2);
	ck_assert( fcntl(STDIN_FILENO, F_GETFD) == -1 );
	/* now the fd is higher than 2 , the fd number will not change*/
	int saved_fd_no = fd;
	ck_assert(dup_over_stdio(&fd));
	ck_assert_int_eq(fd,saved_fd_no);
	close(fd);
	/* fd closed*/
	ck_assert(!dup_over_stdio(&fd));

	/* restore stdin fd */
	dup2(saved_stdin, STDIN_FILENO);
	close(saved_stdin);
} END_TEST
Пример #12
0
END_TEST

START_TEST(log_priority)
{
	struct libinput *li;

	li = libinput_path_create_context(&simple_interface, NULL);
	libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_ERROR);
	libinput_log_set_handler(li, simple_log_handler);
	log_handler_context = li;

	libinput_path_add_device(li, "/tmp");

	ck_assert_int_eq(log_handler_called, 1);

	libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_INFO);
	/* event0 is usually Lid Switch which prints an info that
	   we don't handle it */
	libinput_path_add_device(li, "/dev/input/event0");
	ck_assert_int_gt(log_handler_called, 1);

	log_handler_called = 0;

	libinput_unref(li);
	log_handler_context = NULL;
}
Пример #13
0
END_TEST

START_TEST(getversion_returns_a_version)
{
	ck_assert_int_gt((int)strlen(getversion()), 1);
	ck_assert(strchr(getversion(), '_') == NULL);
	ck_assert(strchr(getversion(), '.') != NULL);
}
Пример #14
0
END_TEST

START_TEST(service_request_inval_message) {
  ck_assert_int_gt(nuts_msg_ignore_print(&msg_buf, 8), 0); // any other message that SSH_MSG_SERVICE_REQUEST
  ck_assert_int_eq(nuts_srv_service_invoke(handler, &env, msg_buf.data, msg_buf.size), NUTS_ERROR);
  ck_assert_int_eq(selected_invocations, 0);
  ck_assert_lv_empty(buf_s2c);
}
Пример #15
0
END_TEST

START_TEST(test_uinput_events)
{
	struct libevdev *dev;
	struct libevdev_uinput *uidev;
	int fd, fd2;
	int rc;
	const char *devnode;
	int i;
	const int nevents = 5;
	struct input_event events[] = { {{0, 0}, EV_REL, REL_X, 1},
					{{0, 0}, EV_REL, REL_Y, -1},
					{{0, 0}, EV_SYN, SYN_REPORT, 0},
					{{0, 0}, EV_KEY, BTN_LEFT, 1},
					{{0, 0}, EV_SYN, SYN_REPORT, 0}};
	struct input_event events_read[nevents];

	dev = libevdev_new();
	ck_assert(dev != NULL);
	libevdev_set_name(dev, TEST_DEVICE_NAME);
	libevdev_enable_event_type(dev, EV_SYN);
	libevdev_enable_event_type(dev, EV_REL);
	libevdev_enable_event_type(dev, EV_KEY);
	libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
	libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);
	libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);

	fd = open(UINPUT_NODE, O_RDWR);
	ck_assert_int_gt(fd, -1);

	rc = libevdev_uinput_create_from_device(dev, fd, &uidev);
	ck_assert_int_eq(rc, 0);
	ck_assert(uidev != NULL);

	devnode = libevdev_uinput_get_devnode(uidev);
	ck_assert(devnode != NULL);

	fd2 = open(devnode, O_RDONLY);

	for (i = 0; i < nevents; i++)
		libevdev_uinput_write_event(uidev, events[i].type, events[i].code, events[i].value);

	rc = read(fd2, events_read, sizeof(events_read));
	ck_assert_int_eq(rc, sizeof(events_read));

	for (i = 0; i < nevents; i++) {
		ck_assert_int_eq(events[i].type, events_read[i].type);
		ck_assert_int_eq(events[i].code, events_read[i].code);
		ck_assert_int_eq(events[i].value, events_read[i].value);
	}

	libevdev_free(dev);
	libevdev_uinput_destroy(uidev);
	close(fd);
	close(fd2);
}
Пример #16
0
END_TEST

START_TEST(mosecs_return_values)
{
	time_t a, b;
	defaultcfg();
	cfg.monthrotate = 1;
	ck_assert_int_eq(mosecs(0, 0), 1);

	a = mosecs(172800, 173000);
	ck_assert_int_gt(a, 1);

	cfg.monthrotate = 2;
	b = mosecs(172800, 173000);
	ck_assert_int_gt(b, 1);

	ck_assert_int_gt(a, b);
}
Пример #17
0
END_TEST

START_TEST(test_clogger_expanded_macro)
{
    new_output();
    ck_assert_int_eq(output_size(), 0);
    LOG_INFO("This is a log line");
    fflush(output_fd);
    ck_assert_int_gt(output_size(), 0);
}
Пример #18
0
END_TEST

START_TEST(Session_updateLifetime_ShallWork) {
    UA_Session session;
    UA_Session_init(&session);
    UA_DateTime tmpDateTime;
    tmpDateTime = session.validTill;
    UA_Session_updateLifetime(&session);

    UA_Int32 result = (session.validTill >= tmpDateTime);
    ck_assert_int_gt(result,0);
}
Пример #19
0
END_TEST

START_TEST(test_clogger_log_levels)
{
    new_output();
    clogger_set_level(Warn);
    ck_assert_int_eq(output_size(), 0);
    LOG_INFO("This is a log line");
    fflush(output_fd);
    ck_assert_int_eq(output_size(), 0);
    LOG_WARN("This is a log line");
    fflush(output_fd);
    ck_assert_int_gt(output_size(), 0);
}
Пример #20
0
static void
test_bt_child_proxy_get (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  gulong length;

  GST_INFO ("-- act --");
  bt_child_proxy_get (song, "sequence::length", &length, NULL);

  GST_INFO ("-- assert --");
  ck_assert_int_gt (length, 0);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Пример #21
0
/* test recording (loop test over BtSinkBinRecordFormat */
static void
test_bt_sink_bin_record (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  if (!bt_sink_bin_is_record_format_supported (_i))
    return;
  // see GST_BUG_733031
  if (_i == 3 || _i == 6)
    return;
#if !GST_CHECK_VERSION (1,8,0)
  if (_i == 5 || _i == 7)
    return;
#endif

  make_new_song ( /*silence */ 4);
  GstElement *sink_bin = get_sink_bin ();
  GEnumClass *enum_class =
      g_type_class_peek_static (BT_TYPE_SINK_BIN_RECORD_FORMAT);
  GEnumValue *enum_value = g_enum_get_value (enum_class, _i);
  gchar *filename = make_tmp_song_path ("record", enum_value->value_name);
  g_object_set (sink_bin,
      "mode", BT_SINK_BIN_MODE_RECORD,
      "record-format", _i, "record-file-name", filename, NULL);

  GST_INFO ("-- act --");
  GST_INFO ("act: == %s ==", filename);
  bt_song_play (song);
  run_main_loop_until_eos ();
  bt_song_stop (song);
  g_object_set (sink_bin, "mode", BT_SINK_BIN_MODE_PLAY, NULL);

  GST_INFO ("-- assert --");
  GST_INFO ("assert: == %s ==", filename);
  fail_unless (g_file_test (filename, G_FILE_TEST_IS_REGULAR));
  GStatBuf st;
  g_stat (filename, &st);
  ck_assert_int_gt (st.st_size, 0);
  ck_assert_str_eq_and_free (get_media_type (filename), media_types[_i]);

  GST_INFO ("-- cleanup --");
  g_free (filename);
  gst_object_unref (sink_bin);
  BT_TEST_END;
}
Пример #22
0
END_TEST


START_TEST(test_pcre_pattern_simple)
{
    match_entry * entry;
    entry = match_entry_createl( "/user/123" , strlen("/user/123") );
    node * n = r3_tree_create(10);
    r3_tree_insert_path(n, "/user/{id:\\d+}", NULL);
    r3_tree_insert_path(n, "/user", NULL);
    r3_tree_compile(n);
    // r3_tree_dump(n, 0);
    node *matched;
    matched = r3_tree_matchl(n, "/user/123", strlen("/user/123"), entry);
    fail_if(matched == NULL);
    ck_assert_int_gt(entry->vars->len, 0);
    ck_assert_str_eq(entry->vars->tokens[0],"123");
}
Пример #23
0
static void
test_bt_child_proxy_get_property (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  GValue value = { 0, };
  g_value_init (&value, G_TYPE_ULONG);

  GST_INFO ("-- act --");
  bt_child_proxy_get_property ((GObject *) song, "sequence::length", &value);
  gulong length = g_value_get_ulong (&value);

  GST_INFO ("-- assert --");
  ck_assert_int_gt (length, 0);

  GST_INFO ("-- cleanup --");
  g_value_unset (&value);
  BT_TEST_END;
}
Пример #24
0
END_TEST

START_TEST(test_uinput_properties)
{
	struct libevdev *dev, *dev2;
	struct libevdev_uinput *uidev;
	int fd;
	int rc;
	const char *devnode;

	dev = libevdev_new();
	ck_assert(dev != NULL);
	libevdev_set_name(dev, TEST_DEVICE_NAME);
	libevdev_enable_event_type(dev, EV_SYN);
	libevdev_enable_event_type(dev, EV_REL);
	libevdev_enable_event_type(dev, EV_KEY);
	libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
	libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);
	libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);
	libevdev_enable_property(dev, INPUT_PROP_BUTTONPAD);
	libevdev_enable_property(dev, INPUT_PROP_MAX);

	rc = libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &uidev);
	ck_assert_int_eq(rc, 0);
	ck_assert(uidev != NULL);

	devnode = libevdev_uinput_get_devnode(uidev);
	ck_assert(devnode != NULL);

	fd = open(devnode, O_RDONLY);
	ck_assert_int_gt(fd, -1);
	rc = libevdev_new_from_fd(fd, &dev2);
	ck_assert_int_eq(rc, 0);

	ck_assert(libevdev_has_property(dev2, INPUT_PROP_BUTTONPAD));
	ck_assert(libevdev_has_property(dev2, INPUT_PROP_MAX));

	libevdev_free(dev);
	libevdev_free(dev2);
	libevdev_uinput_destroy(uidev);
	close(fd);
}
} END_TEST

START_TEST(AddComplexTypeWithInheritance) {
    /* add a variable node to the address space */
    UA_ObjectAttributes attr = UA_ObjectAttributes_default;
    attr.description = UA_LOCALIZEDTEXT("en-US","fakeServerStruct");
    attr.displayName = UA_LOCALIZEDTEXT("en-US","fakeServerStruct");
  
    UA_NodeId myObjectNodeId = UA_NODEID_STRING(1, "the.fake.Server.Struct");
    UA_QualifiedName myObjectName = UA_QUALIFIEDNAME(1, "the.fake.Server.Struct");
    UA_NodeId parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
    UA_NodeId parentReferenceNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
    UA_StatusCode res =
        UA_Server_addObjectNode(server, myObjectNodeId, parentNodeId,
                                parentReferenceNodeId, myObjectName,
                                UA_NODEID_NUMERIC(0, 2004), attr,
                                &handleCalled, NULL);
    ck_assert_int_eq(UA_STATUSCODE_GOOD, res);
    ck_assert_int_gt(handleCalled, 0); // Should be 58, but may depend on NS0 XML detail
} END_TEST
Пример #26
0
static void
test_bt_song_info_seconds_since_last_saved (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtSongInfo *song_info =
      BT_SONG_INFO (check_gobject_get_object_property (song, "song-info"));

  GST_INFO ("-- act --");
  // TODO: waiting one sec makes this the slowest test :/
  g_usleep (G_USEC_PER_SEC);
  gint ts = bt_song_info_get_seconds_since_last_saved (song_info);

  GST_INFO ("-- assert --");
  ck_assert_int_gt (ts, 0);

  GST_INFO ("-- cleanup --");
  g_object_unref (song_info);
  BT_TEST_END;
}
Пример #27
0
END_TEST

START_TEST(test_http_iframe)
{
	const gchar *header = "GET /iframe?instanceid=123 HTTP/1.1\n\n";

	gint err;
	gchar buff[0xffff];
	qev_fd_t s = test_socket();

	err = send(s, header, strlen(header), 0);
	ck_assert_int_eq(strlen(header), err);

	err = recv(s, buff, sizeof(buff), 0);
	ck_assert_int_gt(err, 0);
	buff[err] = '\0';

	ck_assert(strstr(buff, "<!DOCTYPE html>") != NULL);

	close(s);
}
Пример #28
0
END_TEST

START_TEST(log_handler_invoked)
{
	struct libinput *li;

	li = libinput_path_create_context(&simple_interface, NULL);

	libinput_log_set_priority(li, LIBINPUT_LOG_PRIORITY_DEBUG);
	libinput_log_set_handler(li, simple_log_handler);
	log_handler_context = li;

	libinput_path_add_device(li, "/tmp");

	ck_assert_int_gt(log_handler_called, 0);
	log_handler_called = 0;

	libinput_unref(li);

	log_handler_context = NULL;
}
Пример #29
0
END_TEST

START_TEST(test_http_surrogate)
{
	const gchar *headers =
		"POST /?sid=16a0dd9a4e554a9f94520c8bfa59e1b9&connect=true HTTP/1.1\n"
		"Content-Length: 0\n\n";
	const gchar *ping =
		"POST /?sid=16a0dd9a4e554a9f94520c8bfa59e1b9 HTTP/1.1\n"
		"Content-Length: 16\n\n"
		"/qio/ping:1=null";

	gint err;
	struct client *surrogate;
	qev_fd_t s = test_socket();
	struct client *client = test_get_client_raw();

	ck_assert(!qev_is_surrogate(client));

	err = send(s, headers, strlen(headers), 0);
	ck_assert_int_eq(err, strlen(headers));

	QEV_WAIT_FOR(client->http.client != NULL);
	surrogate = test_get_surrogate();

	client->last_send = qev_monotonic - QEV_SEC_TO_USEC(60);

	test_heartbeat();

	ck_assert(client->http.client == NULL);
	_assert_status_code(s, 200);

	ck_assert_int_gt(surrogate->last_send, qev_monotonic - QEV_SEC_TO_USEC(1));

	err = send(s, ping, strlen(ping), 0);
	ck_assert_int_eq(err, strlen(ping));
	_assert_status_code(s, 200);

	close(s);
}
Пример #30
0
END_TEST

START_TEST(timeused_debug_outputs_something_expected_when_debug_is_enabled)
{
	int pipe, len;
	char buffer[512];
	memset(&buffer, '\0', sizeof(buffer));

	defaultcfg();
	debug = 1;
	pipe = pipe_output();
	/* the assumption here is that the next two steps
	   can always execute in less than one second resulting
	   in a duration that starts with a zero */
	timeused_debug("that_func", 1);
	timeused_debug("that_func", 0);
	fflush(stdout);

	len = (int)read(pipe, buffer, 512);
	ck_assert_int_gt(len, 1);
	ck_assert_ptr_ne(strstr(buffer, "that_func() in 0"), NULL);
}