From 17b7a74041bbd652ee12e8c1b2d51a2f35fafa90 Mon Sep 17 00:00:00 2001 From: Yan Yan Date: Wed, 29 Nov 2023 00:15:07 +0000 Subject: [PATCH] Fix StructXfrmLifetimeCurTest failure when default timezone is not GMT Previously the calculation of the expected ADD_TIME implicitly depended on the default timezone of the test device and thus might have different values and cause test failures. This fix updates the test to always use "GMT" to generate the ADD_TIME Bug: 308011229 Test: StructXfrmLifetimeCurTest passing with default timezone being GMT, GMT-6, GMT-10 Change-Id: Ib88a253c1ecb09feeb298a04b847c4105651a710 --- .../module/util/netlink/xfrm/StructXfrmLifetimeCurTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/staticlibs/tests/unit/src/com/android/net/module/util/netlink/xfrm/StructXfrmLifetimeCurTest.java b/staticlibs/tests/unit/src/com/android/net/module/util/netlink/xfrm/StructXfrmLifetimeCurTest.java index 38ef7adb30..008c922f5b 100644 --- a/staticlibs/tests/unit/src/com/android/net/module/util/netlink/xfrm/StructXfrmLifetimeCurTest.java +++ b/staticlibs/tests/unit/src/com/android/net/module/util/netlink/xfrm/StructXfrmLifetimeCurTest.java @@ -31,6 +31,7 @@ import java.math.BigInteger; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Calendar; +import java.util.TimeZone; import java.util.concurrent.TimeUnit; @RunWith(AndroidJUnit4.class) @@ -42,7 +43,7 @@ public class StructXfrmLifetimeCurTest { private static final BigInteger ADD_TIME; static { - final Calendar cal = Calendar.getInstance(); + final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.set(2023, Calendar.NOVEMBER, 2, 1, 42, 36); final long timestampSeconds = TimeUnit.MILLISECONDS.toSeconds(cal.getTimeInMillis()); ADD_TIME = BigInteger.valueOf(timestampSeconds);