audio: Add flags to makefiles
Enable GCOV if config is set to true. Also
add gcov_flush in source files to get enhanced
code coverage.
Change-Id: I39776cc6d6f16cd23da05b66669eea22fc4cba81
Signed-off-by: Vatsal Bucha <vbucha@codeaurora.org>
diff --git a/voice_processing/Android.mk b/voice_processing/Android.mk
index a39df33..5b865b7 100644
--- a/voice_processing/Android.mk
+++ b/voice_processing/Android.mk
@@ -20,6 +20,12 @@
liblog \
libcutils
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_GCOV)),true)
+LOCAL_CFLAGS += --coverage -fprofile-arcs -ftest-coverage
+LOCAL_CPPFLAGS += --coverage -fprofile-arcs -ftest-coverage
+LOCAL_STATIC_LIBRARIES += libprofile_rt
+endif
+
LOCAL_SHARED_LIBRARIES += libdl
LOCAL_HEADER_LIBRARIES := libhardware_headers
diff --git a/voice_processing/voice_processing.c b/voice_processing/voice_processing.c
index caf1cf7..32b76a5 100644
--- a/voice_processing/voice_processing.c
+++ b/voice_processing/voice_processing.c
@@ -43,6 +43,18 @@
NUM_ID
};
+#ifdef AUDIO_FEATURE_ENABLED_GCOV
+extern void __gcov_flush();
+static void enable_gcov()
+{
+ __gcov_flush();
+}
+#else
+static void enable_gcov()
+{
+}
+#endif
+
// Session state
enum session_state {
SESSION_STATE_INIT, // initialized
@@ -711,6 +723,7 @@
list_remove(&session->node);
free(session);
}
+ enable_gcov();
return status;
}
@@ -732,7 +745,7 @@
return 0;
}
}
-
+ enable_gcov();
return -EINVAL;
}