~ubuntu-branches/debian/sid/umockdev/sid

« back to all changes in this revision

Viewing changes to tests/test-umockdev.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-09-01 12:03:28 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20140901120328-8h1fjou6oe2j5gao
Tags: 0.8.6-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
339
339
    g_free(input);
340
340
}
341
341
 
 
342
/* UMockdevTestbed add_device() with adding a block device */
 
343
static void
 
344
t_testbed_add_block_device(UMockdevTestbedFixture * fixture, gconstpointer data)
 
345
{
 
346
    gchar *syspath;
 
347
 
 
348
    syspath = umockdev_testbed_add_device(fixture->testbed, "block", "scribble", NULL,
 
349
                                          /* attributes */
 
350
                                          "size", "10000", NULL,
 
351
                                          /* properties */
 
352
                                          "ID_TYPE", "disk", NULL);
 
353
    g_assert(syspath);
 
354
    g_assert_cmpstr(syspath, ==, "/sys/devices/scribble");
 
355
 
 
356
    /* check attributes */
 
357
    g_assert(g_file_test("/sys/devices/scribble/size", G_FILE_TEST_IS_REGULAR));
 
358
    g_assert(g_file_test("/sys/devices/scribble/uevent", G_FILE_TEST_IS_REGULAR));
 
359
    g_assert(g_file_test("/sys/devices/scribble/subsystem", G_FILE_TEST_IS_SYMLINK));
 
360
 
 
361
    /* check class symlinks */
 
362
    g_assert(g_file_test("/sys/class/block/scribble", G_FILE_TEST_IS_SYMLINK));
 
363
    g_assert(g_file_test("/sys/class/block/scribble/size", G_FILE_TEST_IS_REGULAR));
 
364
 
 
365
    g_assert(g_file_test("/sys/block/scribble", G_FILE_TEST_IS_SYMLINK));
 
366
    g_assert(g_file_test("/sys/block/scribble/size", G_FILE_TEST_IS_REGULAR));
 
367
 
 
368
    g_free(syspath);
 
369
}
 
370
 
342
371
struct TestbedErrorCatcherData {
343
372
    unsigned counter;
344
373
    GLogLevelFlags last_level;
426
455
    /* int attributes */
427
456
    umockdev_testbed_set_attribute_int(fixture->testbed, syspath, "count", 1000);
428
457
    umockdev_testbed_set_attribute_hex(fixture->testbed, syspath, "addr", 0x1a01);
 
458
    /* subdir attribute */
 
459
    umockdev_testbed_set_attribute(fixture->testbed, syspath, "knobs/red", "off");
429
460
 
430
461
    device = g_udev_client_query_by_sysfs_path(client, syspath);
431
462
    g_assert(device);
434
465
    g_assert_cmpstr(g_udev_device_get_sysfs_attr(device, "color"), ==, "yellow");
435
466
    g_assert_cmpstr(g_udev_device_get_sysfs_attr(device, "count"), ==, "1000");
436
467
    g_assert_cmpstr(g_udev_device_get_sysfs_attr(device, "addr"), ==, "1a01");
 
468
    g_assert_cmpstr(g_udev_device_get_sysfs_attr(device, "knobs/red"), ==, "off");
437
469
    g_assert_cmpstr(g_udev_device_get_driver(device), ==, "hub");
438
470
    g_object_unref(device);
439
471
 
744
776
                                               "H: binary_attr=41A9FF0005FF00\n"
745
777
                                               "A: multiline_attr=a\\\\b\\nc\\\\d\\nlast\n"
746
778
                                               "A: simple_attr=1\n"
 
779
                                               "A: knobs/red=off\n"
747
780
                                               "L: driver=../../foo", &error);
748
781
    g_assert_no_error(error);
749
782
    g_assert(success);
760
793
    g_assert(g_udev_device_get_parent(device) == NULL);
761
794
    g_assert_cmpstr(g_udev_device_get_sysfs_attr(device, "simple_attr"), ==, "1");
762
795
    g_assert_cmpstr(g_udev_device_get_sysfs_attr(device, "multiline_attr"), ==, "a\\b\nc\\d\nlast");
 
796
    g_assert_cmpstr(g_udev_device_get_sysfs_attr(device, "knobs/red"), ==, "off");
763
797
    g_assert_cmpstr(g_udev_device_get_property(device, "SIMPLE_PROP"), ==, "1");
764
798
    g_assert_cmpstr(g_udev_device_get_driver(device), ==, "foo");
765
799
    g_object_unref(device);
1853
1887
               t_testbed_add_devicev, t_testbed_fixture_teardown);
1854
1888
    g_test_add("/umockdev-testbed/add_device", UMockdevTestbedFixture, NULL, t_testbed_fixture_setup,
1855
1889
               t_testbed_add_device, t_testbed_fixture_teardown);
 
1890
    g_test_add("/umockdev-testbed/add_block_device", UMockdevTestbedFixture, NULL, t_testbed_fixture_setup,
 
1891
               t_testbed_add_block_device, t_testbed_fixture_teardown);
1856
1892
    g_test_add("/umockdev-testbed/add_device_errors", UMockdevTestbedFixture, NULL, t_testbed_fixture_setup,
1857
1893
               t_testbed_add_device_errors, t_testbed_fixture_teardown);
1858
1894
    g_test_add("/umockdev-testbed/child_device", UMockdevTestbedFixture, NULL, t_testbed_fixture_setup,