Example #1
0
}

int CtSgwGetAppStatus(CtSgwAppStatus_t *app_status)
{
	GDBusConnection *connection;
	GDBusProxy *proxy;
	GError *error = NULL;
	GVariant *result;
	gchar *str;
	gint ret = 0;

	connection = g_bus_get_sync (DBUS_TYPE, NULL, &error);
	g_assert_no_error(error);

	proxy = g_dbus_proxy_new_sync(connection,
								  G_DBUS_PROXY_FLAGS_NONE,
								  NULL,					  /* GDBusInterfaceInfo */
								  "com.ctc.appframework1", /* name */
								  "/com/ctc/appframework1", /* object path */
								  "com.ctc.appframework1.AppAgent",		  /* interface */
								  NULL, /* GCancellable */
								  &error);
	g_assert_no_error(error);

	result = g_dbus_proxy_call_sync(proxy,
								"GetStatus",
								g_variant_new("(s)", app_status->name),
								G_DBUS_CALL_FLAGS_NONE,
								-1,
								NULL,
								&error);
	g_assert(result != NULL);
	g_variant_get(result, "(s)", &str);
	g_strlcpy(app_status->state, str, BUFLEN_16);

	g_variant_unref (result);
	g_object_unref (proxy);
	g_object_unref (connection);
static gpointer WriterThread(WriterThreadContext *ctx) {
  GError *error = NULL;
  GIOStatus status;

  status = g_io_channel_write_chars(ctx->channel, ctx->contents, -1, NULL,
                                    &error);
  g_assert_no_error(error);
  g_assert_cmpint(G_IO_STATUS_NORMAL, ==, status);

  status = g_io_channel_shutdown(ctx->channel, TRUE, NULL);
  g_assert_cmpint(G_IO_STATUS_NORMAL, ==, status);
  return NULL;
}
Example #3
0
static GArray *load_expected_aml(test_data *data)
{
    int i;
    AcpiSdtTable *sdt;
    GError *error = NULL;
    gboolean ret;

    GArray *exp_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
    for (i = 0; i < data->tables->len; ++i) {
        AcpiSdtTable exp_sdt;
        uint32_t signature;
        gchar *aml_file = NULL;
        const char *ext = data->variant ? data->variant : "";

        sdt = &g_array_index(data->tables, AcpiSdtTable, i);

        memset(&exp_sdt, 0, sizeof(exp_sdt));
        exp_sdt.header.signature = sdt->header.signature;

        signature = cpu_to_le32(sdt->header.signature);

try_again:
        aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
                                   (gchar *)&signature, ext);
        if (getenv("V")) {
            fprintf(stderr, "\nLooking for expected file '%s'\n", aml_file);
        }
        if (g_file_test(aml_file, G_FILE_TEST_EXISTS)) {
            exp_sdt.aml_file = aml_file;
        } else if (*ext != '\0') {
            /* try fallback to generic (extention less) expected file */
            ext = "";
            g_free(aml_file);
            goto try_again;
        }
        g_assert(exp_sdt.aml_file);
        if (getenv("V")) {
            fprintf(stderr, "\nUsing expected file '%s'\n", aml_file);
        }
        ret = g_file_get_contents(aml_file, &exp_sdt.aml,
                                  &exp_sdt.aml_len, &error);
        g_assert(ret);
        g_assert_no_error(error);
        g_assert(exp_sdt.aml);
        g_assert(exp_sdt.aml_len);

        g_array_append_val(exp_tables, exp_sdt);
    }

    return exp_tables;
}
Example #4
0
static void
test_query (TestInfo      *test_info,
            gconstpointer  context)
{
	GError *error = NULL;
	gchar *data_filename;
	gchar *query_filename;
	gchar *results_filename;
	gchar *prefix, *data_prefix, *test_prefix;

	prefix = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-data", NULL);
	data_prefix = g_build_filename (prefix, test_info->data, NULL);
	test_prefix = g_build_filename (prefix, test_info->test_name, NULL);
	g_free (prefix);

	tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);

	/* initialization */
	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
	                           NULL,
	                           NULL,
	                           FALSE,
	                           FALSE,
	                           100,
	                           100,
	                           NULL,
	                           NULL,
	                           NULL,
	                           NULL);

	/* load data set */
	data_filename = g_strconcat (data_prefix, ".ttl", NULL);
	tracker_turtle_reader_load (data_filename, &error);
	g_assert_no_error (error);

	query_filename = g_strconcat (test_prefix, ".rq", NULL);
	results_filename = g_strconcat (test_prefix, ".out", NULL);

	g_free (data_prefix);
	g_free (test_prefix);

	query_helper (query_filename, results_filename);

	/* cleanup */

	g_free (data_filename);
	g_free (query_filename);
	g_free (results_filename);

	tracker_data_manager_shutdown ();
}
Example #5
0
static void
add_tests_for_files_in_directory (GFile *dir)
{
  GFileEnumerator *enumerator;
  GFileInfo *info;
  GList *files;
  GError *error = NULL;

  enumerator = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &error);
  g_assert_no_error (error);
  files = NULL;

  while ((info = g_file_enumerator_next_file (enumerator, NULL, &error)))
    {
      const char *filename;

      filename = g_file_info_get_name (info);

      if (!g_str_has_suffix (filename, ".css") ||
          g_str_has_suffix (filename, ".out.css") ||
          g_str_has_suffix (filename, ".ref.css"))
        {
          g_object_unref (info);
          continue;
        }

      files = g_list_prepend (files, g_file_get_child (dir, filename));

      g_object_unref (info);
    }
  
  g_assert_no_error (error);
  g_object_unref (enumerator);

  files = g_list_sort (files, compare_files);
  g_list_foreach (files, (GFunc) add_test_for_file, NULL);
  g_list_free_full (files, g_object_unref);
}
Example #6
0
static void
test_repo_finalize (void)
{
  GomAdapter *adapter;
  GomRepository *repository;
  gboolean ret;
  GError *error = NULL;

  /* Unref repo, then close and unref adapter */
  adapter = gom_adapter_new();
  ret = gom_adapter_open_sync (adapter, ":memory:", &error);
  g_assert_no_error (error);
  g_assert (ret);

  repository = gom_repository_new (adapter);

  g_clear_object (&repository);
  ret = gom_adapter_close_sync (adapter, &error);
  g_assert_no_error (error);
  g_assert (ret);

  g_clear_object (&adapter);

  /* Close and unref adapter, then unref repo */
  adapter = gom_adapter_new();
  ret = gom_adapter_open_sync (adapter, ":memory:", &error);
  g_assert_no_error (error);
  g_assert (ret);

  repository = gom_repository_new (adapter);

  ret = gom_adapter_close_sync (adapter, &error);
  g_assert_no_error (error);
  g_assert (ret);
  g_clear_object (&adapter);

  g_clear_object (&repository);
}
Example #7
0
static void
test_create_ok(void)
{
    struct replication_config_s cfg = { _get_id, _get_peers, _get_vers,
               NULL, ELECTION_MODE_NONE
    };
    struct election_manager_s *m = NULL;
    GError *err;

    err = election_manager_create(&cfg, &m);
    g_assert_no_error(err);
    g_assert(&cfg == election_manager_get_config0(m));
    election_manager_clean(m);
}
Example #8
0
static void
setup (Test *test,
       gconstpointer data)
{
	const gchar *filename = data;
	GError *error = NULL;
	gchar *contents;
	gsize length;

	g_file_get_contents (filename, (gchar**)&contents, &length, &error);
	g_assert_no_error (error);

	test->data = g_bytes_new_take (contents, length);
}
Example #9
0
static void
set_up_mock_xdg_runtime_dir (void)
{
  GError *error = NULL;
  GSocketAddress *addr;

  mock_bus = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, 0,
      &error);
  g_assert_no_error (error);
  g_assert_true (G_IS_SOCKET (mock_bus));

  /* alters tmpdir in-place */
  if (g_mkdtemp_full (tmpdir, 0700) == NULL)
    g_error ("g_mkdtemp_full: %s", g_strerror (errno));

  mock_bus_path = g_strconcat (tmpdir, "/bus", NULL);
  addr = g_unix_socket_address_new (mock_bus_path);
  g_socket_bind (mock_bus, addr, FALSE, &error);
  g_assert_no_error (error);
  g_object_unref (addr);

  g_setenv ("XDG_RUNTIME_DIR", tmpdir, TRUE);
}
static void TestDump(gconstpointer user_data) {
  guint index = GPOINTER_TO_UINT(user_data);
  GError *error = NULL;
  EscalateMessage *message = EscalateMessageLoad(example_messages[index],
                                                 &error);
  g_assert_no_error(error);
  g_assert(message);

  gchar *message_str = EscalateMessageDump(message);
  g_assert_cmpstr(example_messages[index], ==, message_str);

  g_free(message_str);
  EscalateMessageUnref(message);
}
Example #11
0
static void
on_connected (GObject      *source_object,
              GAsyncResult *result,
              gpointer      user_data)
{
  GSocketConnection *conn;
  GError *error = NULL;

  conn = g_socket_client_connect_to_uri_finish (G_SOCKET_CLIENT (source_object), result, &error);
  g_assert_no_error (error);

  g_object_unref (conn);
  g_main_loop_quit (user_data);
}
Example #12
0
static void
print_address (void)
{
  GError *error = NULL;
  gchar *addr;

  addr = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SESSION, NULL,
      &error);

  g_assert_no_error (error);
  g_assert_nonnull (addr);
  g_print ("%s\n", addr);
  g_free (addr);
}
Example #13
0
static void test_decode_header_actionid(void)
{
	GObexHeader *header;
	size_t parsed;
	GError *err = NULL;

	header = g_obex_header_decode(hdr_actionid, sizeof(hdr_actionid),
					G_OBEX_DATA_REF, &parsed, &err);
	g_assert_no_error(err);

	g_assert_cmpuint(parsed, ==, sizeof(hdr_actionid));

	g_obex_header_free(header);
}
static void
async_update_array_callback (GObject      *source_object,
                             GAsyncResult *result,
                             gpointer      user_data)
{
	AsyncData *data = user_data;
	GError *error = NULL;
	GPtrArray *errors;

	errors = tracker_sparql_connection_update_array_finish (connection, result, &error);
	g_assert_no_error (error);
	g_ptr_array_unref (errors);
	g_main_loop_quit (data->main_loop);
}
Example #15
0
/**
 * @internal
 *
 * @brief Tests buffer wrapping and unwrapping.
 * */
