Author: abroekhuis
Date: Thu Oct  3 20:03:49 2013
New Revision: 1528988

URL: http://svn.apache.org/r1528988
Log:
CELIX-55: Updated tests to work again. Fixed a small issue in the registry as a 
result. Also updated coverage handling to work again. Should now work on Linux 
and OSX.

Modified:
    incubator/celix/trunk/cmake/CodeCoverage.cmake
    incubator/celix/trunk/framework/CMakeLists.txt
    incubator/celix/trunk/framework/private/mock/framework_mock.c
    incubator/celix/trunk/framework/private/src/service_registry.c
    incubator/celix/trunk/framework/private/test/bundle_context_test.cpp
    incubator/celix/trunk/framework/private/test/service_registry_test.cpp
    incubator/celix/trunk/utils/CMakeLists.txt

Modified: incubator/celix/trunk/cmake/CodeCoverage.cmake
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/CodeCoverage.cmake?rev=1528988&r1=1528987&r2=1528988&view=diff
==============================================================================
--- incubator/celix/trunk/cmake/CodeCoverage.cmake (original)
+++ incubator/celix/trunk/cmake/CodeCoverage.cmake Thu Oct  3 20:03:49 2013
@@ -31,8 +31,9 @@ ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL 
 
 
 # Setup compiler options
