{
int op_count[DM_TEST_OP_COUNT];
struct udevice *dev, *test_dev;
+ int start_dev_count, start_uc_count;
+ int dev_count, uc_count;
int pingret;
int ret;
memcpy(op_count, dm_testdrv_op_count, sizeof(op_count));
+ dm_get_stats(&start_dev_count, &start_uc_count);
+
ut_assertok(device_bind_by_name(uts->root, false, &driver_info_manual,
&dev));
ut_assert(dev);
== op_count[DM_TEST_OP_BIND] + 1);
ut_assert(!dev_get_priv(dev));
+ /* We should have one more device */
+ dm_get_stats(&dev_count, &uc_count);
+ ut_asserteq(start_dev_count + 1, dev_count);
+ ut_asserteq(start_uc_count, uc_count);
+
/* Probe the device - it should fail allocating private data */
uts->force_fail_alloc = 1;
ret = device_probe(dev);
ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_UNBIND]);
ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_PRE_UNBIND]);
+ /* We should have one less device */
+ dm_get_stats(&dev_count, &uc_count);
+ ut_asserteq(start_dev_count, dev_count);
+ ut_asserteq(start_uc_count, uc_count);
+
return 0;
}
DM_TEST(dm_test_lifecycle, UT_TESTF_SCAN_PDATA | UT_TESTF_PROBE_TEST);
/* Test uclass init/destroy methods */
static int dm_test_uclass(struct unit_test_state *uts)
{
+ int dev_count, uc_count;
struct uclass *uc;
+ /* We should have just the root device and uclass */
+ dm_get_stats(&dev_count, &uc_count);
+ ut_asserteq(1, dev_count);
+ ut_asserteq(1, uc_count);
+
ut_assertok(uclass_get(UCLASS_TEST, &uc));
ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_DESTROY]);
ut_assert(uclass_get_priv(uc));
+ dm_get_stats(&dev_count, &uc_count);
+ ut_asserteq(1, dev_count);
+ ut_asserteq(2, uc_count);
+
ut_assertok(uclass_destroy(uc));
ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_DESTROY]);
+ dm_get_stats(&dev_count, &uc_count);
+ ut_asserteq(1, dev_count);
+ ut_asserteq(1, uc_count);
+
return 0;
}
DM_TEST(dm_test_uclass, 0);
}
DM_TEST(dm_test_dma_offset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
#endif
+
+/* Test dm_get_stats() */
+static int dm_test_get_stats(struct unit_test_state *uts)
+{
+ int dev_count, uc_count;
+
+ dm_get_stats(&dev_count, &uc_count);
+ ut_assert(dev_count > 50);
+ ut_assert(uc_count > 30);
+
+ return 0;
+}
+DM_TEST(dm_test_get_stats, UT_TESTF_SCAN_FDT);