Fix ZoneInfoDBTest on devices that have taken a gservices tzdata update. The tests were assuming that the zygote was always using the /system/usr/share/zoneinfo copy, but devices that have taken a gservices tzdata update will be using the /data/misc/zoneinfo/tzdata copy instead. Bug: 11513357 (cherry picked from commit e086850abf2726d5b5af1d9286fdb32f7146fad3) Change-Id: If9047a0678efb7bcfe0838cbe602a9c906e1f907
diff --git a/luni/src/test/java/libcore/util/ZoneInfoDBTest.java b/luni/src/test/java/libcore/util/ZoneInfoDBTest.java index d5f2b6e..8f8ab58 100644 --- a/luni/src/test/java/libcore/util/ZoneInfoDBTest.java +++ b/luni/src/test/java/libcore/util/ZoneInfoDBTest.java
@@ -23,18 +23,19 @@ public class ZoneInfoDBTest extends junit.framework.TestCase { private static final String CURRENT_VERSION = ZoneInfoDB.getInstance().getVersion(); - private static final String DEFAULT_FILE = System.getenv("ANDROID_ROOT") + "/usr/share/zoneinfo/tzdata"; + private static final String DEFAULT_FILE_1 = System.getenv("ANDROID_ROOT") + "/usr/share/zoneinfo/tzdata"; + private static final String DEFAULT_FILE_2 = System.getenv("ANDROID_DATA") + "/misc/zoneinfo/tzdata"; // An empty override file should fall back to the default file. public void testEmptyOverrideFile() throws Exception { - ZoneInfoDB.TzData data = new ZoneInfoDB.TzData(makeEmptyFile(), DEFAULT_FILE); + ZoneInfoDB.TzData data = new ZoneInfoDB.TzData(makeEmptyFile(), DEFAULT_FILE_1, DEFAULT_FILE_2); assertEquals(CURRENT_VERSION, data.getVersion()); assertEquals(TimeZone.getAvailableIDs().length, data.getAvailableIDs().length); } // A corrupt override file should fall back to the default file. public void testCorruptOverrideFile() throws Exception { - ZoneInfoDB.TzData data = new ZoneInfoDB.TzData(makeCorruptFile(), DEFAULT_FILE); + ZoneInfoDB.TzData data = new ZoneInfoDB.TzData(makeCorruptFile(), DEFAULT_FILE_1, DEFAULT_FILE_2); assertEquals(CURRENT_VERSION, data.getVersion()); assertEquals(TimeZone.getAvailableIDs().length, data.getAvailableIDs().length); } @@ -49,9 +50,11 @@ // Given a valid override file, we should find ourselves using that. public void testGoodOverrideFile() throws Exception { - RandomAccessFile in = new RandomAccessFile(DEFAULT_FILE, "r"); + // We copy /system/usr/share/zoneinfo/tzdata because we know that always exists. + RandomAccessFile in = new RandomAccessFile(DEFAULT_FILE_1, "r"); byte[] content = new byte[(int) in.length()]; in.readFully(content); + // Bump the version number to one long past where humans will be extinct. content[6] = '9'; content[7] = '9'; content[8] = '9'; @@ -61,7 +64,7 @@ String goodFile = makeTemporaryFile(content); try { - ZoneInfoDB.TzData data = new ZoneInfoDB.TzData(goodFile, DEFAULT_FILE); + ZoneInfoDB.TzData data = new ZoneInfoDB.TzData(goodFile, DEFAULT_FILE_1, DEFAULT_FILE_2); assertEquals("9999z", data.getVersion()); assertEquals(TimeZone.getAvailableIDs().length, data.getAvailableIDs().length); } finally {