-ADD_DEFINITIONS(-fprofile_rt)
-LINK_LIBRARIES(profile_rt)
+ADD_DEFINITIONS(--coverage)
+set(CMAKE_SHARED_LINKER_FLAGS "--coverage")
+set(CMAKE_EXE_LINKER_FLAGS "--coverage")
 
 
 add_custom_target(coverage

Modified: incubator/celix/trunk/framework/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/CMakeLists.txt?rev=1528988&r1=1528987&r2=1528988&view=diff
==============================================================================
--- incubator/celix/trunk/framework/CMakeLists.txt (original)
+++ incubator/celix/trunk/framework/CMakeLists.txt Thu Oct  3 20:03:49 2013
@@ -22,7 +22,6 @@ if (FRAMEWORK) 
     find_package(ZLIB REQUIRED)
     
     include(CPackComponent)
-    include(${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake)
     
     #cpack_add_component(framework
     #  DISPLAY_NAME Framework
@@ -71,8 +70,11 @@ if (FRAMEWORK) 
     FILE(GLOB files "public/include/*.h")
     INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
 
-       celix_subproject(FRAMEWORK_TESTS "Option to build the framework tests" 
"ON" DEPS)
+       celix_subproject(FRAMEWORK_TESTS "Option to build the framework tests" 
"OFF" DEPS)
     if (FRAMEWORK_TESTS)
+       include(${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake)
+       find_package(CppUTest REQUIRED)
+       
            include_directories(${CPPUTEST_INCLUDE_DIR})
            include_directories(${CPPUTEST_EXT_INCLUDE_DIR})
            

Modified: incubator/celix/trunk/framework/private/mock/framework_mock.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/framework_mock.c?rev=1528988&r1=1528987&r2=1528988&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/framework_mock.c (original)
+++ incubator/celix/trunk/framework/private/mock/framework_mock.c Thu Oct  3 
20:03:49 2013
@@ -25,7 +25,7 @@
  */
 #include "CppUTestExt/MockSupport_c.h"
 
-#include "framework.h"
+#include "framework_private.h"
 
 celix_status_t framework_create(framework_pt *framework, apr_pool_t 
*memoryPool, properties_pt config) {
        mock_c()->actualCall("framework_create");
@@ -148,19 +148,21 @@ celix_status_t fw_getServiceReferences(f
                return mock_c()->returnValue().value.intValue;
 }
 
-void * fw_getService(framework_pt framework, bundle_pt bundle, 
service_reference_pt reference) {
+celix_status_t fw_getService(framework_pt framework, bundle_pt bundle, 
service_reference_pt reference, void **service) {
        mock_c()->actualCall("fw_getService")
                ->withPointerParameters("framework", framework)
                ->withPointerParameters("bundle", bundle)
-               ->withPointerParameters("reference", reference);
-               return mock_c()->returnValue().value.pointerValue;
+               ->withPointerParameters("reference", reference)
+               ->_andPointerOutputParameters("service", service);
+               return mock_c()->returnValue().value.intValue;
 }
 
-bool framework_ungetService(framework_pt framework, bundle_pt bundle, 
service_reference_pt reference) {
+celix_status_t framework_ungetService(framework_pt framework, bundle_pt 
bundle, service_reference_pt reference, bool *result) {
        mock_c()->actualCall("framework_ungetService")
                ->withPointerParameters("framework", framework)
                ->withPointerParameters("bundle", bundle)
-               ->withPointerParameters("reference", reference);
+               ->withPointerParameters("reference", reference)
+               ->_andIntOutputParameters("result", result);
                return mock_c()->returnValue().value.intValue;
 }
 

Modified: incubator/celix/trunk/framework/private/src/service_registry.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registry.c?rev=1528988&r1=1528987&r2=1528988&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Thu Oct  3 
20:03:49 2013
@@ -389,14 +389,13 @@ celix_status_t serviceRegistry_getServic
        array_list_pt usages = hashMap_get(registry->inUseMap, bundle);
        if (usages != NULL) {
                unsigned int i;
-               array_list_pt references = NULL;
                apr_pool_t *pool = NULL;
                bundle_getMemoryPool(bundle, &pool);
                arrayList_create(pool, services);
                
                for (i = 0; i < arrayList_size(usages); i++) {
                        usage_count_pt usage = arrayList_get(usages, i);
-                       arrayList_add(references, usage->reference);
+                       arrayList_add(*services, usage->reference);
                }
        }
        return CELIX_SUCCESS;

Modified: incubator/celix/trunk/framework/private/test/bundle_context_test.cpp
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/test/bundle_context_test.cpp?rev=1528988&r1=1528987&r2=1528988&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/test/bundle_context_test.cpp 
(original)
+++ incubator/celix/trunk/framework/private/test/bundle_context_test.cpp Thu 
Oct  3 20:03:49 2013
@@ -321,7 +321,8 @@ TEST(bundle_context, getService) {
                .withParameter("framework", framework)
                .withParameter("bundle", bundle)
                .withParameter("reference", serviceReference)
-               .andReturnValue(service);
+               .andOutputParameter("service", service)
+               .andReturnValue(CELIX_SUCCESS);
 
        void *actualService = NULL;
        celix_status_t status = bundleContext_getService(context, 
serviceReference, &actualService);
@@ -348,7 +349,8 @@ TEST(bundle_context, ungetService) {
                .withParameter("framework", framework)
                .withParameter("bundle", bundle)
                .withParameter("reference", serviceReference)
-               .andReturnValue(result);
+               .andOutputParameter("result", result)
+               .andReturnValue(CELIX_SUCCESS);
 
        bool actualResult = NULL;
        celix_status_t status = bundleContext_ungetService(context, 
serviceReference, &actualResult);

Modified: incubator/celix/trunk/framework/private/test/service_registry_test.cpp
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/test/service_registry_test.cpp?rev=1528988&r1=1528987&r2=1528988&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/test/service_registry_test.cpp 
(original)
+++ incubator/celix/trunk/framework/private/test/service_registry_test.cpp Thu 
Oct  3 20:03:49 2013
@@ -63,12 +63,6 @@ TEST(service_registry, create) {
        framework_pt framework = (framework_pt) 0x10;
        service_registry_pt registry = NULL;
 
-       mock()
-               .expectOneCall("framework_getMemoryPool")
-               .withParameter("framework", framework)
-               .andOutputParameter("pool", pool)
-               .andReturnValue(CELIX_SUCCESS);
-
        serviceRegistry_create(pool, framework, 
serviceRegistryTest_serviceChanged, &registry);
 
        POINTERS_EQUAL(framework, registry->framework);
@@ -268,11 +262,6 @@ TEST(service_registry, unregisterService
                .andOutputParameter("references", references)
                .andReturnValue(CELIX_SUCCESS);
        mock()
-               .expectOneCall("framework_getMemoryPool")
-               .withParameter("framework", framework)
-               .andOutputParameter("pool", pool)
-               .andReturnValue(CELIX_SUCCESS);
-       mock()
                .expectOneCall("serviceReference_invalidate")
                .withParameter("reference", reference)
                .andReturnValue(CELIX_SUCCESS);
@@ -466,6 +455,7 @@ TEST(service_registry, ungetService) {
        arrayList_create(pool, &usages);
        usage_count_pt usage = (usage_count_pt) malloc(sizeof(*usage));
        usage->reference = reference;
+       apr_pool_create(&usage->pool, pool);
        arrayList_add(usages, usage);
        hashMap_put(registry->inUseMap, bundle, usages);
 
@@ -509,6 +499,7 @@ TEST(service_registry, ungetServivces) {
        arrayList_create(pool, &usages);
        usage_count_pt usage = (usage_count_pt) malloc(sizeof(*usage));
        usage->reference = reference;
+       apr_pool_create(&usage->pool, pool);
        arrayList_add(usages, usage);
        hashMap_put(registry->inUseMap, bundle, usages);
 

Modified: incubator/celix/trunk/utils/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/utils/CMakeLists.txt?rev=1528988&r1=1528987&r2=1528988&view=diff
==============================================================================
--- incubator/celix/trunk/utils/CMakeLists.txt (original)
+++ incubator/celix/trunk/utils/CMakeLists.txt Thu Oct  3 20:03:49 2013
@@ -50,7 +50,7 @@ if (UTILS) 
     FILE(GLOB files "public/include/*.h")
     INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
     
-    celix_subproject(UTILS-TESTS "Option to build the utilities library" "ON")
+    celix_subproject(UTILS-TESTS "Option to build the utilities library tests" 
"OFF")
     if (UTILS-TESTS)
            include_directories(${CUNIT_INCLUDE_DIRS})
            include_directories(${CPPUTEST_INCLUDE_DIR})


Reply via email to