Loading libs/binder/Android.bp +12 −3 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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 Loading Loading @@ -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 Loading libs/binder/tests/binder_sdk/Android.bp 0 → 100644 +84 −0 Original line number Diff line number Diff line // // 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", ], } libs/binder/tests/binder_sdk/binder_sdk_docker_test.sh 0 → 100755 +70 −0 Original line number Diff line number Diff line #!/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}" libs/binder/tests/binder_sdk/binder_sdk_test.sh 0 → 100644 +40 −0 Original line number Diff line number Diff line #!/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" libs/binder/tests/binder_sdk/clang.Dockerfile 0 → 100644 +32 −0 Original line number Diff line number Diff line # # 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" ] Loading
libs/binder/Android.bp +12 −3 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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 Loading Loading @@ -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 Loading
libs/binder/tests/binder_sdk/Android.bp 0 → 100644 +84 −0 Original line number Diff line number Diff line // // 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", ], }
libs/binder/tests/binder_sdk/binder_sdk_docker_test.sh 0 → 100755 +70 −0 Original line number Diff line number Diff line #!/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}"
libs/binder/tests/binder_sdk/binder_sdk_test.sh 0 → 100644 +40 −0 Original line number Diff line number Diff line #!/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"
libs/binder/tests/binder_sdk/clang.Dockerfile 0 → 100644 +32 −0 Original line number Diff line number Diff line # # 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" ]