static void wrap_unwrap_test() {

    /* Test variables. */
    CCLContext * ctx = NULL;
    CCLBuffer * b = NULL;
    CCLBuffer * b_aux = NULL;
    cl_mem buffer = NULL;
    CCLErr * err = NULL;
    size_t buf_size = sizeof(cl_uint) * CCL_TEST_BUFFER_SIZE;
    cl_int status;

    /* Get the test context with the pre-defined device. */
    ctx = ccl_test_context_new(&err);
    g_assert_no_error(err);

    /* Create a buffer using OpenCL functions directly. */
    buffer = clCreateBuffer(
        ccl_context_unwrap(ctx), CL_MEM_READ_ONLY, buf_size, NULL, &status);
    g_assert_cmpint(status, ==, CL_SUCCESS);

    /* Wrap buffer. */
    b = ccl_buffer_new_wrap(buffer);

    /* If we now unwrap the wrapper, we must get the originally created
     * buffer. */
    g_assert(buffer == ccl_buffer_unwrap(b));

    /* If we again wrap the original buffer... */
    b_aux = ccl_buffer_new_wrap(buffer);

    /* ...we must get the same wrapper... */
    g_assert(b == b_aux);

    /* ... and the buffer wrapper ref count must be 2. */
    g_assert_cmpuint(2, ==, ccl_wrapper_ref_count((CCLWrapper *) b));

    /* Unref buffer, twice. */
    ccl_buffer_unref(b);

    /* Check that buffer ref count is 1. */
    g_assert_cmpuint(1, ==, ccl_wrapper_ref_count((CCLWrapper *) b));

    /* Destroy stuff. */
    ccl_buffer_destroy(b);
    ccl_context_destroy(ctx);

    /* Confirm that memory allocated by wrappers has been properly
     * freed. */
    g_assert(ccl_wrapper_memcheck());
}
Example #16
0
/**
 * @internal
 *
 * @brief Tests creation, getting info from and destruction of
 * buffer wrapper objects.
 * */
