Beispiel #1
0
static void
test_delete_reference_property(gs_grid_storage_t * gs)
{
	char **prop_array = parameters_init();
	char *nameRef = test_init(gs, "Ref_params", prop_array);
	char *deleted_key[] = { prop_array[0], NULL };
	char *keys[] = { prop_array[0], prop_array[1], NULL };
	gchar **result = NULL;

	gs_error_t *err = hc_delete_reference_property(gs, nameRef, deleted_key);

	if (err == NULL) {
		hc_get_reference_property(gs, nameRef, keys, &result);
		g_assert_true(result[1] == NULL);
		g_assert_true(strstr(result[0], prop_array[3]) != NULL);
	}
	else
		g_test_fail();

	parameters_delete(prop_array);
	test_end(gs, nameRef, NULL);
}
Beispiel #2
0
static void
test_set_container_quota(gs_grid_storage_t * gs)
{
	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	gs_error_t *err2 = hc_set_container_quota(container, "test");

	g_assert_true(err2 == NULL);

	test_end(gs, nameRef, container);
}
Beispiel #3
0
void test_train_moves_trailing_car_onto_track(test_train_context* test_ctx, const void* data) {
#pragma unused(data)

    sem_world* world = &(test_ctx->world);
    sem_train* train = test_ctx->train;

    sem_track track_E_W;
    sem_track_set(&track_E_W, SEM_EAST, SEM_WEST);

    sem_track track_W_S;
    sem_track_set(&track_W_S, SEM_WEST, SEM_SOUTH);

    sem_track track_N_S;
    sem_track_set(&track_N_S, SEM_NORTH, SEM_SOUTH);

    sem_tile_set_track(sem_tile_at(world, 0, 0), &track_E_W);
    sem_tile_set_track(sem_tile_at(world, 1, 0), &track_W_S);
    sem_tile_set_track(sem_tile_at(world, 1, 1), &track_N_S);

    train->state = MOVING;
    train->direction = SEM_SOUTH;

    sem_car car1;
    sem_coordinate_set(&(car1.position), 1, 0);
    car1.track = &track_W_S;

    sem_car car2;
    sem_coordinate_set(&(car2.position), 0, 0);
    car2.track = &track_E_W;

    sem_train_add_car(train, &car1);
    sem_train_add_car(train, &car2);

    sem_train_move_outcome outcome;
    sem_train_move(train, &outcome);

    g_assert_true(train->head_car->track == &track_N_S);
    g_assert_true(train->head_car->next->track == &track_W_S);
}
void test_dynamic_array_remove_item(sem_dynamic_array* a, const void* data) {
	#pragma unused(data)

	char* item1 = "hello";
	char* item2 = "world";

	sem_dynamic_array_add(a, item1);
	sem_dynamic_array_add(a, item2);
	sem_dynamic_array_remove(a, item1);

	g_assert_cmpuint(a->tail_idx, ==, 1);
	g_assert_true(a->items[0] == item2);
}
Beispiel #5
0
static void
_adg_behavior_entity(void)
{
    AdgCanvas *canvas;
    const CpmlExtents *extents;
    AdgTitleBlock *title_block;

    canvas = ADG_CANVAS(adg_test_canvas());

    adg_entity_arrange(ADG_ENTITY(canvas));
    extents = adg_entity_get_extents(ADG_ENTITY(canvas));
    g_assert_true(extents->is_defined);
    adg_assert_isapprox(extents->size.x, 1);
    adg_assert_isapprox(extents->size.y, 1);

    adg_entity_invalidate(ADG_ENTITY(canvas));
    extents = adg_entity_get_extents(ADG_ENTITY(canvas));
    g_assert_false(extents->is_defined);

    title_block = adg_title_block_new();
    adg_canvas_set_title_block(canvas, title_block);
    adg_entity_arrange(ADG_ENTITY(canvas));
    extents = adg_entity_get_extents(ADG_ENTITY(canvas));
    g_assert_true(extents->is_defined);
    g_assert_cmpfloat(extents->size.x, >, 1);
    g_assert_cmpfloat(extents->size.y, >, 1);
    g_assert_cmpfloat(extents->size.x, <, 5000);
    g_assert_cmpfloat(extents->size.y, <, 5000);

    adg_canvas_set_size_explicit(canvas, 5000, 5000);
    adg_entity_arrange(ADG_ENTITY(canvas));
    extents = adg_entity_get_extents(ADG_ENTITY(canvas));
    g_assert_true(extents->is_defined);
    adg_assert_isapprox(extents->size.x, 5000);
    adg_assert_isapprox(extents->size.y, 5000);

    adg_entity_destroy(ADG_ENTITY(canvas));
}
Beispiel #6
0
static void
_adg_property_has_extension2(void)
{
    AdgADim *adim;
    gboolean invalid_boolean;
    gboolean has_extension2;

    adim = adg_adim_new();
    invalid_boolean = (gboolean) 1234;

    /* Using the public APIs */
    adg_adim_switch_extension2(adim, FALSE);
    has_extension2 = adg_adim_has_extension2(adim);
    g_assert_false(has_extension2);

    adg_adim_switch_extension2(adim, invalid_boolean);
    has_extension2 = adg_adim_has_extension2(adim);
    g_assert_false(has_extension2);

    adg_adim_switch_extension2(adim, TRUE);
    has_extension2 = adg_adim_has_extension2(adim);
    g_assert_true(has_extension2);

    /* Using GObject property methods */
    g_object_set(adim, "has-extension2", FALSE, NULL);
    g_object_get(adim, "has-extension2", &has_extension2, NULL);
    g_assert_false(has_extension2);

    g_object_set(adim, "has-extension2", invalid_boolean, NULL);
    g_object_get(adim, "has-extension2", &has_extension2, NULL);
    g_assert_false(has_extension2);

    g_object_set(adim, "has-extension2", TRUE, NULL);
    g_object_get(adim, "has-extension2", &has_extension2, NULL);
    g_assert_true(has_extension2);

    adg_entity_destroy(ADG_ENTITY(adim));
}
void test_mod_color(lfFixture *lfFix, gconstpointer data)
{
  lfTestParams *p = (lfTestParams *)data;

  for(size_t y = 0; y < lfFix->img_height; y++)
  {
    T *imgdata = (T *)lfFix->image + (size_t)p->cpp * y * lfFix->img_width;

    g_assert_true(
      lfFix->mod->ApplyColorModification(
        imgdata, 0.0, y, lfFix->img_width, 1,
        p->comp_role, p->cpp * lfFix->img_width));
  }
}
Beispiel #8
0
char *
frida_test_process_backend_filename_of (void * handle)
{
#ifdef HAVE_QNX
  g_assert_true (handle == &frida_magic_self_handle);

  struct dlopen_handle ** _handle = dlopen (NULL, RTLD_LAZY);
  struct dlopen_handle * p_u = *(_handle);

  return g_strdup (p_u->p_lm->l_path);
#else
  return g_file_read_link ("/proc/self/exe", NULL);
#endif
}
Beispiel #9
0
static void test_str2bool()
{
	int err;
	bool value;

	err = str2bool("yes", &value);
	g_assert_cmpint(err, ==, 0);
	g_assert_true(value);

	err = str2bool("1", &value);
	g_assert_cmpint(err, ==, 0);
	g_assert_true(value);

	err = str2bool("no", &value);
	g_assert_cmpint(err, ==, 0);
	g_assert_false(value);

	err = str2bool("0", &value);
	g_assert_cmpint(err, ==, 0);
	g_assert_false(value);

	err = str2bool("", &value);
	g_assert_cmpint(err, ==, 0);
	g_assert_false(value);

	err = str2bool(NULL, &value);
	g_assert_cmpint(err, ==, 0);
	g_assert_false(value);

	err = str2bool("flower", &value);
	g_assert_cmpint(err, ==, -1);
	g_assert_cmpint(errno, ==, EINVAL);

	err = str2bool("yes", NULL);
	g_assert_cmpint(err, ==, -1);
	g_assert_cmpint(errno, ==, EFAULT);
}
Beispiel #10
0
/*
static void
test_delete_content_property(gs_grid_storage_t * gs)
{
	gs_error_t **err = NULL;
	gchar **result = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *nameContent =
		gs_get_content_from_path(container, "Content", err);

	char *props[] = { "key1=value1", "key2=value2", NULL };
	char *propDel[] = { "key1", NULL };
	hc_set_content_property(nameContent, props, err);

	hc_delete_content_property(nameContent, propDel, err);
	g_assert_true(err == NULL);

	hc_get_content_properties(nameContent, &result, err);
	g_assert_true(err == NULL);
	if (result == NULL)
		g_test_fail();
	else
		g_assert_true(strcmp(result[0], "key2=value2") == 0);

	gs_content_free(nameContent);
	test_end(gs, nameRef, container);
}
*/
static void
test_copy_content(gs_grid_storage_t * gs)
{
	gs_error_t **err = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *nameContent =
		gs_get_content_from_path(container, "Content", err);

	hc_copy_content(container, "Content", "Content_copy", err);
	g_assert_true(err == NULL);

	gs_content_t *nameContent2 =
		gs_get_content_from_path(container, "Content_copy", err);
	g_assert_true(nameContent != NULL);

	gs_content_free(nameContent);
	gs_content_free(nameContent2);
	test_end(gs, nameRef, container);
}
static void
test_queue_stalled (void)
{
	struct oio_events_queue_s *q =
		oio_events_queue_factory__create_agent ("inproc://X", 100);
	g_assert_nonnull (q);

	g_assert_false (oio_events_queue__is_stalled (q));
	for (guint i=0; i<100 ;++i)
		oio_events_queue__send (q, g_strdup ("x"));

	/* XXX(jfs): ugly way to give a chance to the internal thread to consume
	   events and update counters. */
	g_thread_yield ();
	g_usleep (100 * G_TIME_SPAN_MILLISECOND);

	g_assert_true (oio_events_queue__is_stalled (q));
	for (guint i=0; i<1000 ;++i)
		oio_events_queue__send (q, g_strdup ("x"));
	g_assert_true (oio_events_queue__is_stalled (q));

	oio_events_queue__run_agent (q, immediately_done);
	oio_events_queue__destroy (q);
}
/* The hierarchy looks like this:
 * /tmp/first_dir/first_child/second_child
 * /tmp/second_dir
 * We're copying first_dir to second_dir.
 */
