Message ID | 1429449662-9782-6-git-send-email-sjg@chromium.org |
---|---|
State | Accepted |
Delegated to: | Simon Glass |
Headers | show |
Hi Simon, On Sun, Apr 19, 2015 at 8:21 AM, Simon Glass <sjg@chromium.org> wrote: > We must not clear global_data even in tests, since the ram_buffer (which > is used by malloc()) will also be lost, and subsequent tests will fail. > > Zero only the global_data fields that are required for the test to function. > > Signed-off-by: Simon Glass <sjg@chromium.org> For me, this fixed: """ Test: dm_test_usb_base /home/joe/u-boot/test/dm/test-main.c:27, dm_test_init(): 0 == dm_init(): Expected 0, got -12 /home/joe/u-boot/test/dm/test-main.c:93, dm_test_main(): 0 == dm_test_init(dms): Expected 0, got -1 """ Reviewed-by: Joe Hershberger <joe.hershberger@ni.com> Tested-by: Joe Hershberger <joe.hershberger@ni.com>
On 21 April 2015 at 10:00, Joe Hershberger <joe.hershberger@gmail.com> wrote: > Hi Simon, > > On Sun, Apr 19, 2015 at 8:21 AM, Simon Glass <sjg@chromium.org> wrote: >> We must not clear global_data even in tests, since the ram_buffer (which >> is used by malloc()) will also be lost, and subsequent tests will fail. >> >> Zero only the global_data fields that are required for the test to function. >> >> Signed-off-by: Simon Glass <sjg@chromium.org> > > For me, this fixed: > > """ > Test: dm_test_usb_base > /home/joe/u-boot/test/dm/test-main.c:27, dm_test_init(): 0 == > dm_init(): Expected 0, got -12 > /home/joe/u-boot/test/dm/test-main.c:93, dm_test_main(): 0 == > dm_test_init(dms): Expected 0, got -1 > """ > > Reviewed-by: Joe Hershberger <joe.hershberger@ni.com> > Tested-by: Joe Hershberger <joe.hershberger@ni.com> Applied to u-boot-dm.
diff --git a/test/dm/core.c b/test/dm/core.c index 990d390..4b9c987 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -596,12 +596,14 @@ static int dm_test_uclass_before_ready(struct dm_test_state *dms) ut_assertok(uclass_get(UCLASS_TEST, &uc)); - memset(gd, '\0', sizeof(*gd)); + gd->dm_root = NULL; + gd->dm_root_f = NULL; + memset(&gd->uclass_root, '\0', sizeof(gd->uclass_root)); + ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST)); return 0; } - DM_TEST(dm_test_uclass_before_ready, 0); static int dm_test_device_get_uclass_id(struct dm_test_state *dms)
We must not clear global_data even in tests, since the ram_buffer (which is used by malloc()) will also be lost, and subsequent tests will fail. Zero only the global_data fields that are required for the test to function. Signed-off-by: Simon Glass <sjg@chromium.org> --- test/dm/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)