static void create_info_destroy_test() {

    /* Test variables. */
    CCLContext * ctx = NULL;
    CCLBuffer * b = NULL;
    CCLErr * err = NULL;
    size_t buf_size = sizeof(cl_uint) * CCL_TEST_BUFFER_SIZE;

    /* Get the test context with the pre-defined device. */
    ctx = ccl_test_context_new(&err);
    g_assert_no_error(err);

    /* Create regular buffer. */
    b = ccl_buffer_new(ctx, CL_MEM_READ_WRITE, buf_size, NULL, &err);
    g_assert_no_error(err);

    /* Get some info and check if the return value is as expected. */
    cl_mem_object_type mot;
    mot = ccl_memobj_get_info_scalar(
        b, CL_MEM_TYPE, cl_mem_object_type, &err);
    g_assert_no_error(err);
    g_assert_cmphex(mot, ==, CL_MEM_OBJECT_BUFFER);

    cl_mem_flags flags;
    flags = ccl_memobj_get_info_scalar(
        b, CL_MEM_FLAGS, cl_mem_flags, &err);
    g_assert_no_error(err);
    g_assert_cmphex(flags, ==, CL_MEM_READ_WRITE);

    size_t mem_size;
    mem_size = ccl_memobj_get_info_scalar(b, CL_MEM_SIZE, size_t, &err);
    g_assert_no_error(err);
    g_assert_cmpuint(mem_size, ==, buf_size);

    void * host_ptr = NULL;
    host_ptr = ccl_memobj_get_info_scalar(
        b, CL_MEM_HOST_PTR, void*, &err);
    g_assert((err == NULL) || (err->code == CCL_ERROR_INFO_UNAVAILABLE_OCL));
    g_assert_cmphex(GPOINTER_TO_UINT(host_ptr), ==,
        GPOINTER_TO_UINT(NULL));
    g_clear_error(&err);

    cl_context context;
    context = ccl_memobj_get_info_scalar(
        b, CL_MEM_CONTEXT, cl_context, &err);
    g_assert_no_error(err);
    g_assert_cmphex(GPOINTER_TO_UINT(context), ==,
        GPOINTER_TO_UINT(ccl_context_unwrap(ctx)));

    /* Destroy stuff. */
    ccl_buffer_destroy(b);
    ccl_context_destroy(ctx);

    /* Confirm that memory allocated by wrappers has been properly
     * freed. */
    g_assert(ccl_wrapper_memcheck());
}
static void
appeared_cb (GDBusConnection *connection,
	     const gchar     *name,
	     const gchar     *name_owner,
	     gpointer         user_data)
{
	GError *error = NULL;

	iio_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
						   G_DBUS_PROXY_FLAGS_NONE,
						   NULL,
						   "net.hadess.SensorProxy",
						   "/net/hadess/SensorProxy",
						   "net.hadess.SensorProxy",
						   NULL, NULL);

	g_signal_connect (G_OBJECT (iio_proxy), "g-properties-changed",
			  G_CALLBACK (properties_changed), NULL);

	/* Accelerometer */
	g_dbus_proxy_call_sync (iio_proxy,
				"ClaimAccelerometer",
				NULL,
				G_DBUS_CALL_FLAGS_NONE,
				-1,
				NULL, &error);
	g_assert_no_error (error);

	/* ALS */
	g_dbus_proxy_call_sync (iio_proxy,
				"ClaimLight",
				NULL,
				G_DBUS_CALL_FLAGS_NONE,
				-1,
				NULL, &error);
	g_assert_no_error (error);
}
Example #18
0
static void
fixture_setup(TestFixture *fixture, gconstpointer data)
{
    const gchar *extra_arg = data;
    GError *error = NULL;
    gchar *cwd, *path, *cmd, **argv = NULL;

    fixture->loop = g_main_loop_new(NULL, FALSE);

    fixture->test_dir = g_strdup("/tmp/qgatest.XXXXXX");
    g_assert_nonnull(mkdtemp(fixture->test_dir));

    path = g_build_filename(fixture->test_dir, "sock", NULL);
    cwd = g_get_current_dir();
    cmd = g_strdup_printf("%s%cqemu-ga -m unix-listen -t %s -p %s %s %s",
                          cwd, G_DIR_SEPARATOR,
                          fixture->test_dir, path,
                          getenv("QTEST_LOG") ? "-v" : "",
                          extra_arg ?: "");
    g_shell_parse_argv(cmd, NULL, &argv, &error);
    g_assert_no_error(error);

    g_spawn_async(fixture->test_dir, argv, NULL,
                  G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD,
                  NULL, NULL, &fixture->pid, &error);
    g_assert_no_error(error);

    g_child_watch_add(fixture->pid, qga_watch, fixture);

    fixture->fd = connect_qga(path);
    g_assert_cmpint(fixture->fd, !=, -1);

    g_strfreev(argv);
    g_free(cmd);
    g_free(cwd);
    g_free(path);
}
Example #19
0
/**
 * Tests sampler wrapper class reference counting.
 * */
