1#!/bin/bash 2# 3# Copyright 2023 Google Inc. All rights reserved. 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 17set -euo pipefail 18 19# This test asserts that the android_app under test does not package ndk libs 20# 21# Setup 22# android_app: SimpleJni 23# jni_libs: libsimplejni 24# transitive_dep_of_jni_lib: liblog (an NDK library) 25# 26# Expectation 27# SimpleJni.apk contains libsimplejni.so 28# SimpleJni.apk does not contain libglog.so 29 30unsigned_apk=$(find ${RUNFILES_DIR} -name *_unsigned.apk) 31 32# check that the apk contains libsimplejni.so 33if ! [[ $(unzip -l ${unsigned_apk} | grep lib/.*libsimplejni.so ) ]]; then 34 echo "Could not find libsimplejni.so in SimpleJni's apk file: ${unsigned_apk}" 35 exit 1 36fi 37 38# check that the apk does not liblog.so 39if [[ $(unzip -l ${unsigned_apk} | grep lib/.*liblog.so ) ]]; then 40 echo "Found liblog.so in SimpleJni's apk file: ${unsigned_apk}. Since this is an NDK library, it should not be included." 41 exit 1 42fi 43