From f04a8bc2266e4a51e1ccfb18c24ff0ae25d98d8a Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 3 Oct 2014 13:46:42 -0700 Subject: [PATCH] Add compile time test infrastructure for bionic. Actual tests to follow... Bug: 17782583 Change-Id: I22857f19899c3b39dbc2e5473ad3be1a8a291139 --- tests/Android.mk | 45 ++++++++++++++++++++++++++++++++++++++++++++ tests/file-check-cxx | 13 +++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 tests/file-check-cxx diff --git a/tests/Android.mk b/tests/Android.mk index d946d307c..1358800fa 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -322,6 +322,51 @@ build_type := host build_target := NATIVE_TEST include $(LOCAL_PATH)/Android.build.mk +# ----------------------------------------------------------------------------- +# Compile time tests. +# ----------------------------------------------------------------------------- + +# Some of these are intentionally using = instead of := since we need access to +# some variables not initialtized until we're in the build system. + +include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := \ + $(LOCAL_PATH)/Android.mk \ + $(LOCAL_PATH)/file-check-cxx \ + | $(HOST_OUT_EXECUTABLES)/FileCheck$(HOST_EXECUTABLE_SUFFIX) \ + +LOCAL_CXX = $(LOCAL_PATH)/file-check-cxx \ + $(HOST_OUT_EXECUTABLES)/FileCheck \ + $($(LOCAL_2ND_ARCH_VAR_PREFIX)CXX_BARE) \ + GCC \ + +LOCAL_CLANG := false +LOCAL_MODULE := bionic-compile-time-tests-g++ +LOCAL_CXXFLAGS := -Wall +LOCAL_SRC_FILES := +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := \ + $(LOCAL_PATH)/Android.mk \ + $(LOCAL_PATH)/file-check-cxx \ + | $(HOST_OUT_EXECUTABLES)/FileCheck$(HOST_EXECUTABLE_SUFFIX) \ + +LOCAL_CXX := $(LOCAL_PATH)/file-check-cxx \ + $(HOST_OUT_EXECUTABLES)/FileCheck \ + $(LLVM_PREBUILTS_PATH)/clang++ \ + CLANG \ + +LOCAL_CLANG := true +LOCAL_MODULE := bionic-compile-time-tests-clang++ +LOCAL_CXXFLAGS := -Wall +LOCAL_SRC_FILES := +include $(BUILD_STATIC_LIBRARY) + +# ----------------------------------------------------------------------------- +# Host glibc tests. +# ----------------------------------------------------------------------------- + ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm mips x86)) LINKER = linker64 NATIVE_TEST_SUFFIX=64 diff --git a/tests/file-check-cxx b/tests/file-check-cxx new file mode 100755 index 000000000..8ece83556 --- /dev/null +++ b/tests/file-check-cxx @@ -0,0 +1,13 @@ +#!/bin/bash +FILECHECK=$1 +CXX=$2 +PREFIX=$3 +ARGS=${*:4} +SOURCE=$(echo $ARGS | grep -oP '\S+\.cpp\b') +OBJ=$(echo $ARGS | grep -oP '\S+\.o\b') +$CXX $ARGS 2>&1 | $FILECHECK -check-prefix=$PREFIX $SOURCE +if [ "$?" -eq 0 ]; then + touch $OBJ +else + exit 1 +fi