Skip to content

Commit

Permalink
CELIX-290: fixed cmake warning in framework/CMakelist.txt (removed br…
Browse files Browse the repository at this point in the history
…ackets from [COPYONLY] at line 351/353),

fixed build warning in framework bundle_cache_test.cpp (mktemp depricated, used mkstemp instead),
fixed a dev note accidentaly left in framework service_registry_test.cpp (used preprocessor symbol as dev note, will not do again),
fixed a lot of the framework mocks, used to not assign any of the output parameters, resulting in undefined behaviour,
updated most framework tests to accommodate for the mock changes,
expanded framework resolver test (WIP)
  • Loading branch information
bpetri committed Nov 11, 2015
1 parent b307757 commit 1b7b3e8
Show file tree
Hide file tree
Showing 31 changed files with 557 additions and 220 deletions.
10 changes: 5 additions & 5 deletions framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ if (FRAMEWORK)
private/mock/requirement_mock.c
private/mock/capability_mock.c
private/mock/manifest_parser_mock.c
private/mock/wire_mock.c
private/mock/version_mock.c
private/src/wire.c
private/src/module.c
private/src/resolver.c
private/src/celix_errorcodes.c
Expand Down Expand Up @@ -348,9 +348,9 @@ if (FRAMEWORK)
private/test/wire_test.cpp)
target_link_libraries(wire_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY})

configure_file(private/resources-test/manifest_sections.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest_sections.txt [COPYONLY])
configure_file(private/resources-test/manifest.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest.txt [COPYONLY])
configure_file(private/resources-test/properties.txt ${CMAKE_BINARY_DIR}/framework/resources-test/properties.txt [COPYONLY])
configure_file(private/resources-test/manifest_sections.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest_sections.txt COPYONLY)
configure_file(private/resources-test/manifest.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest.txt COPYONLY)
configure_file(private/resources-test/properties.txt ${CMAKE_BINARY_DIR}/framework/resources-test/properties.txt COPYONLY)

#set_target_properties(wire_test PROPERTIES COMPILE_FLAGS "-include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorMallocMacros.h -include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorNewMacros.h")

Expand Down Expand Up @@ -381,7 +381,7 @@ if (FRAMEWORK)
add_test(NAME wire_test COMMAND wire_test)

SETUP_TARGET_FOR_COVERAGE(attribute_test attribute_test ${CMAKE_BINARY_DIR}/coverage/attribute_test/attribute_test)
SETUP_TARGET_FOR_COVERAGE(bundle_archive_test bundle_archive_test ${CMAKE_BINARY_DIR}/coverage/bundle_archive/bundle_archive_test)
SETUP_TARGET_FOR_COVERAGE(bundle_archive_test bundle_archive_test ${CMAKE_BINARY_DIR}/coverage/bundle_archive_test/bundle_archive_test)
SETUP_TARGET_FOR_COVERAGE(bundle_cache_test bundle_cache_test ${CMAKE_BINARY_DIR}/coverage/bundle_cache_test/bundle_cache_test)
SETUP_TARGET_FOR_COVERAGE(bundle_context_test bundle_context_test ${CMAKE_BINARY_DIR}/coverage/bundle_context_test/bundle_context_test)
SETUP_TARGET_FOR_COVERAGE(bundle_revision_test bundle_revision_test ${CMAKE_BINARY_DIR}/coverage/bundle_revision_test/bundle_revision_test)
Expand Down
38 changes: 29 additions & 9 deletions framework/private/mock/bundle_archive_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,39 @@ celix_status_t bundleArchive_getId(bundle_archive_pt archive, long *id) {
}

