1#!/usr/bin/env bash 2# 3# Copyright (C) 2017 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17# Updates the test data files. 18TIMEZONE_DIR=${ANDROID_BUILD_TOP}/system/timezone 19DISTRO_TOOLS_DIR=${TIMEZONE_DIR}/distro/tools 20REFERENCE_DISTRO_FILES=${TIMEZONE_DIR}/output_data 21 22# Fail on error 23set -e 24 25# Test 1: A set of data newer than the system-image data from ${TIMEZONE_DIR} 26IANA_VERSION=2030a 27TEST_DIR=test1 28 29# Create fake distro input files. 30./transform-distro-files.sh ${REFERENCE_DISTRO_FILES} ${IANA_VERSION} ./${TEST_DIR}/output_data 31 32# Create the distro .zip 33mkdir -p ${TEST_DIR}/output_data/distro 34mkdir -p ${TEST_DIR}/output_data/version 35${DISTRO_TOOLS_DIR}/create-distro.py \ 36 -iana_version ${IANA_VERSION} \ 37 -revision 1 \ 38 -tzdata ${TEST_DIR}/output_data/iana/tzdata \ 39 -icu ${TEST_DIR}/output_data/icu_overlay/icu_tzdata.dat \ 40 -tzlookup ${TEST_DIR}/output_data/android/tzlookup.xml \ 41 -telephonylookup ${TEST_DIR}/output_data/android/telephonylookup.xml \ 42 -output_distro_dir ${TEST_DIR}/output_data/distro \ 43 -output_version_file ${TEST_DIR}/output_data/version/tz_version 44 45# Test 2: A set of data older than the system-image data from ${TIMEZONE_DIR} 46IANA_VERSION=2016a 47TEST_DIR=test2 48 49# Create fake distro input files. 50./transform-distro-files.sh ${REFERENCE_DISTRO_FILES} ${IANA_VERSION} ./${TEST_DIR}/output_data 51 52# Create the distro .zip 53mkdir -p ${TEST_DIR}/output_data/distro 54mkdir -p ${TEST_DIR}/output_data/version 55${DISTRO_TOOLS_DIR}/create-distro.py \ 56 -iana_version ${IANA_VERSION} \ 57 -revision 1 \ 58 -tzdata ${TEST_DIR}/output_data/iana/tzdata \ 59 -icu ${TEST_DIR}/output_data/icu_overlay/icu_tzdata.dat \ 60 -tzlookup ${TEST_DIR}/output_data/android/tzlookup.xml \ 61 -telephonylookup ${TEST_DIR}/output_data/android/telephonylookup.xml \ 62 -output_distro_dir ${TEST_DIR}/output_data/distro \ 63 -output_version_file ${TEST_DIR}/output_data/version/tz_version 64 65# Test 3: A corrupted set of data like test 1, but with a truncated ICU 66# overlay file. This test data set exists because it is (currently) a good way 67# to trigger a boot loop which enables easy watchdog and recovery testing. 68IANA_VERSION=2030a 69TEST_DIR=test3 70 71# Create fake distro input files. 72./transform-distro-files.sh ${REFERENCE_DISTRO_FILES} ${IANA_VERSION} ./${TEST_DIR}/output_data 73 74# Corrupt icu_tzdata.dat by truncating it 75truncate --size 27766 ${TEST_DIR}/output_data/icu_overlay/icu_tzdata.dat 76 77# Create the distro .zip 78mkdir -p ${TEST_DIR}/output_data/distro 79mkdir -p ${TEST_DIR}/output_data/version 80${DISTRO_TOOLS_DIR}/create-distro.py \ 81 -iana_version ${IANA_VERSION} \ 82 -revision 1 \ 83 -tzdata ${TEST_DIR}/output_data/iana/tzdata \ 84 -icu ${TEST_DIR}/output_data/icu_overlay/icu_tzdata.dat \ 85 -tzlookup ${TEST_DIR}/output_data/android/tzlookup.xml \ 86 -telephonylookup ${TEST_DIR}/output_data/android/telephonylookup.xml \ 87 -output_distro_dir ${TEST_DIR}/output_data/distro \ 88 -output_version_file ${TEST_DIR}/output_data/version/tz_version 89