diff options
| author | 2024-06-18 18:51:32 +0000 | |
|---|---|---|
| committer | 2024-06-18 18:51:32 +0000 | |
| commit | 1734fc05cd9a0e4b69bd1488224ba47c7beb4da4 (patch) | |
| tree | cf8c0382387f2ce63fb2bca6ba8f2d1d778591f7 | |
| parent | f9335c655da143ecb3eb2bb5f82cc6fa6d8fdff1 (diff) | |
| parent | e283631bb407d6cd7b0d8578f4ac2dfd1706f398 (diff) | |
Merge "Implement binder_sdk*_test(s)" into main
| -rw-r--r-- | libs/binder/Android.bp | 15 | ||||
| -rw-r--r-- | libs/binder/tests/binder_sdk/Android.bp | 84 | ||||
| -rwxr-xr-x | libs/binder/tests/binder_sdk/binder_sdk_docker_test.sh | 70 | ||||
| -rw-r--r-- | libs/binder/tests/binder_sdk/binder_sdk_test.sh | 40 | ||||
| -rw-r--r-- | libs/binder/tests/binder_sdk/clang.Dockerfile | 32 | ||||
| -rw-r--r-- | libs/binder/tests/binder_sdk/gcc.Dockerfile | 32 | ||||
| -rw-r--r-- | libs/binder/tests/binder_sdk/gnumake.Dockerfile | 30 |
7 files changed, 300 insertions, 3 deletions
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp index 7d1535065c..f31f8d3993 100644 --- a/libs/binder/Android.bp +++ b/libs/binder/Android.bp @@ -19,6 +19,7 @@ package { // to get the below license kinds: // SPDX-license-identifier-Apache-2.0 default_applicable_licenses: ["frameworks_native_license"], + default_team: "trendy_team_virtualization", } cc_library_headers { @@ -90,7 +91,11 @@ cc_cmake_snapshot { "libbinder_sdk", "libbinder_sdk_single_threaded", "libbinder_ndk_sdk", + "googletest_cmake", + "binderRpcTestNoKernel", + "binderRpcTestSingleThreadedNoKernel", + "binderRpcWireProtocolTest", ], prebuilts: [ // to enable arm64 host support, build with musl - e.g. on aosp_cf_arm64_phone @@ -133,12 +138,16 @@ cc_cmake_snapshot { { android_name: "libgtest", mapped_name: "GTest::gtest", - package_system: "GTest", + package_pregenerated: "external/googletest", }, { android_name: "libgtest_main", - mapped_name: "GTest::gtest", - package_system: "GTest", + mapped_name: "GTest::gtest_main", + package_pregenerated: "external/googletest", + }, + { + android_name: "googletest_cmake", + package_pregenerated: "external/googletest", }, // use libbinder_sdk and friends instead of full Android's libbinder diff --git a/libs/binder/tests/binder_sdk/Android.bp b/libs/binder/tests/binder_sdk/Android.bp new file mode 100644 index 0000000000..4e884ad319 --- /dev/null +++ b/libs/binder/tests/binder_sdk/Android.bp @@ -0,0 +1,84 @@ +// +// Copyright (C) 2024 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "frameworks_native_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["frameworks_native_license"], +} + +sh_test_host { + name: "binder_sdk_test", + src: "binder_sdk_test.sh", + test_suites: ["general-tests"], + test_options: { + unit_test: false, + }, + + data: [ + ":binder_sdk", + ":cmake_root", + ], + data_bins: [ + "cmake", + "ctest", + ], +} + +sh_test_host { + name: "binder_sdk_docker_test_gcc", + src: "binder_sdk_docker_test.sh", + test_suites: ["general-tests"], + test_options: { + unit_test: false, + }, + + data: [ + ":binder_sdk", + "gcc.Dockerfile", + ], +} + +sh_test_host { + name: "binder_sdk_docker_test_clang", + src: "binder_sdk_docker_test.sh", + test_suites: ["general-tests"], + test_options: { + unit_test: false, + }, + + data: [ + ":binder_sdk", + "clang.Dockerfile", + ], +} + +sh_test_host { + name: "binder_sdk_docker_test_gnumake", + src: "binder_sdk_docker_test.sh", + test_suites: ["general-tests"], + test_options: { + unit_test: false, + }, + + data: [ + ":binder_sdk", + "gnumake.Dockerfile", + ], +} diff --git a/libs/binder/tests/binder_sdk/binder_sdk_docker_test.sh b/libs/binder/tests/binder_sdk/binder_sdk_docker_test.sh new file mode 100755 index 0000000000..0eca84607e --- /dev/null +++ b/libs/binder/tests/binder_sdk/binder_sdk_docker_test.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -ex + +TEST_NAME="$(basename "$0")" +DOCKER_TAG="${TEST_NAME}-${RANDOM}${RANDOM}" +DOCKER_FILE=*.Dockerfile +DOCKER_RUN_FLAGS= + +# Guess if we're running as an Android test or directly +if [ "$(ls -1 ${DOCKER_FILE} | wc -l)" == "1" ]; then + # likely running as `atest binder_sdk_docker_test_XYZ` + DOCKER_PATH="$(dirname $(readlink --canonicalize --no-newline binder_sdk.zip))" +else + # likely running directly as `./binder_sdk_docker_test.sh` - provide mode for easy testing + RED='\033[1;31m' + NO_COLOR='\033[0m' + + if ! modinfo vsock_loopback &>/dev/null ; then + echo -e "${RED}Module vsock_loopback is not installed.${NO_COLOR}" + exit 1 + fi + if modprobe --dry-run --first-time vsock_loopback &>/dev/null ; then + echo "Module vsock_loopback is not loaded. Attempting to load..." + if ! sudo modprobe vsock_loopback ; then + echo -e "${RED}Module vsock_loopback is not loaded and attempt to load failed.${NO_COLOR}" + exit 1 + fi + fi + + DOCKER_RUN_FLAGS="--interactive --tty" + + DOCKER_FILE="$1" + if [ ! -f "${DOCKER_FILE}" ]; then + echo -e "${RED}Docker file '${DOCKER_FILE}' doesn't exist. Please provide one as an argument.${NO_COLOR}" + exit 1 + fi + + if [ ! -d "${ANDROID_BUILD_TOP}" ]; then + echo -e "${RED}ANDROID_BUILD_TOP doesn't exist. Please lunch some target.${NO_COLOR}" + exit 1 + fi + ${ANDROID_BUILD_TOP}/build/soong/soong_ui.bash --make-mode binder_sdk + BINDER_SDK_ZIP="${ANDROID_BUILD_TOP}/out/soong/.intermediates/frameworks/native/libs/binder/binder_sdk/linux_glibc_x86_64/*/binder_sdk.zip" + DOCKER_PATH="$(dirname $(ls -1 ${BINDER_SDK_ZIP} | head --lines=1))" +fi + +function cleanup { + docker rmi --force "${DOCKER_TAG}" 2>/dev/null || true +} +trap cleanup EXIT + +docker build --force-rm --tag "${DOCKER_TAG}" --file ${DOCKER_FILE} ${DOCKER_PATH} +docker run ${DOCKER_RUN_FLAGS} --rm "${DOCKER_TAG}" diff --git a/libs/binder/tests/binder_sdk/binder_sdk_test.sh b/libs/binder/tests/binder_sdk/binder_sdk_test.sh new file mode 100644 index 0000000000..1881acef5e --- /dev/null +++ b/libs/binder/tests/binder_sdk/binder_sdk_test.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -ex + +RED='\033[1;31m' +NO_COLOR='\033[0m' + +if [ ! -f "binder_sdk.zip" ]; then + echo -e "${RED}binder_sdk.zip doesn't exist. Are you running this test through 'atest binder_sdk_test'?${NO_COLOR}" + exit 1 +fi + +mkdir -p bin +cp `pwd`/cmake bin/cmake +cp `pwd`/ctest bin/ctest +export PATH="`pwd`/bin:$PATH" + +WORKDIR=workdir_$RANDOM$RANDOM$RANDOM +unzip -q -d $WORKDIR binder_sdk.zip +cd $WORKDIR + +cmake . +make -j +make test ARGS="--parallel 32 --output-on-failure" diff --git a/libs/binder/tests/binder_sdk/clang.Dockerfile b/libs/binder/tests/binder_sdk/clang.Dockerfile new file mode 100644 index 0000000000..aa1fec2d3c --- /dev/null +++ b/libs/binder/tests/binder_sdk/clang.Dockerfile @@ -0,0 +1,32 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM debian:bookworm + +RUN echo 'deb http://deb.debian.org/debian bookworm-backports main' >> /etc/apt/sources.list && \ + apt-get update -y && \ + apt-get install -y clang cmake ninja-build unzip + +ADD binder_sdk.zip / +RUN unzip -q -d binder_sdk binder_sdk.zip + +WORKDIR /binder_sdk +RUN CC=clang CXX=clang++ cmake -G Ninja -B build . +RUN cmake --build build + +WORKDIR /binder_sdk/build +# Alternatively: `ninja test`, but it won't pass parallel argument +ENTRYPOINT [ "ctest", "--parallel", "32", "--output-on-failure" ] diff --git a/libs/binder/tests/binder_sdk/gcc.Dockerfile b/libs/binder/tests/binder_sdk/gcc.Dockerfile new file mode 100644 index 0000000000..fb2ee2ce7d --- /dev/null +++ b/libs/binder/tests/binder_sdk/gcc.Dockerfile @@ -0,0 +1,32 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM gcc:9 + +RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' >> /etc/apt/sources.list && \ + apt-get update -y && \ + apt-get install -y cmake ninja-build + +ADD binder_sdk.zip / +RUN unzip -q -d binder_sdk binder_sdk.zip + +WORKDIR /binder_sdk +RUN CC=gcc CXX=g++ cmake -G Ninja -B build . +RUN cmake --build build + +WORKDIR /binder_sdk/build +# Alternatively: `ninja test`, but it won't pass parallel argument +ENTRYPOINT [ "ctest", "--parallel", "32", "--output-on-failure" ] diff --git a/libs/binder/tests/binder_sdk/gnumake.Dockerfile b/libs/binder/tests/binder_sdk/gnumake.Dockerfile new file mode 100644 index 0000000000..abe12fb9d1 --- /dev/null +++ b/libs/binder/tests/binder_sdk/gnumake.Dockerfile @@ -0,0 +1,30 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM gcc:9 + +RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' >> /etc/apt/sources.list && \ + apt-get update -y && \ + apt-get install -y cmake + +ADD binder_sdk.zip / +RUN unzip -q -d binder_sdk binder_sdk.zip + +WORKDIR /binder_sdk +RUN cmake . +RUN make -j + +ENTRYPOINT make test ARGS="--parallel 32 --output-on-failure" |