From patchwork Mon Jan 19 20:41:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1638 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855354; bh=rdqIrbfC0H5QeYwxqDWgjGH3Lj+EBp6xvwBlomT6m9w=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KI9ztg0a6qIx3SY4LJiI1S3Y5uvDggpwf4gb3JyNHYZ+wrjNJni5Lo92XFBbTgEJc x8SgU5foPT7W6oMkl2FDuZeYPiwLJ4h84rENTLJViIrXggp1veGNLNWXD9Eqo2CHLS Bi2AwOudEuozvb9w5x4fNRaeKPXiGBQJ7+w7PdxFmPsG6SSteVFPfiN/BnKOdGh7Em rKYz1m8NcL9EqBrkSSM/h2nF+oR9tRgMSog4XLoORMrp0dZF8fCYFQQiQrKPU0jHZi VBkG+8RbCpm3KgJlbq00wdFCdlO0IhJHXnAjeklrtzYOyJjsarF7vF1F8nJnFXcwBt Orbu+2hkhTW5g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BA91769504 for ; Mon, 19 Jan 2026 13:42:34 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id aoAhuHNvDqhO for ; Mon, 19 Jan 2026 13:42:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855354; bh=rdqIrbfC0H5QeYwxqDWgjGH3Lj+EBp6xvwBlomT6m9w=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KI9ztg0a6qIx3SY4LJiI1S3Y5uvDggpwf4gb3JyNHYZ+wrjNJni5Lo92XFBbTgEJc x8SgU5foPT7W6oMkl2FDuZeYPiwLJ4h84rENTLJViIrXggp1veGNLNWXD9Eqo2CHLS Bi2AwOudEuozvb9w5x4fNRaeKPXiGBQJ7+w7PdxFmPsG6SSteVFPfiN/BnKOdGh7Em rKYz1m8NcL9EqBrkSSM/h2nF+oR9tRgMSog4XLoORMrp0dZF8fCYFQQiQrKPU0jHZi VBkG+8RbCpm3KgJlbq00wdFCdlO0IhJHXnAjeklrtzYOyJjsarF7vF1F8nJnFXcwBt Orbu+2hkhTW5g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AA67D694CE for ; Mon, 19 Jan 2026 13:42:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855352; bh=AnbYsXvYWPhruPFjpOdmZ+C041lj/rRssE62pTt406o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIMf4OFJ3Ov5ZNRH+cjhiOhWWjWHBCHKIl+dIrPuxxD8tSa6yzlPz/UCfQLGAZzkP 5zBUEUKMZNFuxcFmfqTWam7JFk26JzaeUHFUaXwxUc10qUm2BBO3D2eLQy06N5gVbA lKOVfVB6ajepE6K6D2+0RWDlZPJX8LKZfYC/ayxfuo8Cw2RhABFMzEiUnOUoB3GVHu iuNiI17IZiZq9P4d60xfbEqEogB70QJ+ovijSCrLUWj2xdxd24WQVVo2w53zyRnaF+ HpNJGpqIZTAz+QeIE9OxgqShjzRbCZx27c3yYLd6oLhHklfHqIulXBrf1Y4TVro3ig u1kUTu2idSI6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0AA7694CE; Mon, 19 Jan 2026 13:42:32 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 9Hm3q0Ez9RXl; Mon, 19 Jan 2026 13:42:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855347; bh=b6AbT1BFcxf9bi+q2pihXEVG2mys7LYQuRqRL2Yqat0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F5WcIhwjwjafz4ODNev6NkRpcNXT5UHaw3JUrhiAn+c16QIiUGIDpNeT4ea/In70k OdwtHl+aPVZ0F/9aPjAgDYa7oYTzdvQJLWHl1AJqWU9ZnQp/r3ghdaYyoNoIyqmrZb 1DE8osqCMF0zYkQNkJk/4zzlV9swuj/HoIEnG7EBcvzeV9SGrzu62yGgdwZCblz39B grONGZw1pAknxchd7QFiIbspg1k9QKubx0uumfTZaBVZCezHMh+7YBB9g9epw15Ch9 0ov7yZMo6s8RTTt34IB8hES794U2dh6g+Og9UtbF8sB1U2ybHaoYSgm1qibj55Bwfr V0tjQjz1pX61A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3FF75693BA; Mon, 19 Jan 2026 13:42:27 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 19 Jan 2026 13:41:01 -0700 Message-ID: <20260119204130.3972647-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260119204130.3972647-1-sjg@u-boot.org> References: <20260119204130.3972647-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: W3EJWTZTEROGXKX6RIRQ5VVZT4CN54RD X-Message-ID-Hash: W3EJWTZTEROGXKX6RIRQ5VVZT4CN54RD X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/27] test: dm: rtc: Fix flaky dm_test_rtc_dual test List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The test compares times from two RTC devices to verify they can operate independently with different offsets. However, it is flaky because now1 is read with use_system_time=true (using live os_localtime()) while cmp is read with use_system_time=false (using the fixed base_time captured at bind). If exactly 1 second elapses between emulator bind and test execution, the times accidentally match and the test fails. Fix this by: - Reading now1 after switching emul1 to manual mode, so both reads use the fixed base_time - Using a 10-second offset difference instead of 1 second, to account for the fact that each emulator has its own base_time which could differ slightly Also remove the unused now2 and offset variables. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/dm/rtc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/dm/rtc.c b/test/dm/rtc.c index 88f080b64a8..b2687bde433 100644 --- a/test/dm/rtc.c +++ b/test/dm/rtc.c @@ -281,23 +281,30 @@ DM_TEST(dm_test_rtc_reset, UTF_SCAN_PDATA | UTF_SCAN_FDT); /* Check that two RTC devices can be used independently */ static int dm_test_rtc_dual(struct unit_test_state *uts) { - struct rtc_time now1, now2, cmp; + struct rtc_time now1, cmp; struct udevice *dev1, *dev2; struct udevice *emul1, *emul2; - long offset; ut_assertok(uclass_get_device(UCLASS_RTC, 0, &dev1)); - ut_assertok(dm_rtc_get(dev1, &now1)); ut_assertok(uclass_get_device(UCLASS_RTC, 1, &dev2)); - ut_assertok(dm_rtc_get(dev2, &now2)); ut_assertok(i2c_emul_find(dev1, &emul1)); ut_assertnonnull(emul1); ut_assertok(i2c_emul_find(dev2, &emul2)); ut_assertnonnull(emul2); - offset = sandbox_i2c_rtc_set_offset(emul1, false, -1); - sandbox_i2c_rtc_set_offset(emul2, false, offset + 1); + /* + * Put both emulators in manual mode before reading, to avoid a race + * with system time. With use_system_time=true, times are based on + * os_localtime() which advances with real time; with it false, they + * use the fixed base_time captured at bind. Use a large offset + * difference (10s) to account for the fact that each emulator has + * its own base_time, which could differ slightly. + */ + sandbox_i2c_rtc_set_offset(emul1, false, 0); + ut_assertok(dm_rtc_get(dev1, &now1)); + + sandbox_i2c_rtc_set_offset(emul2, false, 10); memset(&cmp, '\0', sizeof(cmp)); ut_assertok(dm_rtc_get(dev2, &cmp)); ut_asserteq(-EINVAL, cmp_times(&now1, &cmp, false));