164ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light#!/bin/bash
264ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light#
364ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# Copyright (C) 2014 The Android Open Source Project
464ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light#
564ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# Licensed under the Apache License, Version 2.0 (the "License");
664ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# you may not use this file except in compliance with the License.
764ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# You may obtain a copy of the License at
864ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light#
964ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light#     http://www.apache.org/licenses/LICENSE-2.0
1064ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light#
1164ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# Unless required by applicable law or agreed to in writing, software
1264ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# distributed under the License is distributed on an "AS IS" BASIS,
1364ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1464ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# See the License for the specific language governing permissions and
1564ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# limitations under the License.
1664ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light
173ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampeflags="$@"
183ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe
193ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe# This test is supposed to test without oat files, so doesn't work for prebuild. Make sure that
203ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe# flag isn't set, or complain.
213ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe# Note: prebuild is the default.
223ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampeif [[ "${flags}" == *--prebuild* || "${flags}" != *--no-prebuild* ]] ; then
233ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe  echo "Test 118-noimage-dex2oat cannot run in prebuild mode."
243ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe  exit 1
253ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampefi
2664ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light
273ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe# Force relocation otherwise we will just use the already created core.oat/art pair.
283ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe# Note: relocate is the default.
293ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampeif [[ "${flags}" == *--no-relocate* ]] ; then
303ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe  echo "Test 118-noimage-dex2oat is not intended to run in no-relocate mode."
313ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampe  exit 1
323ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampefi
3364ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light
343ad5d5ea993376e7cae41ee6642d5e963822db84Andreas Gampeif [[ $@ == *--host* ]]; then
351ef4ce87e54a595a67263e550916b97a1b468b99Alex Light    framework="${ANDROID_HOST_OUT}/framework"
361ef4ce87e54a595a67263e550916b97a1b468b99Alex Light    bpath_suffix="-hostdex"
3764ad14dbe2225441fb7734bf6d89358d96692eeaAlex Lightelse
381ef4ce87e54a595a67263e550916b97a1b468b99Alex Light    framework="/system/framework"
391ef4ce87e54a595a67263e550916b97a1b468b99Alex Light    bpath_suffix=""
4064ad14dbe2225441fb7734bf6d89358d96692eeaAlex Lightfi
411ef4ce87e54a595a67263e550916b97a1b468b99Alex Lightbpath="${framework}/core-libart${bpath_suffix}.jar"
421ef4ce87e54a595a67263e550916b97a1b468b99Alex Lightbpath="${bpath}:${framework}/conscrypt${bpath_suffix}.jar"
431ef4ce87e54a595a67263e550916b97a1b468b99Alex Lightbpath="${bpath}:${framework}/okhttp${bpath_suffix}.jar"
441ef4ce87e54a595a67263e550916b97a1b468b99Alex Lightbpath="${bpath}:${framework}/bouncycastle${bpath_suffix}.jar"
451ef4ce87e54a595a67263e550916b97a1b468b99Alex Lightbpath_arg="--runtime-option -Xbootclasspath:${bpath}"
461ef4ce87e54a595a67263e550916b97a1b468b99Alex Light
4764ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light
4824e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler# Make sure we can run without an oat file.
4964ad14dbe2225441fb7734bf6d89358d96692eeaAlex Lightecho "Run -Xnoimage-dex2oat"
501ef4ce87e54a595a67263e550916b97a1b468b99Alex Light${RUN} ${flags} ${bpath_arg} --runtime-option -Xnoimage-dex2oat --runtime-option -Xnodex2oat
5164ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light
5224e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler# Make sure we cannot run without an oat file without fallback.
5324e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beylerecho "Run -Xnoimage-dex2oat -Xno-dex-file-fallback"
5424e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler${RUN} ${flags} ${bpath_arg} --runtime-option -Xnoimage-dex2oat --runtime-option -Xnodex2oat --runtime-option -Xno-dex-file-fallback
5524e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler
5664ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# Make sure we can run with the oat file.
5764ad14dbe2225441fb7734bf6d89358d96692eeaAlex Lightecho "Run -Ximage-dex2oat"
581ef4ce87e54a595a67263e550916b97a1b468b99Alex Light${RUN} ${flags} ${bpath_arg} --runtime-option -Ximage-dex2oat
5964ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light
6064ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light# Make sure we can run with the default settings.
6164ad14dbe2225441fb7734bf6d89358d96692eeaAlex Lightecho "Run default"
621ef4ce87e54a595a67263e550916b97a1b468b99Alex Light${RUN} ${flags} ${bpath_arg}
63