This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch feature/refactor_bundle_cache
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/feature/refactor_bundle_cache
by this push:
new 350144f0 Add more test cases for error condition.
350144f0 is described below
commit 350144f0102ad256fdd10383689989188ced48fc
Author: PengZheng <[email protected]>
AuthorDate: Fri Mar 17 19:03:50 2023 +0800
Add more test cases for error condition.
---
libs/framework/gtest/src/CelixLauncherTestSuite.cc | 39 ++++++++++++++++++++++
libs/framework/src/bundle_archive.c | 1 +
2 files changed, 40 insertions(+)
diff --git a/libs/framework/gtest/src/CelixLauncherTestSuite.cc
b/libs/framework/gtest/src/CelixLauncherTestSuite.cc
index 201a3f0b..f7b22388 100644
--- a/libs/framework/gtest/src/CelixLauncherTestSuite.cc
+++ b/libs/framework/gtest/src/CelixLauncherTestSuite.cc
@@ -95,6 +95,45 @@ TEST_F(CelixLauncherTestSuite, ExtractBundlesTest) {
free(arg2);
}
+TEST_F(CelixLauncherTestSuite, ExtractNonexistentBundlesTest) {
+ //launch framework with bundle configured to start
+ //Given a properties set with 2 bundles configured for start
+ auto* props = celix_properties_create();
+ auto start = std::string{} + "nonexistent";
+ celix_properties_set(props, CELIX_AUTO_START_0, start.c_str());
+
+ //When I run the celixLauncher with "-c" argument
+ char* arg1 = celix_utils_strdup("programName");
+ char* arg2 = celix_utils_strdup("-c");
+ char* argv[] = {arg1, arg2};
+ int rc = celixLauncher_launchAndWaitForShutdown(2, argv, props);
+
+ //Then it will print the result of the extracted bundles and exit with 0
+ EXPECT_EQ(rc, 1);
+ free(arg1);
+ free(arg2);
+}
+
+TEST_F(CelixLauncherTestSuite, ExtractBundlesIntoTempTest) {
+ //launch framework with bundle configured to start
+ //Given a properties set with 2 bundles configured for start
+ auto* props = celix_properties_create();
+ auto start = std::string{} + SIMPLE_TEST_BUNDLE1_LOCATION + " " +
SIMPLE_TEST_BUNDLE2_LOCATION;
+ celix_properties_set(props, CELIX_AUTO_START_0, start.c_str());
+ celix_properties_setBool(props, CELIX_FRAMEWORK_CACHE_USE_TMP_DIR, true);
+
+ //When I run the celixLauncher with "-c" argument
+ char* arg1 = celix_utils_strdup("programName");
+ char* arg2 = celix_utils_strdup("-c");
+ char* argv[] = {arg1, arg2};
+ int rc = celixLauncher_launchAndWaitForShutdown(2, argv, props);
+
+ //Then it will print the result of the extracted bundles and exit with 0
+ EXPECT_EQ(rc, 1);
+ free(arg1);
+ free(arg2);
+}
+
TEST_F(CelixLauncherTestSuite, LaunchCelixTest) {
//launch framework with bundle configured to start
//Given a properties set with 2 bundles configured for start
diff --git a/libs/framework/src/bundle_archive.c
b/libs/framework/src/bundle_archive.c
index 0a585027..567e6854 100644
--- a/libs/framework/src/bundle_archive.c
+++ b/libs/framework/src/bundle_archive.c
@@ -243,6 +243,7 @@ celix_status_t
celix_bundleArchive_createArchiveInternal(celix_framework_t* fw,
archive->currentRevisionRoot = getcwd(NULL, 0);
archive->storeRoot = getcwd(NULL, 0);
} else {
+ // assert(location != NULL)
archive->location = celix_utils_strdup(location);
archive->archiveRoot = celix_utils_strdup(archiveRoot);
rc = asprintf(&archive->savedBundleStatePropertiesPath, "%s/%s",
archiveRoot,