From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23210C00140 for ; Sun, 31 Jul 2022 18:27:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8FBE183FCC; Sun, 31 Jul 2022 20:27:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PLu7vIc2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4E66383D13; Sun, 31 Jul 2022 20:27:16 +0200 (CEST) Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A24E483FCC for ; Sun, 31 Jul 2022 20:27:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-10bd4812c29so11275152fac.11 for ; Sun, 31 Jul 2022 11:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=ZRyvctFDOANMRSH9tIlbqKpIYc+XHS0lAkm5nDWib0g=; b=PLu7vIc2XRsRY+NFFXyDNNIF8LiESUmnb+EhxL10Y2z+YY4BcpHzEb9gR7CpvVCQWK 9xyyAyFsrNI8nF6Mlj2rUtaB/WM1E4xwbBgDYsaQEDiUf/Sa4jFCBbwQqRpv1L5mtMAY ud+TLP4nTrD85AzAajpZpsbdsJ3cC0GSmXVTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=ZRyvctFDOANMRSH9tIlbqKpIYc+XHS0lAkm5nDWib0g=; b=RWD7LJcqRFUJxpOFwa5y3VRfPq0D6qe+JcF4Z7cOvBKlLYRC8RlI2fyQyle5BL3Fla dbTlDwKUO+KO1hrFmOskW40AcWVA0yu/rEInBlhJdgWMPaRh3nEotr3/aq75SzI6YJkS GhV+WcQDSb+DLj1vAZeU0v07bOLdrVvXGnBnf8RepXhql6yhfHj/JAXz5S0DdH6TzU5v Ey9bX4XurHMHFpRdKzTjezjgHfDFgmTc1R4KuhVKTL2xq497AwNVtmms/LbYrcUEmdSH CUnMfPQU840kxTI1NKc+uVonf+RlEDzPtNGMo2gsMpx3vmX4LhQX52AFLHZ/vrDUHj/I f6Dg== X-Gm-Message-State: AJIora8OKaNLvTnUG5KTtwQq1UeRA4hrxRSNgyD2gJO3vj1GGmQ/tR0c n3DkskX4pRn3J5kH8KAGRe1aSMGbJNhdSg== X-Google-Smtp-Source: AGRyM1uTyF36nomvCeK2LP0pq/2YSy8H74imYjozH5HJGw5lVa3o2cZ3OXDvpYh5ytO+cpGA5qM7lQ== X-Received: by 2002:a05:6870:6312:b0:10b:8ee3:b402 with SMTP id s18-20020a056870631200b0010b8ee3b402mr5995562oao.60.1659292031963; Sun, 31 Jul 2022 11:27:11 -0700 (PDT) Received: from sjg1.lan (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id w9-20020a9d70c9000000b0061d15ee86ddsm2314940otj.68.2022.07.31.11.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Jul 2022 11:27:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass , Bin Meng , Rasmus Villemoes , Marek Vasut , Pavel Herrmann Subject: [PATCH] dm: rtc: Avoid a race in the rtc_reset test Date: Sun, 31 Jul 2022 12:27:07 -0600 Message-Id: <20220731182707.921722-1-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Since resetting the RTC on sandbox causes it to read the base time from the system, we cannot rely on this being unchanged since it was last read. Allow for a one-second delay. Fixes: https://source.denx.de/u-boot/u-boot/-/issues/4 Reported-by: Bin Meng Reported-by: Tom Rini Suggested-by: Rasmus Villemoes Signed-off-by: Simon Glass --- test/dm/rtc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/dm/rtc.c b/test/dm/rtc.c index c7f9f8f0ce7..403bf5c640a 100644 --- a/test/dm/rtc.c +++ b/test/dm/rtc.c @@ -245,16 +245,21 @@ static int dm_test_rtc_reset(struct unit_test_state *uts) ut_assertok(dm_rtc_get(dev, &now)); ut_assertok(i2c_emul_find(dev, &emul)); - ut_assert(emul != NULL); + ut_assertnonnull(emul); old_base_time = sandbox_i2c_rtc_get_set_base_time(emul, 0); ut_asserteq(0, sandbox_i2c_rtc_get_set_base_time(emul, -1)); - /* Resetting the RTC should put he base time back to normal */ + /* + * Resetting the RTC should put the base time back to normal. Allow for + * a one-second adjustment in case the time flips over while this + * test process is pre-empted, since reset_time() in i2c_rtc_emul.c + * reads the time from the OS. + */ ut_assertok(dm_rtc_reset(dev)); base_time = sandbox_i2c_rtc_get_set_base_time(emul, -1); - ut_asserteq(old_base_time, base_time); + ut_assert(base_time - old_base_time <= 1); return 0; } -- 2.37.1.455.g008518b4e5-goog