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
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 38ef7ad..008c922 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.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 @@
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);