This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/export_headers in repository https://gitbox.apache.org/repos/asf/celix.git
commit 01cdb31d42493c29bd2a7d6817d61ba6c65f7c52 Author: Pepijn Noltes <[email protected]> AuthorDate: Sun Apr 16 22:04:07 2023 +0200 Add export macro for private functions used in unit tests --- .../BundleArchiveWithErrorInjectionTestSuite.cc | 28 +++++++++++----------- libs/framework/src/bundle_archive.c | 6 ++--- libs/framework/src/bundle_archive_private.h | 4 ++-- libs/framework/src/bundle_revision.c | 4 ++-- libs/framework/src/bundle_revision_private.h | 4 +++- libs/framework/src/celix_bundle_cache.c | 2 +- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc b/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc index 238535eb..350fd3f1 100644 --- a/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc +++ b/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc @@ -27,9 +27,9 @@ #include "asprintf_ei.h" //extern declarations for testing purposes. Note signatures are not correct, but that is not important for the test. -extern "C" celix_status_t bundleArchive_create(void); +extern "C" celix_status_t celix_bundleArchive_create(void); extern "C" celix_status_t manifest_create(void); -extern "C" celix_status_t bundleRevision_create(void); +extern "C" celix_status_t celix_bundleRevision_create(void); class BundleArchiveWithErrorInjectionTestSuite : public ::testing::Test { public: @@ -75,12 +75,12 @@ protected: TEST_F(BundleArchiveWithErrorInjectionTestSuite, BundleArchiveCreatedFailedTest) { teardownErrorInjectors(); //Given a mocked calloc which returns NULL from a (indirect) call from bundleArchive_create - celix_ei_expect_calloc((void*)bundleArchive_create, 1, nullptr); + celix_ei_expect_calloc((void*)celix_bundleArchive_create, 1, nullptr); installBundleAndExpectFailure(); teardownErrorInjectors(); //Given a mocked celix_utils_strdup which returns NULL from a (indirect) call from bundleArchive_create - celix_ei_expect_celix_utils_strdup((void*)bundleArchive_create, 1, nullptr); + celix_ei_expect_celix_utils_strdup((void*)celix_bundleArchive_create, 1, nullptr); installBundleAndExpectFailure(); teardownErrorInjectors(); @@ -90,15 +90,15 @@ TEST_F(BundleArchiveWithErrorInjectionTestSuite, BundleArchiveCreatedFailedTest) teardownErrorInjectors(); //Given a mocked calloc which returns NULL from a call from bundleRevision_create - celix_ei_expect_calloc((void*)bundleRevision_create, 0, nullptr); + celix_ei_expect_calloc((void*)celix_bundleRevision_create, 0, nullptr); installBundleAndExpectFailure(); teardownErrorInjectors(); //Given a mocked celix_utils_strdup which returns NULL from a call from bundleRevision_create - celix_ei_expect_celix_utils_strdup((void*)bundleRevision_create, 0, nullptr); + celix_ei_expect_celix_utils_strdup((void*)celix_bundleRevision_create, 0, nullptr); installBundleAndExpectFailure(); - celix_ei_expect_celix_utils_strdup((void*)bundleRevision_create, 0, nullptr, 2); + celix_ei_expect_celix_utils_strdup((void*)celix_bundleRevision_create, 0, nullptr, 2); installBundleAndExpectFailure(); } @@ -106,38 +106,38 @@ TEST_F(BundleArchiveWithErrorInjectionTestSuite, BundleArchiveCreateCacheDirecto teardownErrorInjectors(); //Given a mocked celix_utils_createDirectory which returns CELIX_FILE_IO_EXCEPTION from a (indirect) call from //bundleArchive_create - celix_ei_expect_celix_utils_createDirectory((void*)bundleArchive_create, 2, CELIX_FILE_IO_EXCEPTION); + celix_ei_expect_celix_utils_createDirectory((void*)celix_bundleArchive_create, 2, CELIX_FILE_IO_EXCEPTION); installBundleAndExpectFailure(); teardownErrorInjectors(); //Given a mocked asprintf which returns -1 from a (indirect) call from bundleArchive_create - celix_ei_expect_asprintf((void*)bundleArchive_create, 2, -1); + celix_ei_expect_asprintf((void*)celix_bundleArchive_create, 2, -1); installBundleAndExpectFailure(); teardownErrorInjectors(); //Given a mocked celix_utils_createDirectory which returns CELIX_FILE_IO_EXCEPTION from a second (indirect) call // from bundleArchive_create - celix_ei_expect_celix_utils_createDirectory((void*)bundleArchive_create, 2, CELIX_FILE_IO_EXCEPTION, 2); + celix_ei_expect_celix_utils_createDirectory((void*)celix_bundleArchive_create, 2, CELIX_FILE_IO_EXCEPTION, 2); installBundleAndExpectFailure(); teardownErrorInjectors(); //Given a mocked asprintf which returns -1 from a (indirect) call from bundleArchive_create - celix_ei_expect_asprintf((void*)bundleArchive_create, 2, -1, 2); + celix_ei_expect_asprintf((void*)celix_bundleArchive_create, 2, -1, 2); installBundleAndExpectFailure(); teardownErrorInjectors(); //Given a mocked celix_utils_createDirectory which returns CELIX_FILE_IO_EXCEPTION from a third (indirect) call // from bundleArchive_create - celix_ei_expect_celix_utils_createDirectory((void*)bundleArchive_create, 2, CELIX_FILE_IO_EXCEPTION, 3); + celix_ei_expect_celix_utils_createDirectory((void*)celix_bundleArchive_create, 2, CELIX_FILE_IO_EXCEPTION, 3); installBundleAndExpectFailure(); teardownErrorInjectors(); //Given a mocked celix_utils_strdup which returns NULL from a (indirect) call from bundleArchive_create - celix_ei_expect_celix_utils_strdup((void*)bundleArchive_create, 2, nullptr); + celix_ei_expect_celix_utils_strdup((void*)celix_bundleArchive_create, 2, nullptr); installBundleAndExpectFailure(); teardownErrorInjectors(); //Given a mocked celix_utils_strdup which returns NULL from a second (indirect) call from bundleArchive_create - celix_ei_expect_celix_utils_strdup((void*)bundleArchive_create, 2, nullptr, 2); + celix_ei_expect_celix_utils_strdup((void*)celix_bundleArchive_create, 2, nullptr, 2); installBundleAndExpectFailure(); } diff --git a/libs/framework/src/bundle_archive.c b/libs/framework/src/bundle_archive.c index 87856a9a..b06300b8 100644 --- a/libs/framework/src/bundle_archive.c +++ b/libs/framework/src/bundle_archive.c @@ -263,9 +263,9 @@ celix_status_t celix_bundleArchive_createArchiveInternal(celix_framework_t* fw, } if (archive->isSystemBundle) { - status = bundleRevision_create(fw, archive->archiveRoot, NULL, manifest, &archive->revision); + status = celix_bundleRevision_create(fw, archive->archiveRoot, NULL, manifest, &archive->revision); } else { - status = bundleRevision_create(fw, archive->archiveRoot, archive->location, manifest, &archive->revision); + status = celix_bundleRevision_create(fw, archive->archiveRoot, archive->location, manifest, &archive->revision); } if (status != CELIX_SUCCESS) { fw_logCode(fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Could not create archive. Could not create bundle revision."); @@ -281,7 +281,7 @@ celix_status_t celix_bundleArchive_createArchiveInternal(celix_framework_t* fw, return status; } -celix_status_t bundleArchive_create(celix_framework_t* fw, const char *archiveRoot, long id, const char *location, bundle_archive_pt *bundle_archive) { +celix_status_t celix_bundleArchive_create(celix_framework_t* fw, const char *archiveRoot, long id, const char *location, bundle_archive_pt *bundle_archive) { return celix_bundleArchive_createArchiveInternal(fw, archiveRoot, id, location, bundle_archive); } diff --git a/libs/framework/src/bundle_archive_private.h b/libs/framework/src/bundle_archive_private.h index aafd28c5..f4974cf5 100644 --- a/libs/framework/src/bundle_archive_private.h +++ b/libs/framework/src/bundle_archive_private.h @@ -41,9 +41,9 @@ extern "C" { /** * @brief Create bundle archive. - * + * @note Symbol exported for testing purposes. */ -celix_status_t bundleArchive_create(celix_framework_t* fw, const char *archiveRoot, long id, const char *location, bundle_archive_pt *bundle_archive); +CELIX_FRAMEWORK_EXPORT celix_status_t celix_bundleArchive_create(celix_framework_t* fw, const char *archiveRoot, long id, const char *location, bundle_archive_pt *bundle_archive); celix_status_t bundleArchive_destroy(bundle_archive_pt archive); diff --git a/libs/framework/src/bundle_revision.c b/libs/framework/src/bundle_revision.c index 704d7679..febbeb41 100644 --- a/libs/framework/src/bundle_revision.c +++ b/libs/framework/src/bundle_revision.c @@ -23,7 +23,7 @@ #include "bundle_revision_private.h" #include "framework_private.h" -celix_status_t bundleRevision_create(celix_framework_t* fw, const char *root, const char *location, manifest_pt manifest, bundle_revision_pt *bundle_revision) { +celix_status_t celix_bundleRevision_create(celix_framework_t* fw, const char *root, const char *location, manifest_pt manifest, bundle_revision_pt *bundle_revision) { celix_status_t status = CELIX_SUCCESS; bundle_revision_pt revision = calloc(1, sizeof(*revision)); if (revision != NULL) { @@ -55,7 +55,7 @@ celix_status_t bundleRevision_create(celix_framework_t* fw, const char *root, co bundle_revision_t* bundleRevision_revise(const bundle_revision_t* rev, const char* updatedBundleUrl) { bundle_revision_pt newRev = NULL; manifest_pt clonedManifest = manifest_clone(rev->manifest); - bundleRevision_create(rev->fw, rev->root, updatedBundleUrl, clonedManifest, &newRev); + celix_bundleRevision_create(rev->fw, rev->root, updatedBundleUrl, clonedManifest, &newRev); return newRev; } diff --git a/libs/framework/src/bundle_revision_private.h b/libs/framework/src/bundle_revision_private.h index b74dc92b..7a165339 100644 --- a/libs/framework/src/bundle_revision_private.h +++ b/libs/framework/src/bundle_revision_private.h @@ -50,6 +50,8 @@ struct bundleRevision { * Creates a new revision for the given inputFile or location. * The location parameter is used to identify the bundle. * + * @note Symbol exported for testing purposes. + * * @param fw The Celix framework where to create the bundle revision. * @param root The root for this revision in which the bundle is extracted and state is stored. * @param location The location associated with the revision. @@ -60,7 +62,7 @@ struct bundleRevision { * - CELIX_SUCCESS when no errors are encountered. * - CELIX_ENOMEM If allocating memory for <code>bundle_revision</code> failed. */ -celix_status_t bundleRevision_create(celix_framework_t* fw, const char *root, const char *location, manifest_pt manifest, bundle_revision_pt *bundle_revision); +CELIX_FRAMEWORK_EXPORT celix_status_t celix_bundleRevision_create(celix_framework_t* fw, const char *root, const char *location, manifest_pt manifest, bundle_revision_pt *bundle_revision); bundle_revision_t* bundleRevision_revise(const bundle_revision_t* revision, const char* updatedBundleUrl); diff --git a/libs/framework/src/celix_bundle_cache.c b/libs/framework/src/celix_bundle_cache.c index d4a7941c..c315164a 100644 --- a/libs/framework/src/celix_bundle_cache.c +++ b/libs/framework/src/celix_bundle_cache.c @@ -193,7 +193,7 @@ celix_status_t celix_bundleCache_createArchive(celix_framework_t* fw, long id, c char *archiveRoot = celix_utils_writeOrCreateString(archiveRootBuffer, sizeof(archiveRootBuffer), CELIX_BUNDLE_ARCHIVE_ROOT_FORMAT, fw->cache->cacheDir, id); if (archiveRoot) { celixThreadMutex_lock(&fw->cache->mutex); - status = bundleArchive_create(fw, archiveRoot, id, location, &archive); + status = celix_bundleArchive_create(fw, archiveRoot, id, location, &archive); celixThreadMutex_unlock(&fw->cache->mutex); celix_utils_freeStringIfNotEqual(archiveRootBuffer, archiveRoot); } else {