static void
test_copy_second_hierarchy (void)
{
    g_autoptr (GFile) root = NULL;
    g_autoptr (GFile) first_dir = NULL;
    g_autoptr (GFile) second_dir = NULL;
    g_autoptr (GFile) file = NULL;
    g_autoptr (GFile) result_file = NULL;
    g_autolist (GFile) files = NULL;

    create_second_hierarchy ("copy");

    root = g_file_new_for_path (g_get_tmp_dir ());
    first_dir = g_file_get_child (root, "copy_first_dir");
    files = g_list_prepend (files, g_object_ref (first_dir));
    g_assert_true (first_dir != NULL);

    file = g_file_get_child (first_dir, "copy_first_child");
    g_assert_true (file != NULL);
    file = g_file_get_child (file, "copy_second_child");
    g_assert_true (file != NULL);

    second_dir = g_file_get_child (root, "copy_second_dir");
    g_assert_true (second_dir != NULL);

    nautilus_file_operations_copy_sync (files,
                                        second_dir);

    result_file = g_file_get_child (second_dir, "copy_first_dir");
    g_assert_true (g_file_query_exists (result_file, NULL));
    file = g_file_get_child (result_file, "copy_first_child");
    g_assert_true (g_file_query_exists (file, NULL));

    file = g_file_get_child (file, "copy_second_child");
    g_assert_true (g_file_query_exists (file, NULL));

    file = g_file_get_child (result_file, "copy_first_child");
    g_assert_true (g_file_query_exists (file, NULL));

    file = g_file_get_child (first_dir, "copy_first_child");
    file = g_file_get_child (file, "copy_second_child");

    file = g_file_get_child (first_dir, "copy_first_child");

    empty_directory_by_prefix (root, "copy");
}
void test_mod_color_parallel(lfFixture *lfFix, gconstpointer data)
{
  const lfTestParams *const p = (lfTestParams *)data;

  #pragma omp parallel for schedule(static)
  for(size_t y = 0; y < lfFix->img_height; y++)
  {
    T *imgdata = (T *)lfFix->image + (size_t)p->cpp * y * lfFix->img_width;

    g_assert_true(
      lfFix->mod->ApplyColorModification(
        imgdata, 0.0, y, lfFix->img_width, 1,
        p->comp_role, p->cpp * lfFix->img_width));
  }
}
Beispiel #14
0
static void signature_loopback(void)
{
	GBytes *content = read_file("test/openssl-ca/manifest", NULL);
	GBytes *sig = NULL;
	g_assert_nonnull(content);
	sig = cms_sign(content,
		       r_context()->certpath,
		       r_context()->keypath,
		       NULL);
	g_assert_nonnull(sig);
	g_assert_true(cms_verify(content, sig, NULL));
	((char *)g_bytes_get_data(content, NULL))[0] = 0x00;
	g_assert_false(cms_verify(content, sig, NULL));
	g_bytes_unref(content);
	g_bytes_unref(sig);
}
Beispiel #15
0
void test_train_second_car_occupies_tile(test_train_context* test_ctx, const void* data) {
#pragma unused(data)
    sem_train* train = test_ctx->train;

    sem_car head_car;
    sem_coordinate_set(&(head_car.position), 2, 0);
    sem_train_add_car(train, &head_car);

    sem_coordinate second_car_position;
    sem_coordinate_set(&second_car_position, 1, 0);
    sem_car second_car;
    second_car.position = second_car_position;
    sem_train_add_car(train, &second_car);

    g_assert_true(sem_train_occupies(train, &second_car_position));
}
Beispiel #16
0
static void
_adg_property_factor(void)
{
    AdgAlignment *alignment;
    CpmlPair null_factor, identity_factor;
    const CpmlPair *factor;
    CpmlPair *factor_dup;

    alignment = adg_alignment_new(NULL);
    null_factor.x = 0;
    null_factor.y = 0;
    identity_factor.x = 1;
    identity_factor.y = 1;

    /* By default, the alignment should be initialized with a null factor */
    factor = adg_alignment_get_factor(alignment);
    g_assert_true(cpml_pair_equal(factor, &null_factor));

    /* Using the public APIs */
    adg_alignment_set_factor(alignment, &identity_factor);
    factor = adg_alignment_get_factor(alignment);
    g_assert_true(cpml_pair_equal(factor, &identity_factor));

    adg_alignment_set_factor_explicit(alignment, 0, 0);
    factor = adg_alignment_get_factor(alignment);
    g_assert_true(cpml_pair_equal(factor, &null_factor));

    adg_alignment_set_factor(alignment, NULL);
    factor = adg_alignment_get_factor(alignment);
    g_assert_true(cpml_pair_equal(factor, &null_factor));

    /* Using GObject property methods */
    g_object_set(alignment, "factor", &identity_factor, NULL);
    g_object_get(alignment, "factor", &factor_dup, NULL);
    g_assert_true(cpml_pair_equal(factor_dup, &identity_factor));
    g_free(factor_dup);

    g_object_set(alignment, "factor", NULL, NULL);
    g_object_get(alignment, "factor", &factor_dup, NULL);
    g_assert_true(cpml_pair_equal(factor_dup, &identity_factor));
    g_free(factor_dup);

    g_object_set(alignment, "factor", &null_factor, NULL);
    g_object_get(alignment, "factor", &factor_dup, NULL);
    g_assert_true(cpml_pair_equal(factor_dup, &null_factor));
    g_free(factor_dup);

    g_object_unref(alignment);
}
Beispiel #17
0
static void test_engine_ngspice_error_no_such_file_or_directory() {
	TestEngineNgspiceResources *test_resources = test_engine_ngspice_resources_new();

	// make sure that the given file does not exist
	g_free(test_resources->resources->netlist_file);
	gint fd = g_file_open_tmp(NULL, &test_resources->resources->netlist_file, NULL);
	g_close(fd, NULL);
	g_remove(test_resources->resources->netlist_file);

	ngspice_watcher_build_and_launch(test_resources->resources);
	g_main_loop_run(test_resources->loop);

	g_assert_nonnull(test_resources->log_list);
	g_assert_true(g_str_has_suffix(test_resources->log_list->data, " No such file or directory\n"));

	test_engine_ngspice_resources_finalize(test_resources);
}
Beispiel #18
0
static void test_wildmatch_questionmark(void)
{
    g_assert_true(util_wildmatch("wild?atch", "wildmatch"));
    g_assert_true(util_wildmatch("wild?atch", "wildBatch"));
    g_assert_true(util_wildmatch("wild?atch", "wild?atch"));
    g_assert_true(util_wildmatch("?ild?atch", "MildBatch"));
    g_assert_true(util_wildmatch("foo\\?bar", "foo?bar"));
    g_assert_true(util_wildmatch("???", "foo"));
    g_assert_true(util_wildmatch("???", "bar"));

    g_assert_false(util_wildmatch("foo\\?bar", "foorbar"));
    g_assert_false(util_wildmatch("?", ""));
    g_assert_false(util_wildmatch("b??r", "bar"));
    /* ? does not match / in contrast to * which does */
    g_assert_false(util_wildmatch("user?share", "user/share"));
}
Beispiel #19
0
static void
test_parse_bin(StateWrapper *wrapper, gconstpointer user_data)
{
    guchar buffer[] = { 0x00, 0x06, 0x00, 0x73, 0x6f, 0x6f, 0x73, 0x68, 0x69 };
    wrapper->state->buffer = g_byte_array_append(wrapper->state->buffer, buffer, sizeof(buffer));

    SooshiNode *node = g_new0(SooshiNode, 1);
    node->type = VAL_BIN;

    sooshi_node_bytes_to_value(node, wrapper->state->buffer, &node->value);

    g_assert_nonnull(node->value);
    g_assert_true(g_variant_is_of_type(node->value, G_VARIANT_TYPE_BYTESTRING));
    const gchar *mem = g_variant_get_bytestring(node->value);
    g_assert_cmpmem(mem, strlen(mem), buffer + 3, sizeof(buffer) - 3);

    g_free(node);
}
Beispiel #20
0
static void
_cpml_behavior_browsing(void)
{
    CpmlSegment segment;
    CpmlPrimitive primitive, primitive_copy;

    cpml_segment_from_cairo(&segment, (cairo_path_t *) adg_test_path());

    cpml_primitive_from_segment(&primitive, &segment);
    adg_assert_isapprox((primitive.org)->point.x, 0);
    adg_assert_isapprox((primitive.org)->point.y, 1);
    g_assert_cmpint((primitive.data)->header.type, ==, CPML_LINE);
    g_assert_true(cpml_primitive_next(&primitive));
    adg_assert_isapprox((primitive.org)->point.x, 3);
    adg_assert_isapprox((primitive.org)->point.y, 1);
    g_assert_cmpint((primitive.data)->header.type, ==, CPML_ARC);
    g_assert_true(cpml_primitive_next(&primitive));
    adg_assert_isapprox((primitive.org)->point.x, 6);
    adg_assert_isapprox((primitive.org)->point.y, 7);
    g_assert_cmpint((primitive.data)->header.type, ==, CPML_CURVE);
    g_assert_true(cpml_primitive_next(&primitive));
    adg_assert_isapprox((primitive.org)->point.x, -2);
    adg_assert_isapprox((primitive.org)->point.y, 2);
    g_assert_cmpint((primitive.data)->header.type, ==, CPML_CLOSE);
    g_assert_false(cpml_primitive_next(&primitive));

    cpml_primitive_reset(&primitive);
    g_assert_true(cpml_primitive_next(&primitive));
    cpml_primitive_reset(&primitive);
    cpml_primitive_reset(&primitive);
    g_assert_true(cpml_primitive_next(&primitive));
    g_assert_true(cpml_primitive_next(&primitive));
    g_assert_true(cpml_primitive_next(&primitive));
    g_assert_false(cpml_primitive_next(&primitive));

    cpml_primitive_copy(&primitive_copy, &primitive);
    g_assert_false(cpml_primitive_next(&primitive_copy));
    cpml_primitive_reset(&primitive);
    g_assert_false(cpml_primitive_next(&primitive_copy));
    cpml_primitive_reset(&primitive_copy);
    g_assert_true(cpml_primitive_next(&primitive_copy));
}
Beispiel #21
0
static void
_round_init (void)
{
	sqlx_repository_t *repo = NULL;
	GError *err;

	err = sqlx_repository_init("/tmp", NULL, &repo);
	g_assert_no_error (err);
	for (int i=0; i<5 ;i++)
		sqlx_repository_set_locator (repo, _locator, NULL);
	for (int i=0; i<5 ;i++)
		g_assert_true (sqlx_repository_running (repo));
	for (int i=0; i<5 ;i++) {
		err = sqlx_repository_configure_type(repo, type, SCHEMA);
		g_assert_no_error (err);
	}
	sqlx_repository_clean(repo);
}
Beispiel #22
0
static void check(int a, int b, bool expected)
{
    struct qht_stats stats;
    int i;

    for (i = a; i < b; i++) {
        void *p;
        uint32_t hash;
        int32_t val;

        val = i;
        hash = i;
        p = qht_lookup(&ht, is_equal, &val, hash);
        g_assert_true(!!p == expected);
    }
    qht_statistics_init(&ht, &stats);
    if (stats.used_head_buckets) {
        g_assert_cmpfloat(qdist_avg(&stats.chain), >=, 1.0);
    }
Beispiel #23
0
char *
frida_test_process_backend_filename_of (void * handle)
{
  guint image_count, image_idx;

  g_assert_true (handle == &frida_magic_self_handle);

  image_count = _dyld_image_count ();
  for (image_idx = 0; image_idx != image_count; image_idx++)
  {
    const gchar * image_path = _dyld_get_image_name (image_idx);

    if (g_str_has_suffix (image_path, "/frida-tests"))
      return g_strdup (image_path);
  }

  g_assert_not_reached ();
  return NULL;
}
Beispiel #24
0
static void
_adg_method_toggle_button_sensitivize(void)
{
    GtkToggleButton *button = (GtkToggleButton *) gtk_toggle_button_new();
    GtkWidget *widget = gtk_toggle_button_new();

    gtk_toggle_button_set_active(button, FALSE);
    adg_gtk_toggle_button_sensitivize(button, widget);
    g_assert_false(gtk_widget_get_sensitive(widget));

    gtk_toggle_button_set_active(button, TRUE);
    adg_gtk_toggle_button_sensitivize(button, widget);
    g_assert_true(gtk_widget_get_sensitive(widget));

    g_object_ref_sink(button);
    g_object_unref(button);

    g_object_ref_sink(widget);
    g_object_unref(widget);
}
Beispiel #25
0
static void
check_new (GAsyncResult    *res,
           GError         **expected_error,
           GIOStream       *expected_stream,
           GSocketAddress  *expected_address)
{
  GarilConnection *connection =
    garil_connection_new_finish (res, expected_error);
  if (expected_error != NULL) {
    g_assert_null (connection);
    g_assert_nonnull (*expected_error);
    return;
  }

  g_assert_true (GARIL_IS_CONNECTION (connection));

  check_stream_address_flags (connection, expected_stream, expected_address);

  g_object_unref (connection);
}
Beispiel #26
0
static void
fu_wac_firmware_parse_func (void)
{
	DfuElement *element;
	DfuImage *image;
	gboolean ret;
	g_autofree gchar *fn = NULL;
	g_autoptr(DfuFirmware) firmware = dfu_firmware_new ();
	g_autoptr(GBytes) blob_block = NULL;
	g_autoptr(GBytes) bytes = NULL;
	g_autoptr(GError) error = NULL;

	/* parse the test file */
	fn = fu_test_get_filename (TESTDATADIR, "test.wac");
	if (fn == NULL) {
		g_test_skip ("no data file found");
		return;
	}
	bytes = fu_common_get_contents_bytes (fn, &error);
	g_assert_no_error (error);
	g_assert_nonnull (bytes);
	ret = fu_wac_firmware_parse_data (firmware, bytes,
					  DFU_FIRMWARE_PARSE_FLAG_NONE, &error);
	g_assert_no_error (error);
	g_assert_true (ret);

	/* get image data */
	image = dfu_firmware_get_image (firmware, 0);
	g_assert_nonnull (image);
	element = dfu_image_get_element_default (image);
	g_assert_nonnull (element);

	/* get block */
	blob_block = dfu_element_get_contents_chunk (element, 0x8008000,
						     1024, &error);
	g_assert_no_error (error);
	g_assert_nonnull (blob_block);
	fu_wac_buffer_dump ("IMG", FU_WAC_REPORT_ID_MODULE,
			    g_bytes_get_data (blob_block, NULL),
			    g_bytes_get_size (blob_block));
}
Beispiel #27
0
static void
test_parse_uint32(StateWrapper *wrapper, gconstpointer user_data)
{
    guchar buffer[] = { 0x00, 0x12, 0x34, 0x56, 0x78 };
    wrapper->state->buffer = g_byte_array_append(wrapper->state->buffer, buffer, sizeof(buffer));

    SooshiNode *node = g_new0(SooshiNode, 1);
    node->type = VAL_U32;

    sooshi_node_bytes_to_value(node, wrapper->state->buffer, &node->value);

    g_assert_nonnull(node->value);
    g_assert_true(g_variant_is_of_type(node->value, G_VARIANT_TYPE_UINT32));
    g_assert_cmpuint(g_variant_get_uint32(node->value), ==, (guint32) 0x78563412);

    guchar buffer2[4];
    gint length = sooshi_node_value_to_bytes(node, buffer2);
    g_assert_cmpint(length, ==, sizeof(buffer2));
    g_assert_cmpmem(buffer2, length, buffer + 1, sizeof(buffer) - 1); 

    g_free(node);
}
Beispiel #28
0
static void
test_parse_chooser(StateWrapper *wrapper, gconstpointer user_data)
{
    guchar buffer[] = { 0x00, 0x06 };
    wrapper->state->buffer = g_byte_array_append(wrapper->state->buffer, buffer, sizeof(buffer));

    SooshiNode *node = g_new0(SooshiNode, 1);
    node->type = CHOOSER;

    sooshi_node_bytes_to_value(node, wrapper->state->buffer, &node->value);

    g_assert_nonnull(node->value);
    g_assert_true(g_variant_is_of_type(node->value, G_VARIANT_TYPE_BYTE));
    g_assert_cmpuint(g_variant_get_byte(node->value), ==, 0x06);

    guchar buffer2[1];
    gint length = sooshi_node_value_to_bytes(node, buffer2);
    g_assert_cmpint(length, ==, sizeof(buffer2));
    g_assert_cmpmem(buffer2, length, buffer + 1, sizeof(buffer) - 1); 

    g_free(node);
}
Beispiel #29
0
static void
test_parse_str(StateWrapper *wrapper, gconstpointer user_data)
{
    guchar buffer[] = { 0x00, 0x06, 0x00, 0x73, 0x6f, 0x6f, 0x73, 0x68, 0x69 };
    wrapper->state->buffer = g_byte_array_append(wrapper->state->buffer, buffer, sizeof(buffer));

    SooshiNode *node = g_new0(SooshiNode, 1);
    node->type = VAL_STR;

    sooshi_node_bytes_to_value(node, wrapper->state->buffer, &node->value);

    g_assert_nonnull(node->value);
    g_assert_true(g_variant_is_of_type(node->value, G_VARIANT_TYPE_STRING));
    g_assert_cmpstr(g_variant_get_string(node->value, NULL), ==, "sooshi");

    guchar buffer2[8];
    gint length = sooshi_node_value_to_bytes(node, buffer2);
    g_assert_cmpint(length, ==, sizeof(buffer2));
    g_assert_cmpmem(buffer2, length, buffer + 1, sizeof(buffer) - 1); 

    g_free(node);
}
Beispiel #30
0
static void
test_parse_int16(StateWrapper *wrapper, gconstpointer user_data)
{
    guchar buffer[] = { 0x00, 0xAB, 0xCD };
    wrapper->state->buffer = g_byte_array_append(wrapper->state->buffer, buffer, sizeof(buffer));

    SooshiNode *node = g_new0(SooshiNode, 1);
    node->type = VAL_S16;

    sooshi_node_bytes_to_value(node, wrapper->state->buffer, &node->value);

    g_assert_nonnull(node->value);
    g_assert_true(g_variant_is_of_type(node->value, G_VARIANT_TYPE_INT16));
    g_assert_cmpint(g_variant_get_int16(node->value), ==, (gint16) 0xCDAB);

    guchar buffer2[2];
    gint length = sooshi_node_value_to_bytes(node, buffer2);
    g_assert_cmpint(length, ==, sizeof(buffer2));
    g_assert_cmpmem(buffer2, length, buffer + 1, sizeof(buffer) - 1); 

    g_free(node);
}