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 3F079C00144 for ; Mon, 1 Aug 2022 13:59:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8AB7E844E4; Mon, 1 Aug 2022 15:59:08 +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="lmtxkMDp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77BF6844E2; Mon, 1 Aug 2022 15:59:04 +0200 (CEST) Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) (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 DB8078440C for ; Mon, 1 Aug 2022 15:58:59 +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-x2e.google.com with SMTP id 586e51a60fabf-10cf9f5b500so13764822fac.2 for ; Mon, 01 Aug 2022 06:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=qkPAyM5xWOF6Vj5mqaiBTq+s3NA6vGHnfphM7NHP3Cw=; b=lmtxkMDp2a9M5G2MNzYY+gywS/JTNjcr3W99Lg7OPWPJUYuCn9IqRI8fIAJ7Nrj5Pi nqS78qlr/25F05VSf0uHpVyVcDjSYolTq+hqczgre2R19HhCcWRoaQhk01r5PZ/E65/F oKpUMgVnvN8kM0FuTa8WVRNvsyiSlFtp0FVlg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=qkPAyM5xWOF6Vj5mqaiBTq+s3NA6vGHnfphM7NHP3Cw=; b=x58Ve1x6uUrCc6TFxGOAnTi9THyVnhAW1mLjXb1wD7cnoBt6pRbeDlKisgNOo8TybW aXgBZYf1PeCAFqGIh6lb9daA7UzLYvbNyfxmnmY0rvDiUYiif2Yt27imHAPsFDP/trDm 21MgpZ+mZjeXZKds9gTftkGQzMbz38H5eywMXBmenbHdqauWL3CtfXtiyKqu+DBI4m4c oIasg6UhXaNKFJtwiN3s6duo/LvtCT85/0Hloh0EWBwnSZjiAeMxPLh2FRwXwhhf83Ks GrunHm3yFBr2zC3RB8xlBjALi9JxDWqs3w+QbfGyoIBUXEPfVVNQxNNUmb3ED2y7YJB2 e5wA== X-Gm-Message-State: AJIora87HIgNLvwkq9cbHiK9WqUv/qhqvtDGH6ECs+4QqpWIexXZkkGe Y5VujUviauLHLRxD0F5xDLbHAGs1nSEo9g== X-Google-Smtp-Source: AGRyM1u/qCchwbwPltZ5lx1o7VYHor3XBemJsZZ3sfu7CvoRgTaPrhp9zDTzGPtGjsIqvGOwXsU0nA== X-Received: by 2002:a05:6870:a78f:b0:10c:1ddc:b4b9 with SMTP id x15-20020a056870a78f00b0010c1ddcb4b9mr7458309oao.262.1659362338279; Mon, 01 Aug 2022 06:58:58 -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 a14-20020a9d3e0e000000b0061cf85b2a0csm2743161otd.5.2022.08.01.06.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Aug 2022 06:58:57 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass , Heinrich Schuchardt , Bin Meng , Rasmus Villemoes , Marek Vasut , Pavel Herrmann Subject: [PATCH 3/5] dm: rtc: Avoid a race in the rtc_reset test Date: Mon, 1 Aug 2022 07:58:46 -0600 Message-Id: <20220801135848.992449-4-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220801135848.992449-1-sjg@chromium.org> References: <20220801135848.992449-1-sjg@chromium.org> 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. Reviewed-by: Heinrich Schuchardt 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/dm/rtc.c b/test/dm/rtc.c index a8349756c18..e23905b3e2e 100644 --- a/test/dm/rtc.c +++ b/test/dm/rtc.c @@ -251,10 +251,15 @@ static int dm_test_rtc_reset(struct unit_test_state *uts) 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