static void ref_unref_test() {

	/* Test variables. */
	CCLContext* ctx = NULL;
	CCLSampler* s = NULL;
	GError* err = NULL;

	/* Get the test context with the pre-defined device. */
	ctx = ccl_test_context_new(&err);
	g_assert_no_error(err);

	/* Create sampler. */
	s = ccl_sampler_new(ctx, CL_TRUE, CL_ADDRESS_CLAMP,
		CL_FILTER_NEAREST, &err);
	g_assert_no_error(err);

	/* Increase sampler reference count. */
	ccl_sampler_ref(s);

	/* Check that sampler ref count is 2. */
	g_assert_cmpuint(2, ==, ccl_wrapper_ref_count((CCLWrapper*) s));

	/* Unref sampler. */
	ccl_sampler_unref(s);

	/* Check that sampler ref count is 1. */
	g_assert_cmpuint(1, ==, ccl_wrapper_ref_count((CCLWrapper*) s));

	/* Destroy stuff. */
	ccl_sampler_unref(s);
	ccl_context_destroy(ctx);

	/* Confirm that memory allocated by wrappers has been properly
	 * freed. */
	g_assert(ccl_wrapper_memcheck());
}
Example #20
0
/**
 * Tests creation (using "full" constructor), getting info from and
 * destruction of sampler wrapper objects.
 * */
