Skip to content
Permalink
Browse files
Add missing find_dependency in CelixConfig.cmake, and add test_packag…
…e for etcdlib, launcher, and promises.
  • Loading branch information
PengZheng committed Mar 18, 2022
1 parent b34e5ff commit 93f358de4fad1b0c9015404903b0064eb1e3f8fa
Showing 8 changed files with 101 additions and 6 deletions.
@@ -116,3 +116,6 @@ endif ()
if (TARGET Celix::pubsub_admin_nanomsg)
find_dependency(NanoMsg)
endif ()
if (TARGET Celix::Promises)
find_dependency(Threads)
endif ()
@@ -16,7 +16,7 @@
# under the License.

from conans import ConanFile, CMake, tools
from conans.errors import ConanException, ConanInvalidConfiguration
from conans.errors import ConanInvalidConfiguration
import os


@@ -89,3 +89,21 @@ option(TEST_SHELL_WUI "Test shell WUI" OFF)
if(TEST_SHELL_WUI)
add_celix_container("use_shell_wui" BUNDLES Celix::shell Celix::shell_wui hello)
endif ()

option(TEST_ETCD_LIB "Test ETCD lib" OFF)
if (TEST_ETCD_LIB)
add_executable(use_etcd_lib test_etcd_lib.c)
target_link_libraries(use_etcd_lib PRIVATE Celix::etcdlib)
endif ()

option(TEST_LAUNCHER "Test launcher" OFF)
if (TEST_LAUNCHER)
get_target_property(LAUNCHER_LOCATION Celix::launcher LOCATION)
add_celix_container("use_launcher" LAUNCHER ${LAUNCHER_LOCATION} USE_CONFIG BUNDLES hello)
endif ()

option(TEST_PROMISES "Test promises" OFF)
if (TEST_PROMISES)
add_executable(use_promises test_promises.cpp)
target_link_libraries(use_promises PRIVATE Celix::Promises)
endif ()
@@ -24,8 +24,8 @@ class TestPackageConan(ConanFile):
generators = "cmake_paths"

def requirements(self):
# for test_package, `requires` is set by conan, and thus not needed
# the following make the test package can be used as a standalone package consumer
# strictly speaking, `requires`, which should be set by 'conan test', is not needed by test_package
# the following makes clion conan plugin work
if not self.requires:
self.requires("celix/2.2.3@zhengpeng/testing")

@@ -38,6 +38,10 @@ def build(self):
cmake.definitions["TEST_REMOTE_SHELL"] = self.options["celix"].build_remote_shell
cmake.definitions["TEST_SHELL_TUI"] = self.options["celix"].build_shell_tui
cmake.definitions["TEST_SHELL_WUI"] = self.options["celix"].build_shell_wui
cmake.definitions["TEST_ETCD_LIB"] = self.options["celix"].build_celix_etcdlib
cmake.definitions["TEST_LAUNCHER"] = self.options["celix"].build_launcher
cmake.definitions["TEST_PROMISES"] = self.options["celix"].build_promises
# cmake.definitions["TEST_PUSHSTREAMS"] = self.options["celix"].build_pushstreams
cmake.definitions["CMAKE_PROJECT_test_package_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake")
cmake.configure()
cmake.build()
@@ -59,3 +63,10 @@ def test(self):
self.run("./use_shell_tui", cwd=os.path.join("deploy", "use_shell_tui"), run_environment=True)
if self.options["celix"].build_shell_wui:
self.run("./use_shell_wui", cwd=os.path.join("deploy", "use_shell_wui"), run_environment=True)
if self.options["celix"].build_celix_etcdlib:
self.run("./use_etcd_lib", run_environment=True)
if self.options["celix"].build_launcher:
self.run("./use_launcher", cwd=os.path.join("deploy", "use_launcher"), run_environment=True)
if self.options["celix"].build_promises:
self.run("./use_promises", run_environment=True)

@@ -29,12 +29,12 @@ static celix_status_t activator_start(activator_data_t *data, celix_bundle_conte
const char *key = NULL;
data->logger = celix_logHelper_create(ctx, "test");
printf("\nHello world from C bundle with id %li\n", celix_bundle_getId(celix_bundleContext_getBundle(ctx)));
celix_array_list_t *bundles = celix_bundleContext_listBundles(ctx);
celix_array_list_t *bundles = celix_bundleContext_listInstalledBundles(ctx);
for (int i = 0; i < celix_arrayList_size(bundles); i++) {
long bndId = celix_arrayList_getLong(bundles, i);
printf("Bundle %ld: %s\n", bndId, celix_bundleContext_getBundleSymbolicName(ctx, bndId));
}

celix_arrayList_destroy(bundles);
celix_framework_stopBundleAsync(celix_bundleContext_getFramework(ctx), CELIX_FRAMEWORK_BUNDLE_ID); // to make container quit immediately
return CELIX_SUCCESS;
}
@@ -0,0 +1,31 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

#include <etcdlib.h>
#include <stdio.h>

int main() {
etcdlib_t *db = etcdlib_create("127.0.0.1", 8000, ETCDLIB_NO_CURL_INITIALIZATION);
if (db != NULL) {
printf("etcdlib instance %p created\n", db);
}
etcdlib_destroy(db);
printf("etcdlib instance %p destroyed\n", db);
return 0;
}
@@ -0,0 +1,32 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#include <celix/DefaultExecutor.h>
#include <memory>
#include <iostream>

int main() {
std::shared_ptr<celix::IExecutor> executor = std::make_shared<celix::DefaultExecutor>();
std::atomic<int> counter{0};
executor->execute([&counter]{counter++;});
executor->execute([&counter]{counter++;});
executor->execute([&counter]{counter++;});
executor->wait();
std::cout << "counter=" << counter << std::endl;
return 0;
}
@@ -30,7 +30,7 @@ static void use(void *handle, void *svc) {
}

static bool executeCommand(void *handle, const char *commandLine, FILE *outStream, FILE *errorStream) {
printf("Executing %s\n", commandLine);
fprintf(outStream, "Executing %s\n", commandLine);
return true;
}

0 comments on commit 93f358d

Please sign in to comment.