OSDN Git Service

Add compile time test infrastructure for bionic.
authorDan Albert <danalbert@google.com>
Fri, 3 Oct 2014 20:46:42 +0000 (13:46 -0700)
committerDan Albert <danalbert@google.com>
Mon, 6 Oct 2014 18:38:01 +0000 (11:38 -0700)
Actual tests to follow...

Bug: 17782583
Change-Id: I22857f19899c3b39dbc2e5473ad3be1a8a291139

tests/Android.mk
tests/file-check-cxx [new file with mode: 0755]

index d946d30..1358800 100644 (file)
@@ -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 (executable)
index 0000000..8ece835
--- /dev/null
@@ -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