--- /dev/null
+APP_MODULES := \
+ test-LOCAL_CFLAGS \
+ test-LOCAL_CPPFLAGS
+
+APP_PROJECT_PATH := /tmp/ndk-unit-tests
--- /dev/null
+include $(call all-subdir-makefiles)
--- /dev/null
+# This test is used to check that include $(CLEAR_VARS) does
+# indeed clear all variables we care for.
+
+LOCAL_PATH := $(call my-dir)
+
+# The list of LOCAL_XXX variables documented by docs/ANDROID-MK.TXT
+# Note that LOCAL_PATH is not cleared
+VARS_LOCAL := \
+ MODULE \
+ SRC_FILES \
+ CPP_EXTENSION \
+ C_INCLUDES \
+ CFLAGS \
+ CPPFLAGS \
+ CXXFLAGS \
+ STATIC_LIBRARIES \
+ SHARED_LIBRARIES \
+ LDLIBS \
+ ALLOW_UNDEFINED_SYMBOLS \
+ ARM_MODE \
+
+include $(CLEAR_VARS)
+
+$(for _var,$(VARS_LOCAL),\
+ $(eval LOCAL_$(_var) := 1)\
+)
+
+include $(CLEAR_VARS)
+
+STATUS := ok
+$(foreach _var,$(VARS_LOCAL),\
+ $(if $(LOCAL_$(_var)),\
+ $(info variable LOCAL_$(_var) is not cleared by CLEAR_VARS)\
+ $(eval STATUS := ko)\
+ ,)\
+)
+
+ifeq ($(STATUS),ko)
+ $(error Aborting: CLEAR_VARS does not work !)
+endif
+
+VARS_LOCAL := $(empty)
+STATUS := $(empty)
--- /dev/null
+# Test that LOCAL_CFLAGS works for both C and C++ sources
+#
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := test-LOCAL_CFLAGS
+LOCAL_SRC_FILES := test-LOCAL_CFLAGS-1.c \
+ test-LOCAL_CFLAGS-2.cpp \
+
+LOCAL_CFLAGS := -DBANANA=100
+
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+#if !defined(BANANA)
+# error LOCAL_CFLAGS does not work for C source file
+#endif
+#if BANANA != 100
+# error LOCAL_CFLAGS does not work correctly for C source file
+#endif
+
+void __banana_foo1(void)
+{
+}
--- /dev/null
+#if !defined(BANANA)
+# error LOCAL_CFLAGS does not work for C++ source file
+#endif
+#if BANANA != 100
+# error LOCAL_CFLAGS does not work correctly for C++ source file
+#endif
+
+void __banana_foo2(void)
+{
+}
--- /dev/null
+# Test that LOCAL_CPPFLAGS only works for C++ sources
+#
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := test-LOCAL_CPPFLAGS
+LOCAL_SRC_FILES := test-LOCAL_CPPFLAGS-1.c \
+ test-LOCAL_CPPFLAGS-2.cpp \
+
+LOCAL_CFLAGS := -DBANANA=200
+
+# Note, the -UBANANA is only there to prevent a warning
+# the test works well without it.
+LOCAL_CPPFLAGS := -UBANANA -DBANANA=300
+
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+#if !defined(BANANA)
+# error LOCAL_CPPFLAGS does not work for C source file
+#endif
+#if BANANA != 200
+# error LOCAL_CPPFLAGS does not work correctly for C source file
+#endif
+
+void __banana_foo1(void)
+{
+}
--- /dev/null
+#if !defined(BANANA)
+# error LOCAL_CPPFLAGS does not work for C++ source file
+#endif
+#if BANANA != 300
+# error LOCAL_CPPFLAGS does not work correctly for C++ source file
+#endif
+
+void __banana_foo2(void)
+{
+}