Repository: celix Updated Branches: refs/heads/feature/CELIX-237_rsa-ffi fdade6aaa -> 16853770c
CELIX-237: Moved celix launcher to framework. Adjusted testing setup Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/16853770 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/16853770 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/16853770 Branch: refs/heads/feature/CELIX-237_rsa-ffi Commit: 16853770c82d8744d4e30f168652e1021f87b068 Parents: fdade6a Author: Pepijn Noltes <pepijnnol...@gmail.com> Authored: Tue Aug 18 12:22:27 2015 +0200 Committer: Pepijn Noltes <pepijnnol...@gmail.com> Committed: Tue Aug 18 12:22:27 2015 +0200 ---------------------------------------------------------------------- CMakeLists.txt | 7 +- framework/CMakeLists.txt | 6 +- framework/private/src/celix_launcher.c | 190 +++++++++++++++++++ framework/public/include/celix_launcher.h | 41 ++++ launcher/CMakeLists.txt | 2 +- launcher/private/src/launcher.c | 190 ------------------- launcher/private/src/main.c | 2 +- launcher/public/include/launcher.h | 41 ---- .../remote_service_admin_dfi/CMakeLists.txt | 12 +- .../rsa_tst/CMakeLists.txt | 2 - .../rsa_tst/rsa_client_server_tests.cpp | 2 +- .../rsa_tst/rsa_tests.cpp | 2 +- 12 files changed, 249 insertions(+), 248 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 137c81b..2f78e1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,12 @@ SET(CELIX_MINOR "0") SET(CELIX_MICRO "0") SET(CELIX_QUALIFIER "") -enable_testing() +option(ENABLE_TESTING "Enables unit/bundle testing" FALSE) + +if (ENABLE_TESTING) + enable_testing() +endif() + include(CMakeCelix) include(cmake_celix/installation) http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/framework/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 1719d2c..429dd04 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -55,7 +55,7 @@ if (FRAMEWORK) private/src/requirement.c private/src/resolver.c private/src/service_reference.c private/src/service_registration.c private/src/service_registry.c private/src/service_tracker.c private/src/service_tracker_customizer.c private/src/unzip.c private/src/utils.c private/src/version.c private/src/version_range.c private/src/wire.c - private/src/celix_log.c + private/src/celix_log.c private/src/celix_launcher.c private/include/attribute.h public/include/framework_exports.h @@ -81,7 +81,7 @@ if (FRAMEWORK) INSTALL(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/" DESTINATION share/celix/cmake/modules COMPONENT framework) celix_subproject(FRAMEWORK_TESTS "Option to build the framework tests" "OFF" DEPS) - if (FRAMEWORK_TESTS) + if (ENABLE_TESTING AND FRAMEWORK_TESTS) find_package(CppUTest REQUIRED) include_directories(${CPPUTEST_INCLUDE_DIR}) @@ -374,5 +374,5 @@ if (FRAMEWORK) SETUP_TARGET_FOR_COVERAGE(attribute_test_c attribute_test ${CMAKE_BINARY_DIR}/coverage/attribute_test) SETUP_TARGET_FOR_COVERAGE(wire_test_c wire_test ${CMAKE_BINARY_DIR}/coverage/wire_test) - endif (FRAMEWORK_TESTS) + endif (ENABLE_TESTING AND FRAMEWORK_TESTS) endif (FRAMEWORK) http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/framework/private/src/celix_launcher.c ---------------------------------------------------------------------- diff --git a/framework/private/src/celix_launcher.c b/framework/private/src/celix_launcher.c new file mode 100644 index 0000000..bc6bd34 --- /dev/null +++ b/framework/private/src/celix_launcher.c @@ -0,0 +1,190 @@ +/** + *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. + */ +/* + * celix_launcher.c + * + * \date Mar 23, 2010 + * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> + * \copyright Apache License, Version 2.0 + */ + +#include "celix_launcher.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <libgen.h> +#include <signal.h> + +#ifndef CELIX_NO_CURLINIT +#include <curl/curl.h> +#endif + +#include "framework.h" +#include "linked_list_iterator.h" + +#ifdef WITH_APR +static apr_pool_t *memoryPool; +#endif + +int celixLauncher_launch(const char *configFile, framework_pt *framework) { + int status = 0; + FILE *config = fopen(configFile, "r"); + if (config != NULL) { + status = celixLauncher_launchWithStream(config, framework); + } else { + fprintf(stderr, "Error: invalid or non-existing configuration file: '%s'.", configFile); + perror(""); + status = 1; + } + return status; +} + +int celixLauncher_launchWithStream(FILE *stream, framework_pt *framework) { + int status = 0; + + properties_pt config = properties_loadWithStream(stream); + fclose(stream); + // Make sure we've read it and that nothing went wrong with the file access... + if (config == NULL) { + fprintf(stderr, "Error: invalid configuration file"); + perror(NULL); + status = 1; + } + + +#ifdef WITH_APR + apr_status_t rv; + apr_status_t s; +#endif + +#ifndef CELIX_NO_CURLINIT + // Before doing anything else, let's setup Curl + curl_global_init(CURL_GLOBAL_NOTHING); +#endif + +#ifdef WITH_APR + rv = apr_initialize(); + if (rv != APR_SUCCESS) { + return CELIX_START_ERROR; + } + + s = apr_pool_create(&memoryPool, NULL); + if (s != APR_SUCCESS) { + return CELIX_START_ERROR; + } +#endif + + + if (status == 0) { + char *autoStart = properties_get(config, "cosgi.auto.start.1"); + celix_status_t status; +#ifdef WITH_APR + status = framework_create(framework, memoryPool, config); +#else + status = framework_create(framework, config); +#endif + bundle_pt fwBundle = NULL; + if (status == CELIX_SUCCESS) { + status = fw_init(*framework); + if (status == CELIX_SUCCESS) { + // Start the system bundle + framework_getFrameworkBundle(*framework, &fwBundle); + bundle_start(fwBundle); + + char delims[] = " "; + char *result = NULL; + char *save_ptr = NULL; + linked_list_pt bundles; + array_list_pt installed = NULL; + bundle_context_pt context = NULL; + linked_list_iterator_pt iter = NULL; + unsigned int i; + + linkedList_create(&bundles); + result = strtok_r(autoStart, delims, &save_ptr); + while (result != NULL) { + char *location = strdup(result); + linkedList_addElement(bundles, location); + result = strtok_r(NULL, delims, &save_ptr); + } + // First install all bundles + // Afterwards start them + arrayList_create(&installed); + bundle_getContext(fwBundle, &context); + iter = linkedListIterator_create(bundles, 0); + while (linkedListIterator_hasNext(iter)) { + bundle_pt current = NULL; + char *location = (char *) linkedListIterator_next(iter); + if (bundleContext_installBundle(context, location, ¤t) == CELIX_SUCCESS) { + // Only add bundle if it is installed correctly + arrayList_add(installed, current); + } else { + printf("Could not install bundle from %s\n", location); + } + linkedListIterator_remove(iter); + free(location); + } + linkedListIterator_destroy(iter); + linkedList_destroy(bundles); + + for (i = 0; i < arrayList_size(installed); i++) { + bundle_pt installedBundle = (bundle_pt) arrayList_get(installed, i); + bundle_startWithOptions(installedBundle, 0); + } + + arrayList_destroy(installed); + } + } + + if (status != CELIX_SUCCESS) { + printf("Problem creating framework\n"); + } + + printf("Launcher: Framework Started\n"); + } + + return status; +} + +void celixLauncher_waitForShutdown(framework_pt framework) { + framework_waitForStop(framework); +} + +void celixLauncher_destroy(framework_pt framework) { + framework_destroy(framework); + + #ifdef WITH_APR + apr_pool_destroy(memoryPool); + apr_terminate(); + #endif + + #ifndef CELIX_NO_CURLINIT + // Cleanup Curl + curl_global_cleanup(); + #endif + + printf("Launcher: Exit\n"); +} + +void celixLauncher_stop(framework_pt framework) { + bundle_pt fwBundle = NULL; + framework_getFrameworkBundle(framework, &fwBundle); + bundle_stop(fwBundle); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/framework/public/include/celix_launcher.h ---------------------------------------------------------------------- diff --git a/framework/public/include/celix_launcher.h b/framework/public/include/celix_launcher.h new file mode 100644 index 0000000..a5d375f --- /dev/null +++ b/framework/public/include/celix_launcher.h @@ -0,0 +1,41 @@ +/** + *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. + */ +/* + * celix_launcher.h + * + * \date Jul 30, 2015 + * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> + * \copyright Apache License, Version 2.0 + */ + +#ifndef CELIX_LAUNCHER_H +#define CELIX_LAUNCHER_H + +#include <stdio.h> +#include "framework.h" + +int celixLauncher_launch(const char *configFile, framework_pt *framework); +int celixLauncher_launchWithStream(FILE *config, framework_pt *framework); + +void celixLauncher_stop(framework_pt framework); +void celixLauncher_destroy(framework_pt framework); + +void celixLauncher_waitForShutdown(framework_pt framework); + +#endif //CELIX_LAUNCHER_H http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/launcher/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index dac0ce7..e1f9a9c 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -26,7 +26,7 @@ if (LAUNCHER) add_executable(celix private/src/main - private/src/launcher) + ) target_link_libraries(celix celix_framework ${CURL_LIBRARIES}) include_directories("${PROJECT_SOURCE_DIR}/utils/public/include") http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/launcher/private/src/launcher.c ---------------------------------------------------------------------- diff --git a/launcher/private/src/launcher.c b/launcher/private/src/launcher.c deleted file mode 100644 index a6297a0..0000000 --- a/launcher/private/src/launcher.c +++ /dev/null @@ -1,190 +0,0 @@ -/** - *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. - */ -/* - * launcher.c - * - * \date Mar 23, 2010 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ - -#include "launcher.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <libgen.h> -#include <signal.h> - -#ifndef CELIX_NO_CURLINIT -#include <curl/curl.h> -#endif - -#include "framework.h" -#include "linked_list_iterator.h" - -#ifdef WITH_APR -static apr_pool_t *memoryPool; -#endif - -int celixLauncher_launch(const char *configFile, framework_pt *framework) { - int status = 0; - FILE *config = fopen(configFile, "r"); - if (config != NULL) { - status = celixLauncher_launchWithStream(config, framework); - } else { - fprintf(stderr, "Error: invalid or non-existing configuration file: '%s'.", configFile); - perror(""); - status = 1; - } - return status; -} - -int celixLauncher_launchWithStream(FILE *stream, framework_pt *framework) { - int status = 0; - - properties_pt config = properties_loadWithStream(stream); - fclose(stream); - // Make sure we've read it and that nothing went wrong with the file access... - if (config == NULL) { - fprintf(stderr, "Error: invalid configuration file"); - perror(NULL); - status = 1; - } - - -#ifdef WITH_APR - apr_status_t rv; - apr_status_t s; -#endif - -#ifndef CELIX_NO_CURLINIT - // Before doing anything else, let's setup Curl - curl_global_init(CURL_GLOBAL_NOTHING); -#endif - -#ifdef WITH_APR - rv = apr_initialize(); - if (rv != APR_SUCCESS) { - return CELIX_START_ERROR; - } - - s = apr_pool_create(&memoryPool, NULL); - if (s != APR_SUCCESS) { - return CELIX_START_ERROR; - } -#endif - - - if (status == 0) { - char *autoStart = properties_get(config, "cosgi.auto.start.1"); - celix_status_t status; -#ifdef WITH_APR - status = framework_create(framework, memoryPool, config); -#else - status = framework_create(framework, config); -#endif - bundle_pt fwBundle = NULL; - if (status == CELIX_SUCCESS) { - status = fw_init(*framework); - if (status == CELIX_SUCCESS) { - // Start the system bundle - framework_getFrameworkBundle(*framework, &fwBundle); - bundle_start(fwBundle); - - char delims[] = " "; - char *result = NULL; - char *save_ptr = NULL; - linked_list_pt bundles; - array_list_pt installed = NULL; - bundle_context_pt context = NULL; - linked_list_iterator_pt iter = NULL; - unsigned int i; - - linkedList_create(&bundles); - result = strtok_r(autoStart, delims, &save_ptr); - while (result != NULL) { - char *location = strdup(result); - linkedList_addElement(bundles, location); - result = strtok_r(NULL, delims, &save_ptr); - } - // First install all bundles - // Afterwards start them - arrayList_create(&installed); - bundle_getContext(fwBundle, &context); - iter = linkedListIterator_create(bundles, 0); - while (linkedListIterator_hasNext(iter)) { - bundle_pt current = NULL; - char *location = (char *) linkedListIterator_next(iter); - if (bundleContext_installBundle(context, location, ¤t) == CELIX_SUCCESS) { - // Only add bundle if it is installed correctly - arrayList_add(installed, current); - } else { - printf("Could not install bundle from %s\n", location); - } - linkedListIterator_remove(iter); - free(location); - } - linkedListIterator_destroy(iter); - linkedList_destroy(bundles); - - for (i = 0; i < arrayList_size(installed); i++) { - bundle_pt installedBundle = (bundle_pt) arrayList_get(installed, i); - bundle_startWithOptions(installedBundle, 0); - } - - arrayList_destroy(installed); - } - } - - if (status != CELIX_SUCCESS) { - printf("Problem creating framework\n"); - } - - printf("Launcher: Framework Started\n"); - } - - return status; -} - -void celixLauncher_waitForShutdown(framework_pt framework) { - framework_waitForStop(framework); -} - -void celixLauncher_destroy(framework_pt framework) { - framework_destroy(framework); - - #ifdef WITH_APR - apr_pool_destroy(memoryPool); - apr_terminate(); - #endif - - #ifndef CELIX_NO_CURLINIT - // Cleanup Curl - curl_global_cleanup(); - #endif - - printf("Launcher: Exit\n"); -} - -void celixLauncher_stop(framework_pt framework) { - bundle_pt fwBundle = NULL; - framework_getFrameworkBundle(framework, &fwBundle); - bundle_stop(fwBundle); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/launcher/private/src/main.c ---------------------------------------------------------------------- diff --git a/launcher/private/src/main.c b/launcher/private/src/main.c index 90e5612..ec72d03 100644 --- a/launcher/private/src/main.c +++ b/launcher/private/src/main.c @@ -28,7 +28,7 @@ #include <curl/curl.h> #include <signal.h> #include <libgen.h> -#include "launcher.h" +#include "celix_launcher.h" static void show_usage(char* prog_name); static void shutdown_framework(int signal); http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/launcher/public/include/launcher.h ---------------------------------------------------------------------- diff --git a/launcher/public/include/launcher.h b/launcher/public/include/launcher.h deleted file mode 100644 index 6077e03..0000000 --- a/launcher/public/include/launcher.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - *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. - */ -/* - * launcher.h - * - * \date Jul 30, 2015 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ - -#ifndef CELIX_LAUNCHER_H -#define CELIX_LAUNCHER_H - -#include <stdio.h> -#include "framework.h" - -int celixLauncher_launch(const char *configFile, framework_pt *framework); -int celixLauncher_launchWithStream(FILE *config, framework_pt *framework); - -void celixLauncher_stop(framework_pt framework); -void celixLauncher_destroy(framework_pt framework); - -void celixLauncher_waitForShutdown(framework_pt framework); - -#endif //CELIX_LAUNCHER_H http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/remote_services/remote_service_admin_dfi/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/CMakeLists.txt b/remote_services/remote_service_admin_dfi/CMakeLists.txt index 7f9404c..9d6db45 100644 --- a/remote_services/remote_service_admin_dfi/CMakeLists.txt +++ b/remote_services/remote_service_admin_dfi/CMakeLists.txt @@ -20,15 +20,13 @@ if (RSA_REMOTE_SERVICE_ADMIN_DFI) include_directories(dynamic_function_interface/memstream) endif() - #TODO if test check - include_directories(${CPPUTEST_INCLUDE_DIR}) - - add_subdirectory(dynamic_function_interface) add_subdirectory(rsa) - #TODO if test check - add_subdirectory(dynamic_function_interface_tst) - add_subdirectory(rsa_tst) + if (ENABLE_TESTING) + include_directories(${CPPUTEST_INCLUDE_DIR}) + add_subdirectory(dynamic_function_interface_tst) + add_subdirectory(rsa_tst) + endif() endif() \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt b/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt index 82d908b..076231c 100644 --- a/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt +++ b/remote_services/remote_service_admin_dfi/rsa_tst/CMakeLists.txt @@ -4,7 +4,6 @@ include_directories( - ${PROJECT_SOURCE_DIR}/launcher/public/include ${PROJECT_SOURCE_DIR}/framework/public/include ${PROJECT_SOURCE_DIR}/utils/public/include ${PROJECT_SOURCE_DIR}/utils/public/include @@ -24,7 +23,6 @@ add_executable(test_rsa_dfi rsa_tests.cpp rsa_client_server_tests.cpp - ${PROJECT_SOURCE_DIR}/launcher/private/src/launcher.c #TODO move to libframework ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c ) target_link_libraries(test_rsa_dfi celix_framework celix_utils ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY}) http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp b/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp index 35beffe..c1b9b91 100644 --- a/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp +++ b/remote_services/remote_service_admin_dfi/rsa_tst/rsa_client_server_tests.cpp @@ -17,7 +17,7 @@ extern "C" { #include <ctype.h> #include <unistd.h> -#include "launcher.h" +#include "celix_launcher.h" #include "framework.h" #include "remote_service_admin.h" #include "calculator_service.h" http://git-wip-us.apache.org/repos/asf/celix/blob/16853770/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp b/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp index 1384573..c56a677 100644 --- a/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp +++ b/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp @@ -15,7 +15,7 @@ extern "C" { #include <string.h> #include <ctype.h> -#include "launcher.h" +#include "celix_launcher.h" #include "framework.h" #include "remote_service_admin.h" #include "calculator_service.h"