On Thu, Jul 18, 2024 at 02:05:04PM -0700, Stephen Boyd wrote: > Introduce KUnit resource wrappers around platform_driver_register(), > platform_device_alloc(), and platform_device_add() so that test authors > can register platform drivers/devices from their tests and have the > drivers/devices automatically be unregistered when the test is done. > > This makes test setup code simpler when a platform driver or platform > device is needed. Add a few test cases at the same time to make sure the > APIs work as intended. > > Cc: Brendan Higgins <brendan.higgins@xxxxxxxxx> > Reviewed-by: David Gow <davidgow@xxxxxxxxxx> > Cc: Rae Moar <rmoar@xxxxxxxxxx> > Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx> > Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxx> This patch adds another intentional warning traceback seen whenever CONFIG_KUNIT_TEST is enabled. sysfs: cannot create duplicate filename '/devices/platform/kunit-platform-add-2' CPU: 0 UID: 0 PID: 421 Comm: kunit_try_catch Tainted: G N 6.11.0-mac-09967-g2ece55614b92 #1 Tainted: [N]=TEST Stack from 015a9de0: 015a9de0 006168ac 006168ac 0158c000 026e8ea0 00c4a6b8 004bbe32 006168ac 00166cd4 005fa210 0158c000 026e8ea0 ffffffef 00c4a6b8 0067a18c 00166dc0 00c4a6b8 026e8ea0 01a6ac0e 006cb3c8 01a6ac0a 006cb3c8 00000000 00000000 0049b6de 01a6ac0a 00000000 01a6ac0a 00000000 006cb3c8 01a6ac0a 006cb3c8 01a6ac0a 015a9e78 0049b8b4 01a6ac0a 01a6ac00 01a6ac0a 0001bbfa 00321592 01a6ac0a 006cb3c8 00000000 01a6ac00 00000000 0067a18c 0002d21c 00000000 Call Trace: [<004bbe32>] dump_stack+0xc/0x10 [<00166cd4>] sysfs_warn_dup+0x52/0x64 [<00166dc0>] sysfs_create_dir_ns+0x9a/0xac [<0049b6de>] kobject_add_internal+0xdc/0x238 [<0049b8b4>] kobject_add+0x7a/0x7e [<0001bbfa>] insert_resource+0x0/0x1a [<00321592>] device_add+0x104/0x588 [<0002d21c>] list_del_init+0x0/0x2a [<0001bbfa>] insert_resource+0x0/0x1a [<00326358>] platform_device_add+0x58/0x180 [<00326378>] platform_device_add+0x78/0x180 [<00273234>] IS_ERR_OR_NULL+0x0/0x1c [<00270c58>] kunit_platform_device_add+0x14/0x118 [<0002d21c>] list_del_init+0x0/0x2a [<00270c44>] kunit_platform_device_add+0x0/0x118 [<00273234>] IS_ERR_OR_NULL+0x0/0x1c [<002733de>] kunit_platform_device_add_twice_fails_test+0x118/0x170 [<00050e44>] ktime_get_ts64+0x0/0xd8 [<00050e44>] ktime_get_ts64+0x0/0xd8 [<004b04d0>] memset+0x0/0x8c [<0026cc3e>] kunit_try_run_case+0xa0/0x176 [<0002d21c>] list_del_init+0x0/0x2a [<0002cfaa>] kthread_exit+0x0/0x14 [<0026e3d0>] kunit_generic_run_threadfn_adapter+0x0/0x2a [<0026e3e6>] kunit_generic_run_threadfn_adapter+0x16/0x2a [<0002d2d6>] kthread+0x90/0x9a [<0002d246>] kthread+0x0/0x9a [<0000252c>] ret_from_kernel_thread+0xc/0x14 kobject: kobject_add_internal failed for kunit-platform-add-2 with -EEXIST, don't try to register things with the same name in the same directory. # kunit_platform_device_add_twice_fails_test: pass:1 fail:0 skip:0 total:1 ok 3 kunit_platform_device_add_twice_fails_test # kunit_platform_device_add_cleans_up: pass:1 fail:0 skip:0 total:1 ok 4 kunit_platform_device_add_cleans_up # kunit_platform_device: pass:4 fail:0 skip:0 total:4 I have said several times that my test system can and will not handle intentional warning backtraces. I strongly believe that it is wrong to expect that testbed maintainers have to keep track of intentional backtraces. That means that I now also disabled CONFIG_KUNIT_TEST in my testbed. Guenter