static void create_full_info_destroy_test() {

	/* Test variables. */
	CCLContext* ctx = NULL;
	CCLSampler* s = NULL;
	const cl_sampler_properties sampler_properties[] = {
		CL_SAMPLER_NORMALIZED_COORDS, CL_FALSE,
		CL_SAMPLER_ADDRESSING_MODE, CL_ADDRESS_CLAMP_TO_EDGE,
		CL_SAMPLER_FILTER_MODE, CL_FILTER_NEAREST,
		0};

	GError* err = NULL;

	/* Get the test context with the pre-defined device. */
	ctx = ccl_test_context_new(&err);
	g_assert_no_error(err);

	/* Create sampler using "full" constructor. */
	s = ccl_sampler_new_full(ctx, sampler_properties, &err);
	g_assert_no_error(err);

	/* Get some info and check if the return value is as expected. */
	cl_addressing_mode am;
	am = ccl_sampler_get_info_scalar(
		s, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode, &err);
	g_assert_no_error(err);
	g_assert_cmpuint(am, ==, CL_ADDRESS_CLAMP_TO_EDGE);

	cl_filter_mode fm;
	fm = ccl_sampler_get_info_scalar(
		s, CL_SAMPLER_FILTER_MODE, cl_filter_mode, &err);
	g_assert_no_error(err);
	g_assert_cmpuint(fm, ==, CL_FILTER_NEAREST);

	cl_bool nc;
	nc = ccl_sampler_get_info_scalar(
		s, CL_SAMPLER_NORMALIZED_COORDS, cl_bool, &err);
	g_assert_no_error(err);
	g_assert_cmpuint(nc, ==, CL_FALSE);

	cl_context context;
	context = ccl_sampler_get_info_scalar(
		s, CL_SAMPLER_CONTEXT, cl_context, &err);
	g_assert_no_error(err);
	g_assert_cmphex(GPOINTER_TO_UINT(context), ==,
		GPOINTER_TO_UINT(ccl_context_unwrap(ctx)));

	/* Destroy sampler. */
	ccl_sampler_destroy(s);
	ccl_context_destroy(ctx);

	/* Confirm that memory allocated by wrappers has been properly
	 * freed. */
	g_assert(ccl_wrapper_memcheck());

}
static void
test2_insert_cb (GObject      *object,
                 GAsyncResult *result,
                 gpointer      user_data)
{
   MongoCollection *col = (MongoCollection *)object;
   gboolean *success = user_data;
   GError *error = NULL;

   *success = mongo_collection_insert_finish(col, result, &error);
   g_assert_no_error(error);
   g_assert(*success);

   g_main_loop_quit(gMainLoop);
}
Example #22
0
static void
pv_split(void) {
    char *pkg = NULL;
    CPVersion version = NULL;
    GError *error = NULL;
    gboolean success = cp_atom_pv_split("foo-1.0-r1", &pkg, &version, &error);

    g_assert_no_error(error);
    g_assert(success);
    g_assert_cmpstr(pkg, ==, "foo");
    g_assert(version != NULL);
    g_assert_cmpstr(cp_version_str(version), ==, "1.0-r1");
    g_free(pkg);
    cp_version_unref(version);
}
Example #23
0
static const gchar *
read_file (const gchar *uri)
{
	GFile *file = g_file_new_for_commandline_arg (uri);
	GError *error = NULL;
	static gchar buffer[4096];
	gsize read;

	GInputStream *stream = G_INPUT_STREAM (g_file_read (file, NULL, &error));

	g_assert_no_error (error);

	g_input_stream_read_all (stream, buffer, sizeof (buffer) - 1, &read, NULL, &error);
	g_assert_no_error (error);

	buffer[read] = '\0';

	g_input_stream_close (stream, NULL, NULL);

	g_object_unref (stream);
	g_object_unref (file);

	return buffer;
}
Example #24
0
static void
test_query_events (void)
{
	GDataFeed *feed, *calendar_feed;
	GDataClientLoginAuthorizer *authorizer;
	GDataCalendarCalendar *calendar;
	GDataCalendarService *service;
	GList *calendars;
	GError *error = NULL;

	authorizer = gdata_client_login_authorizer_new (CLIENT_ID, GDATA_TYPE_CALENDAR_SERVICE);
	service = gdata_calendar_service_new (GDATA_AUTHORIZER (authorizer));

	/* Log in */
	gdata_client_login_authorizer_authenticate (authorizer, USERNAME, PASSWORD, NULL, &error);
	g_assert_no_error (error);

	/* Get a calendar */
	calendar_feed = gdata_calendar_service_query_own_calendars (service, NULL, NULL, NULL, NULL, &error);
	g_assert_no_error (error);

	calendars = gdata_feed_get_entries (calendar_feed);
	calendar = calendars->data;

	g_object_ref (calendar);
	g_object_unref (calendar_feed);

	/* Get the entry feed */
	feed = gdata_calendar_service_query_events (service, calendar, NULL, NULL, NULL, NULL, &error);
	g_assert_no_error (error);

	g_object_unref (feed);
	g_object_unref (calendar);
	g_object_unref (service);
	g_object_unref (authorizer);
}
Example #25
0
gchar *
get_keyid (GFile *gpg_home)
{
  g_autoptr(GFile) keyid = g_file_get_child (gpg_home, "keyid");
  g_autoptr(GBytes) bytes = NULL;
  g_autoptr(GError) error = NULL;
  gsize len;

  load_to_bytes (keyid, &bytes, &error);
  g_assert_no_error (error);
  len = g_bytes_get_size (bytes);
  g_assert (len == 8);

  return g_strndup (g_bytes_get_data (bytes, NULL), len);
}
void
test_setup_tmdb (void)
{
  GrlConfig *config;
  GrlRegistry *registry;
  GError *error = NULL;

  config = grl_config_new (TMDB_PLUGIN_ID, NULL);
  /* It does not matter what we set this to. It just needs to be non-empty because we're
   * going to fake the network responses. */
  grl_config_set_api_key (config, "TMDB_TEST_API_KEY");

  registry = grl_registry_get_default ();
  grl_registry_add_config (registry, config, &error);
  g_assert_no_error (error);

  grl_registry_load_plugin_by_id (registry, TMDB_PLUGIN_ID, &error);
  g_assert_no_error (error);

  source = GRL_SOURCE (grl_registry_lookup_source (registry, TMDB_PLUGIN_ID));
  g_assert (source != NULL);

  g_assert (grl_source_supported_operations (source) & GRL_OP_RESOLVE);
}
Example #27
0
static void
account_manager_prepare_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  GError *error = NULL;
  GtkWidget *window;

  tp_proxy_prepare_finish (source, result, &error);
  g_assert_no_error (error);

  window = empathy_log_window_show (NULL, NULL, FALSE, NULL);

  g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), NULL);
}
Example #28
0
/**
 * @internal
 *
 * @brief Tests map/unmap operations in buffer objects.
 * */
