From fe06ceec142511fbffed04ed4a760ddf2a68d12c Mon Sep 17 00:00:00 2001 From: Edwin Wong Date: Tue, 26 Mar 2013 10:49:34 -0700 Subject: [PATCH] Separate unit and end-to-end tests from the top level makefie. The top level makefile will build license_protocol_protos.a, which is needed by libcdm.a. Unit and end-to-end tests are now build separately under cdm/test. Also, the tests use Google C++ Testing Framework, so please build the gtest library from external/gtest and run "mm" once before building the tests. Or just run "mmma vendor/widevine/libwvdrmengine" (or mma in vendor/widevine/libwvdrmengine") once. Change-Id: Iec5a7a974e2f23651191b7325230d9ae3d6b83f2 --- libwvdrmengine/Android.mk | 55 ++++++++++++++++++++-------- libwvdrmengine/cdm/Android.mk | 34 ++++------------- libwvdrmengine/cdm/test/Android.mk | 23 ++++++++++++ libwvdrmengine/cdm/test/unit-test.mk | 48 ++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 41 deletions(-) create mode 100644 libwvdrmengine/cdm/test/Android.mk create mode 100644 libwvdrmengine/cdm/test/unit-test.mk diff --git a/libwvdrmengine/Android.mk b/libwvdrmengine/Android.mk index 8666ef0a..18170ee1 100644 --- a/libwvdrmengine/Android.mk +++ b/libwvdrmengine/Android.mk @@ -1,4 +1,38 @@ +# ---------------------------------------------------------------- +# CDM top level makefile +# LOCAL_PATH := $(call my-dir) + +########################################################## +# ---------------------------------------------------------------- +# Builds the protobuf static library and generate .pb.cc and .pb.h +# license_protocol.pb.cc +# license_protocol.pb.h +# license_protocol.a +# +include $(CLEAR_VARS) + +LOCAL_MODULE := license_protocol_protos +LOCAL_MODULE_CLASS := STATIC_LIBRARIES + +LOCAL_C_INCLUDES := \ + bionic \ + external/stlport/stlport + +LOCAL_SRC_FILES := \ + $(call all-proto-files-under, cdm/core/src) + +LOCAL_EXPORT_C_INCLUDE_DIRS := \ + $(call local-intermediates-dir)/proto/$(LOCAL_PATH)/cdm/core/src + +include $(BUILD_STATIC_LIBRARY) + +# proto_generated_headers is a build system internal variable defined in $(BUILD_STATIC_LIBRARY). +# We can use cdm_proto_gen_headers later to establish the dependency. +cdm_proto_gen_headers := $(proto_generated_headers) + + +########################################################### include $(CLEAR_VARS) LOCAL_SRC_FILES := \ @@ -32,22 +66,10 @@ LOCAL_SHARED_LIBRARIES := \ libstlport \ libutils \ -# CDM's protobuffers are not part of the library -PROTO_SRC_DIR := $(proto_generated_cc_sources_dir)/$(LOCAL_PATH)/core/src - -LOCAL_SRC_FILES += \ - $(PROTO_SRC_DIR)/license_protocol.pb.cc \ - -LOCAL_C_INCLUDES += \ - $(proto_generated_cc_sources_dir)/$(LOCAL_PATH)/core/src \ - external/protobuf/src \ - -LOCAL_ADDITIONAL_DEPENDENCIES += $(proto_generated_headers) - LOCAL_WHOLE_STATIC_LIBRARIES := \ - license_protocol_protos \ + license_protocol_protos -# End protobuf section +LOCAL_ADDITIONAL_DEPENDENCIES := $(cdm_proto_gen_headers) LOCAL_MODULE := libwvdrmengine @@ -57,7 +79,10 @@ LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) -include vendor/widevine/libwvdrmengine/oemcrypto/mock/Android.mk include vendor/widevine/libwvdrmengine/cdm/Android.mk include vendor/widevine/libwvdrmengine/mediacrypto/Android.mk include vendor/widevine/libwvdrmengine/mediadrm/Android.mk +include vendor/widevine/libwvdrmengine/oemcrypto/mock/Android.mk + +# clean up temp vars +cdm_proto_gen_headers := diff --git a/libwvdrmengine/cdm/Android.mk b/libwvdrmengine/cdm/Android.mk index 97f6b4a3..780dacb2 100644 --- a/libwvdrmengine/cdm/Android.mk +++ b/libwvdrmengine/cdm/Android.mk @@ -1,28 +1,9 @@ -LOCAL_PATH := $(call my-dir) - -# ---------------------------------------------------------------- -# Builds the protobuf static library and generate .pb.cc and .pb.h -# license_protocol.pb.cc -# license_protocol.pb.h -# license_protocol.a -# -include $(CLEAR_VARS) -LOCAL_MODULE := license_protocol_protos -LOCAL_MODULE_CLASS := STATIC_LIBRARIES - -LOCAL_C_INCLUDES := \ - bionic \ - external/stlport/stlport - -LOCAL_SRC_FILES := \ - $(call all-proto-files-under, core/src) - -include $(BUILD_STATIC_LIBRARY) - # ---------------------------------------------------------------- # Builds libcdm.a # +LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) + LOCAL_C_INCLUDES := \ bionic \ external/stlport/stlport \ @@ -30,14 +11,12 @@ LOCAL_C_INCLUDES := \ vendor/widevine/libwvdrmengine/cdm/include \ vendor/widevine/libwvdrmengine/oemcrypto/include -# Add protocol buffer generated headers -# LOCAL_C_INCLUDES += \ - $(proto_generated_cc_sources_dir)/$(LOCAL_PATH)/core/src \ external/protobuf/src \ ../oemcrypto/include -LOCAL_ADDITIONAL_DEPENDENCIES += $(proto_generated_headers) +LOCAL_STATIC_LIBRARIES := license_protocol_protos +LOCAL_ADDITIONAL_DEPENDENCIES := $(cdm_proto_gen_headers) SRC_DIR := src CORE_SRC_DIR := core/src @@ -54,10 +33,13 @@ LOCAL_SRC_FILES := \ $(SRC_DIR)/lock.cpp \ $(SRC_DIR)/log.cpp \ $(SRC_DIR)/timer.cpp \ - $(SRC_DIR)/wv_content_decryption_module.cpp \ + $(SRC_DIR)/wv_content_decryption_module.cpp LOCAL_MODULE := libcdm LOCAL_MODULE_TAGS := optional include $(BUILD_STATIC_LIBRARY) +######################################################### +# include the tests. +include $(LOCAL_PATH)/test/Android.mk diff --git a/libwvdrmengine/cdm/test/Android.mk b/libwvdrmengine/cdm/test/Android.mk new file mode 100644 index 00000000..726d5843 --- /dev/null +++ b/libwvdrmengine/cdm/test/Android.mk @@ -0,0 +1,23 @@ +# ---------------------------------------------------------------- +# Builds CDM Tests +# +LOCAL_PATH := $(call my-dir) + +test_name := cdm_engine_test +test_src_dir := ../core/test +include $(LOCAL_PATH)/unit-test.mk + +test_name := http_socket_test +test_src_dir := ../core/test +include $(LOCAL_PATH)/unit-test.mk + +test_name := license_unittest +test_src_dir := ../core/test +include $(LOCAL_PATH)/unit-test.mk + +test_name := request_license_test +test_src_dir := . +include $(LOCAL_PATH)/unit-test.mk + +test_name := +test_src_dir := diff --git a/libwvdrmengine/cdm/test/unit-test.mk b/libwvdrmengine/cdm/test/unit-test.mk new file mode 100644 index 00000000..eed4addc --- /dev/null +++ b/libwvdrmengine/cdm/test/unit-test.mk @@ -0,0 +1,48 @@ +# ------------------------------------------------------------------- +# Makes a unit or end to end test. +# test_name must be passed in as the base filename(without the .cpp). +# +$(call assert-not-null,test_name) + +include $(CLEAR_VARS) + +LOCAL_MODULE := $(test_name) +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := \ + $(test_src_dir)/$(test_name).cpp \ + ../core/test/config_test_env.cpp \ + ../core/test/http_socket.cpp \ + ../core/test/license_request.cpp \ + ../core/test/url_request.cpp + +LOCAL_C_INCLUDES := \ + bionic \ + external/gtest/include \ + external/stlport/stlport \ + vendor/widevine/libwvdrmengine/cdm/core/include \ + vendor/widevine/libwvdrmengine/cdm/core/test \ + vendor/widevine/libwvdrmengine/cdm/include + +LOCAL_C_INCLUDES += \ + external/protobuf/src + +LOCAL_ADDITIONAL_DEPENDENCIES := $(cdm_proto_gen_headers) + +LOCAL_STATIC_LIBRARIES := \ + libcdm \ + libgtest \ + libgtest_main \ + libprotobuf-cpp-2.3.0-lite + +LOCAL_WHOLE_STATIC_LIBRARIES := \ + license_protocol_protos + +LOCAL_SHARED_LIBRARIES := \ + libstlport \ + libchromium_net \ + libcrypto \ + liboemcrypto \ + libutils + +include $(BUILD_EXECUTABLE)