aboutsummaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2009-07-27 12:26:17 +0200
committerDavid 'Digit' Turner <digit@google.com>2009-07-27 12:26:17 +0200
commitc6c4758cfcbfb2e04a63eb3dfeaa0ea85dfae325 (patch)
tree7c625623616e9e4e0006794e53ced011454ca1ce /sources
parent61697d20c6e38ce007db1243aebf0a89836c440e (diff)
downloadndk-c6c4758cfcbfb2e04a63eb3dfeaa0ea85dfae325.tar.gz
Add a "unit-tests" sample application to perform unit testing.
Diffstat (limited to 'sources')
-rw-r--r--sources/tests/Android.mk1
-rw-r--r--sources/tests/test-CLEAR_VARS/Android.mk43
-rw-r--r--sources/tests/test-LOCAL_CFLAGS/Android.mk13
-rw-r--r--sources/tests/test-LOCAL_CFLAGS/test-LOCAL_CFLAGS-1.c10
-rw-r--r--sources/tests/test-LOCAL_CFLAGS/test-LOCAL_CFLAGS-2.cpp10
-rw-r--r--sources/tests/test-LOCAL_CPPFLAGS/Android.mk17
-rw-r--r--sources/tests/test-LOCAL_CPPFLAGS/test-LOCAL_CPPFLAGS-1.c10
-rw-r--r--sources/tests/test-LOCAL_CPPFLAGS/test-LOCAL_CPPFLAGS-2.cpp10
8 files changed, 114 insertions, 0 deletions
diff --git a/sources/tests/Android.mk b/sources/tests/Android.mk
new file mode 100644
index 000000000..5053e7d64
--- /dev/null
+++ b/sources/tests/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/sources/tests/test-CLEAR_VARS/Android.mk b/sources/tests/test-CLEAR_VARS/Android.mk
new file mode 100644
index 000000000..fde4e7bb0
--- /dev/null
+++ b/sources/tests/test-CLEAR_VARS/Android.mk
@@ -0,0 +1,43 @@
+# 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)
diff --git a/sources/tests/test-LOCAL_CFLAGS/Android.mk b/sources/tests/test-LOCAL_CFLAGS/Android.mk
new file mode 100644
index 000000000..25348d133
--- /dev/null
+++ b/sources/tests/test-LOCAL_CFLAGS/Android.mk
@@ -0,0 +1,13 @@
+# 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)
diff --git a/sources/tests/test-LOCAL_CFLAGS/test-LOCAL_CFLAGS-1.c b/sources/tests/test-LOCAL_CFLAGS/test-LOCAL_CFLAGS-1.c
new file mode 100644
index 000000000..c14a62c8b
--- /dev/null
+++ b/sources/tests/test-LOCAL_CFLAGS/test-LOCAL_CFLAGS-1.c
@@ -0,0 +1,10 @@
+#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)
+{
+}
diff --git a/sources/tests/test-LOCAL_CFLAGS/test-LOCAL_CFLAGS-2.cpp b/sources/tests/test-LOCAL_CFLAGS/test-LOCAL_CFLAGS-2.cpp
new file mode 100644
index 000000000..4b769c0d5
--- /dev/null
+++ b/sources/tests/test-LOCAL_CFLAGS/test-LOCAL_CFLAGS-2.cpp
@@ -0,0 +1,10 @@
+#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)
+{
+}
diff --git a/sources/tests/test-LOCAL_CPPFLAGS/Android.mk b/sources/tests/test-LOCAL_CPPFLAGS/Android.mk
new file mode 100644
index 000000000..45c9b6d6c
--- /dev/null
+++ b/sources/tests/test-LOCAL_CPPFLAGS/Android.mk
@@ -0,0 +1,17 @@
+# 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)
diff --git a/sources/tests/test-LOCAL_CPPFLAGS/test-LOCAL_CPPFLAGS-1.c b/sources/tests/test-LOCAL_CPPFLAGS/test-LOCAL_CPPFLAGS-1.c
new file mode 100644
index 000000000..c5f2a6e38
--- /dev/null
+++ b/sources/tests/test-LOCAL_CPPFLAGS/test-LOCAL_CPPFLAGS-1.c
@@ -0,0 +1,10 @@
+#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)
+{
+}
diff --git a/sources/tests/test-LOCAL_CPPFLAGS/test-LOCAL_CPPFLAGS-2.cpp b/sources/tests/test-LOCAL_CPPFLAGS/test-LOCAL_CPPFLAGS-2.cpp
new file mode 100644
index 000000000..e8853e850
--- /dev/null
+++ b/sources/tests/test-LOCAL_CPPFLAGS/test-LOCAL_CPPFLAGS-2.cpp
@@ -0,0 +1,10 @@
+#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)
+{
+}