celix_status_t bundleArchive_getLocation(bundle_archive_pt archive, char **location) {
mock_c()->actualCall("bundleArchive_getLocation");
mock_c()->actualCall("bundleArchive_getLocation")
->withPointerParameters("archive", archive)
->withOutputParameter("location", location);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleArchive_getArchiveRoot(bundle_archive_pt archive, char **archiveRoot) {
mock_c()->actualCall("bundleArchive_getArchiveRoot");
mock_c()->actualCall("bundleArchive_getArchiveRoot")
->withPointerParameters("archive", archive)
->withOutputParameter("archiveRoot", archiveRoot);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleArchive_revise(bundle_archive_pt archive, char * location, char *inputFile) {
mock_c()->actualCall("bundleArchive_revise");
mock_c()->actualCall("bundleArchive_revise")
->withPointerParameters("archive", archive)
->withStringParameters("location", location)
->withStringParameters("inputFile", inputFile);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleArchive_rollbackRevise(bundle_archive_pt archive, bool *rolledback) {
mock_c()->actualCall("bundleArchive_rollbackRevise");
mock_c()->actualCall("bundleArchive_rollbackRevise")
->withPointerParameters("archive", archive)
->withOutputParameter("rolledback", rolledback);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleArchive_getRevision(bundle_archive_pt archive, long revNr, bundle_revision_pt *revision) {
mock_c()->actualCall("bundleArchive_getRevision");
mock_c()->actualCall("bundleArchive_getRevision")
->withPointerParameters("archive", archive)
->withLongIntParameters("revNr", revNr)
->withOutputParameter("revision", revision);
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -95,12 +107,16 @@ celix_status_t bundleArchive_getCurrentRevision(bundle_archive_pt archive, bundl
}

celix_status_t bundleArchive_getCurrentRevisionNumber(bundle_archive_pt archive, long *revisionNumber) {
mock_c()->actualCall("bundleArchive_getCurrentRevisionNumber");
mock_c()->actualCall("bundleArchive_getCurrentRevisionNumber")
->withPointerParameters("archive", archive)
->withOutputParameter("revisionNumber", revisionNumber);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleArchive_getRefreshCount(bundle_archive_pt archive, long *refreshCount) {
mock_c()->actualCall("bundleArchive_getRefreshCount");
mock_c()->actualCall("bundleArchive_getRefreshCount")
->withPointerParameters("archive", archive)
->withOutputParameter("refreshCount", refreshCount);
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -126,7 +142,9 @@ celix_status_t bundleArchive_setLastModified(bundle_archive_pt archive, time_t l
}

celix_status_t bundleArchive_getLastModified(bundle_archive_pt archive, time_t *lastModified) {
mock_c()->actualCall("bundleArchive_getLastModified");
mock_c()->actualCall("bundleArchive_getLastModified")
->withPointerParameters("archive", archive)
->withOutputParameter("lastModified", lastModified);
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -138,7 +156,9 @@ celix_status_t bundleArchive_setPersistentState(bundle_archive_pt archive, bundl
}

celix_status_t bundleArchive_getPersistentState(bundle_archive_pt archive, bundle_state_e *state) {
mock_c()->actualCall("bundleArchive_getPersistentState");
mock_c()->actualCall("bundleArchive_getPersistentState")
->withPointerParameters("archive", archive)
->withOutputParameter("state", state);
return mock_c()->returnValue().value.intValue;
}

15 changes: 12 additions & 3 deletions framework/private/mock/bundle_cache_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include "bundle_cache.h"

celix_status_t bundleCache_create(properties_pt configurationMap, bundle_cache_pt *bundle_cache) {
mock_c()->actualCall("bundleCache_create");
mock_c()->actualCall("bundleCache_create")
->withPointerParameters("configurationMap", configurationMap)
->withOutputParameter("bundle_cache", bundle_cache);
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -38,12 +40,19 @@ celix_status_t bundleCache_destroy(bundle_cache_pt *cache) {
}

celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *archives) {
mock_c()->actualCall("bundleCache_getArchives");
mock_c()->actualCall("bundleCache_getArchives")
->withPointerParameters("cache", cache)
->withOutputParameter("archives", archives);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleCache_createArchive(bundle_cache_pt cache, long id, char * location, char *inputFile, bundle_archive_pt *archive) {
mock_c()->actualCall("bundleCache_createArchive");
mock_c()->actualCall("bundleCache_createArchive")
->withPointerParameters("cache", cache)
->withLongIntParameters("id", id)
->withStringParameters("location", location)
->withStringParameters("inputFile", inputFile)
->withOutputParameter("archive", archive);
return mock_c()->returnValue().value.intValue;
}

Expand Down
28 changes: 18 additions & 10 deletions framework/private/mock/bundle_context_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
#include "bundle_context.h"

celix_status_t bundleContext_create(framework_pt framework, framework_logger_pt logger, bundle_pt bundle, bundle_context_pt *bundle_context) {
mock_c()->actualCall("bundleContext_create")
->withPointerParameters("framework", framework)
->withPointerParameters("logger", logger)
->withPointerParameters("bundle", bundle)
mock_c()->actualCall("bundleContext_create")
->withPointerParameters("framework", framework)
->withPointerParameters("logger", logger)
->withPointerParameters("bundle", bundle)
->withOutputParameter("bundle_context", (void **) bundle_context);
return mock_c()->returnValue().value.intValue;
}
Expand All @@ -50,12 +50,12 @@ celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_p
mock_c()->actualCall("bundleContext_getFramework")
->withPointerParameters("context", context)
->withOutputParameter("framework", (void **) framework);
return mock_c()->returnValue().value.intValue;
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleContext_installBundle(bundle_context_pt context, char * location, bundle_pt *bundle) {
mock_c()->actualCall("bundleContext_installBundle")
->withPointerParameters("context", context)
mock_c()->actualCall("bundleContext_installBundle")
->withPointerParameters("context", context)
->withStringParameters("location", location)
->withOutputParameter("bundle", (void **) bundle);
return mock_c()->returnValue().value.intValue;
Expand Down Expand Up @@ -136,12 +136,17 @@ celix_status_t bundleContext_ungetService(bundle_context_pt context, service_ref


celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles) {
mock_c()->actualCall("bundleContext_getBundles");
mock_c()->actualCall("bundleContext_getBundles")
->withPointerParameters("context", context)
->withOutputParameter("bundles", bundles);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle) {
mock_c()->actualCall("bundleContext_getBundleById");
mock_c()->actualCall("bundleContext_getBundleById")
->withPointerParameters("context", context)
->withLongIntParameters("id", id)
->withOutputParameter("bundle", bundle);
return mock_c()->returnValue().value.intValue;
}

Expand Down Expand Up @@ -174,6 +179,9 @@ celix_status_t bundleContext_removeBundleListener(bundle_context_pt context, bun


celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, char **value) {
mock_c()->actualCall("bundleContext_getProperty");
mock_c()->actualCall("bundleContext_getProperty")
->withPointerParameters("context", context)
->withStringParameters("name", name)
->withOutputParameter("value", value);
return mock_c()->returnValue().value.intValue;
}
48 changes: 36 additions & 12 deletions framework/private/mock/bundle_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include "bundle_private.h"

celix_status_t bundle_create(bundle_pt * bundle) {
mock_c()->actualCall("bundle_create");
mock_c()->actualCall("bundle_create")
->withOutputParameter("bundle", bundle);
return mock_c()->returnValue().value.intValue;
}

Expand Down Expand Up @@ -90,7 +91,9 @@ celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator) {
}

celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context) {
mock_c()->actualCall("bundle_getContext");
mock_c()->actualCall("bundle_getContext")
->withPointerParameters("bundle", bundle)
->withOutputParameter("context", context);
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -100,7 +103,10 @@ celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context) {
}

celix_status_t bundle_getEntry(bundle_pt bundle, char * name, char **entry) {
mock_c()->actualCall("bundle_getEntry");
mock_c()->actualCall("bundle_getEntry")
->withPointerParameters("bundle", bundle)
->withStringParameters("name", name)
->withOutputParameter("entry", entry);
return mock_c()->returnValue().value.intValue;
}

Expand Down Expand Up @@ -186,27 +192,37 @@ int compareTo(service_reference_pt a, service_reference_pt b) {


celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state) {
mock_c()->actualCall("bundle_getState");
mock_c()->actualCall("bundle_getState")
->withPointerParameters("bundle", bundle)
->withOutputParameter("state", state);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_isLockable(bundle_pt bundle, bool *lockable) {
mock_c()->actualCall("bundle_isLockable");
mock_c()->actualCall("bundle_isLockable")
->withPointerParameters("bundle", bundle)
->withOutputParameter("lockable", lockable);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getLockingThread(bundle_pt bundle, celix_thread_t *thread) {
mock_c()->actualCall("bundle_getLockingThread");
mock_c()->actualCall("bundle_getLockingThread")
->withPointerParameters("bundle", bundle)
->withOutputParameter("thread", thread);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_lock(bundle_pt bundle, bool *locked) {
mock_c()->actualCall("bundle_lock");
mock_c()->actualCall("bundle_lock")
->withPointerParameters("bundle", bundle)
->withOutputParameter("locked", locked);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_unlock(bundle_pt bundle, bool *unlocked) {
mock_c()->actualCall("bundle_unlock");
mock_c()->actualCall("bundle_unlock")
->withPointerParameters("bundle", bundle)
->withOutputParameter("unlocked", unlocked);
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -228,18 +244,24 @@ celix_status_t bundle_refresh(bundle_pt bundle) {
}

celix_status_t bundle_getBundleId(bundle_pt bundle, long *id) {
mock_c()->actualCall("bundle_getBundleId");
mock_c()->actualCall("bundle_getBundleId")
->withPointerParameters("bundle", bundle)
->withOutputParameter("id", id);
return mock_c()->returnValue().value.intValue;
}


celix_status_t bundle_getRegisteredServices(bundle_pt bundle, array_list_pt *list) {
mock_c()->actualCall("bundle_getRegisteredServices");
mock_c()->actualCall("bundle_getRegisteredServices")
->withPointerParameters("bundle", bundle)
->withOutputParameter("list", list);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getServicesInUse(bundle_pt bundle, array_list_pt *list) {
mock_c()->actualCall("bundle_getServicesInUse");
mock_c()->actualCall("bundle_getServicesInUse")
->withPointerParameters("bundle", bundle)
->withOutputParameter("list", list);
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -249,7 +271,9 @@ celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework) {
}

celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework) {
mock_c()->actualCall("bundle_getFramework");
mock_c()->actualCall("bundle_getFramework")
->withPointerParameters("bundle", bundle)
->withOutputParameter("framework", framework);
return mock_c()->returnValue().value.intValue;
}

Expand Down
19 changes: 15 additions & 4 deletions framework/private/mock/bundle_revision_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
#include "bundle_revision.h"

celix_status_t bundleRevision_create(char *root, char *location, long revisionNr, char *inputFile, bundle_revision_pt *bundle_revision) {
mock_c()->actualCall("bundleRevision_create");
mock_c()->actualCall("bundleRevision_create")
->withStringParameters("root", root)
->withStringParameters("location", location)
->withLongIntParameters("revisionNr", revisionNr)
->withStringParameters("inputFile", inputFile)
->withOutputParameter("bundle_revision", bundle_revision);
return mock_c()->returnValue().value.intValue;
}

Expand All @@ -38,17 +43,23 @@ celix_status_t bundleRevision_destroy(bundle_revision_pt revision) {
}

celix_status_t bundleRevision_getNumber(bundle_revision_pt revision, long *revisionNr) {
mock_c()->actualCall("bundleRevision_getNumber");
mock_c()->actualCall("bundleRevision_getNumber")
->withPointerParameters("revision", revision)
->withOutputParameter("revisionNr", revisionNr);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleRevision_getLocation(bundle_revision_pt revision, char **location) {
mock_c()->actualCall("bundleRevision_getLocation");
mock_c()->actualCall("bundleRevision_getLocation")
->withPointerParameters("revision", revision)
->withOutputParameter("location", location);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundleRevision_getRoot(bundle_revision_pt revision, char **root) {
mock_c()->actualCall("bundleRevision_getRoot");
mock_c()->actualCall("bundleRevision_getRoot")
->withPointerParameters("revision", revision)
->withOutputParameter("root", root);
return mock_c()->returnValue().value.intValue;
}

Expand Down
9 changes: 7 additions & 2 deletions framework/private/mock/capability_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@
#include "capability.h"

celix_status_t capability_create(module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability) {
mock_c()->actualCall("capability_create");
mock_c()->actualCall("capability_create")
->withPointerParameters("module", module)
->withPointerParameters("directives", directives)
->withPointerParameters("attributes", attributes)
->withOutputParameter("capability", capability);
return mock_c()->returnValue().value.intValue;
}

celix_status_t capability_destroy(capability_pt capability) {
mock_c()->actualCall("capability_destroy");
mock_c()->actualCall("capability_destroy")
->withPointerParameters("capability", capability);
return mock_c()->returnValue().value.intValue;
}

Expand Down
Loading

0 comments on commit 1b7b3e8

Please sign in to comment.