@@ -339,6 +339,35 @@ t_testbed_child_device(UMockdevTestbedFixture * fixture, gconstpointer data)
339339 g_free (input );
340340}
341341
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+
342371struct TestbedErrorCatcherData {
343372 unsigned counter ;
344373 GLogLevelFlags last_level ;
@@ -1858,6 +1887,8 @@ main(int argc, char **argv)
18581887 t_testbed_add_devicev , t_testbed_fixture_teardown );
18591888 g_test_add ("/umockdev-testbed/add_device" , UMockdevTestbedFixture , NULL , t_testbed_fixture_setup ,
18601889 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 );
18611892 g_test_add ("/umockdev-testbed/add_device_errors" , UMockdevTestbedFixture , NULL , t_testbed_fixture_setup ,
18621893 t_testbed_add_device_errors , t_testbed_fixture_teardown );
18631894 g_test_add ("/umockdev-testbed/child_device" , UMockdevTestbedFixture , NULL , t_testbed_fixture_setup ,
0 commit comments