static void map_unmap_test() {

    /* Test variables. */
    CCLContext * ctx = NULL;
    CCLDevice * d = NULL;
    CCLBuffer * b = NULL;
    CCLQueue * q;
    cl_uint h_in[CCL_TEST_BUFFER_SIZE];
    cl_uint * h_out;
    size_t buf_size = sizeof(cl_uint) * CCL_TEST_BUFFER_SIZE;
    CCLErr * err = NULL;

    /* Create a host array, put some stuff in it. */
    for (guint i = 0; i < CCL_TEST_BUFFER_SIZE; ++i)
        h_in[i] = g_test_rand_int();

    /* Get the test context with the pre-defined device. */
    ctx = ccl_test_context_new(&err);
    g_assert_no_error(err);

    /* Get first device in context. */
    d = ccl_context_get_device(ctx, 0, &err);
    g_assert_no_error(err);

    /* Create a command queue. */
    q = ccl_queue_new(ctx, d, 0, &err);
    g_assert_no_error(err);

    /* Create regular buffer and write data from the host buffer. */
    b = ccl_buffer_new(
        ctx, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, buf_size, h_in, &err);
    g_assert_no_error(err);

    /* Map buffer onto host memory. */
    h_out = ccl_buffer_enqueue_map(
        b, q, CL_TRUE, CL_MAP_READ, 0, buf_size, NULL, NULL, &err);
    g_assert_no_error(err);

    /* Check data is OK. */
    for (guint i = 0; i < CCL_TEST_BUFFER_SIZE; ++i)
        g_assert_cmpuint(h_in[i], ==, h_out[i]);

    /* Unmap buffer. */
    ccl_memobj_enqueue_unmap(
        (CCLMemObj *) b, q, h_out, NULL, &err);
    g_assert_no_error(err);

    /* Free stuff. */
    ccl_buffer_destroy(b);
    ccl_queue_destroy(q);
    ccl_context_destroy(ctx);

    /* Confirm that memory allocated by wrappers has been properly
     * freed. */
    g_assert(ccl_wrapper_memcheck());
}
Example #29
0
/**
 * Tests buffer wrapper class reference counting.
 * */
static void buffer_ref_unref_test() {

	/* Test variables. */
	CCLContext* ctx = NULL;
	CCLBuffer* b = NULL;
	GError* err = NULL;
	size_t buf_size = sizeof(cl_uint) * CCL_TEST_BUFFER_SIZE;

	/* Get a context with any device. */
	ctx = ccl_context_new_any(&err);
	g_assert_no_error(err);

	/* Create regular buffer. */
	b = ccl_buffer_new(ctx, CL_MEM_READ_WRITE, buf_size, NULL, &err);
	g_assert_no_error(err);

	/* Increase buffer reference count. */
	ccl_memobj_ref(b);

	/* Check that buffer ref count is 2. */
	g_assert_cmpuint(2, ==, ccl_wrapper_ref_count((CCLWrapper*) b));

	/* Unref buffer. */
	ccl_buffer_unref(b);

	/* Check that buffer ref count is 1. */
	g_assert_cmpuint(1, ==, ccl_wrapper_ref_count((CCLWrapper*) b));

	/* Destroy stuff. */
	ccl_buffer_unref(b);
	ccl_context_destroy(ctx);

	/* Confirm that memory allocated by wrappers has been properly
	 * freed. */
	g_assert(ccl_wrapper_memcheck());
}
static void
test_unload (void)
{
  GrlRegistry *registry;
  GError *error = NULL;
  gchar *db_path;

  registry = grl_registry_get_default ();
  grl_registry_unload_plugin (registry, THETVDB_ID, &error);
  g_assert_no_error (error);

  /* Remove grl-thetvdb database to avoid unecessary grow of tmpdir */
  db_path = g_build_filename (tmp_dir, "grilo-plugins", "grl-thetvdb.db", NULL);
  g_remove (db_path);
  g_free (db_path);
}