CELIX-237: initial setup for rsa dfi testing

Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/1e618fb1
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/1e618fb1
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/1e618fb1

Branch: refs/heads/develop
Commit: 1e618fb14061a04d43174291dde729c928e76a3f
Parents: 2f56576
Author: Pepijn Noltes <pepijnnol...@gmail.com>
Authored: Fri Jul 31 21:45:10 2015 +0200
Committer: Pepijn Noltes <pepijnnol...@gmail.com>
Committed: Fri Jul 31 21:45:10 2015 +0200

----------------------------------------------------------------------
 launcher/private/src/launcher.c                 | 19 +++++++++++-----
 launcher/private/src/main.c                     |  1 +
 launcher/public/include/launcher.h              |  3 +++
 .../remote_service_admin_dfi/tst/CMakeLists.txt | 23 ++++++++++++++++++++
 .../tst/config.properties.in                    |  1 +
 .../remote_service_admin_dfi/tst/run_tests.cpp  | 18 +++++++++++++++
 6 files changed, 60 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/1e618fb1/launcher/private/src/launcher.c
----------------------------------------------------------------------
diff --git a/launcher/private/src/launcher.c b/launcher/private/src/launcher.c
index 6d09fc4..9292ffb 100644
--- a/launcher/private/src/launcher.c
+++ b/launcher/private/src/launcher.c
@@ -40,6 +40,8 @@
 static void launcher_shutdown(int signal);
 
 static struct framework * framework;
+static properties_pt config;
+
 #ifdef WITH_APR
 static apr_pool_t *memoryPool;
 #endif
@@ -60,7 +62,7 @@ int celixLauncher_launch(const char *configFile) {
 int celixLauncher_launchWithStream(FILE *stream) {
     int status = 0;
 
-    properties_pt config = properties_loadWithStream(stream);
+    config = properties_loadWithStream(stream);
     fclose(stream);
     // Make sure we've read it and that nothing went wrong with the file 
access...
     if (config == NULL) {
@@ -154,10 +156,6 @@ int celixLauncher_launchWithStream(FILE *stream) {
                 }
 
                 arrayList_destroy(installed);
-
-                framework_waitForStop(framework);
-                framework_destroy(framework);
-                properties_destroy(config);
             }
         }
 
@@ -179,6 +177,17 @@ int celixLauncher_launchWithStream(FILE *stream) {
     return status;
 }
 
+void celixLauncher_waitForShutdown(void) {
+    framework_waitForStop(framework);
+    framework_destroy(framework);
+    properties_destroy(config);
+}
+
+
+struct framework *celixLauncher_getFramework(void) {
+    return framework;
+}
+
 static void launcher_shutdown(int signal) {
     bundle_pt fwBundle = NULL;
     framework_getFrameworkBundle(framework, &fwBundle);

http://git-wip-us.apache.org/repos/asf/celix/blob/1e618fb1/launcher/private/src/main.c
----------------------------------------------------------------------
diff --git a/launcher/private/src/main.c b/launcher/private/src/main.c
index 0a59bc4..b6d3033 100644
--- a/launcher/private/src/main.c
+++ b/launcher/private/src/main.c
@@ -55,6 +55,7 @@ int main(int argc, char *argv[]) {
     }
 
     celixLauncher_launch(config_file);
+    celixLauncher_waitForShutdown();
 }
 
 static void show_usage(char* prog_name) {

http://git-wip-us.apache.org/repos/asf/celix/blob/1e618fb1/launcher/public/include/launcher.h
----------------------------------------------------------------------
diff --git a/launcher/public/include/launcher.h 
b/launcher/public/include/launcher.h
index 296df7c..f95e160 100644
--- a/launcher/public/include/launcher.h
+++ b/launcher/public/include/launcher.h
@@ -28,8 +28,11 @@
 #define CELIX_LAUNCHER_H
 
 #include <stdio.h>
+#include "framework.h"
 
 int celixLauncher_launch(const char *configFile);
 int celixLauncher_launchWithStream(FILE *config);
+void celixLauncher_waitForShutdown(void);
+struct framework *celixLauncher_getFramework(void);
 
 #endif //CELIX_LAUNCHER_H

http://git-wip-us.apache.org/repos/asf/celix/blob/1e618fb1/remote_services/remote_service_admin_dfi/tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/tst/CMakeLists.txt 
b/remote_services/remote_service_admin_dfi/tst/CMakeLists.txt
new file mode 100644
index 0000000..fb1834a
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/tst/CMakeLists.txt
@@ -0,0 +1,23 @@
+#
+# Licensed under Apache License v2. See LICENSE for more information.
+#
+
+include_directories(
+       ${PROJECT_SOURCE_DIR}/launcher/public
+    ${CPPUTEST_INCLUDE_DIR}
+)
+
+
+#if (FRAMEWORK_TESTS) TODO
+       add_executable(rsa_dfi_tests
+               ${PROJECT_SOURCE_DIR}/launcher/private/src/launcher
+           tst/run_tests.cpp
+       )
+       target_link_libraries(rsa_dfi_tests ${CPPUTEST_LIBRARY}) #TODO add 
celix/launcer etc
+
+       get_property(rsa_bundle_file TARGET remote_service_admin_dfi PROPERTY 
BUNDLE)
+       configure_file(config.properties.in config-rsa.properties @ONLY)
+
+       add_test(NAME run_rsa_dfi_tests COMMAND rsa_dfi_tests)
+       SETUP_TARGET_FOR_COVERAGE(rsa_dfi_tests_cov rsa_dfi_tests 
${CMAKE_BINARY_DIR}/coverage/rsa_dfi)
+#endif()

http://git-wip-us.apache.org/repos/asf/celix/blob/1e618fb1/remote_services/remote_service_admin_dfi/tst/config.properties.in
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/tst/config.properties.in 
b/remote_services/remote_service_admin_dfi/tst/config.properties.in
new file mode 100644
index 0000000..b926f36
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/tst/config.properties.in
@@ -0,0 +1 @@
+cosgi.auto.start.1=@rsa_bundle_file@
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/1e618fb1/remote_services/remote_service_admin_dfi/tst/run_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/tst/run_tests.cpp 
b/remote_services/remote_service_admin_dfi/tst/run_tests.cpp
new file mode 100644
index 0000000..b5f29e7
--- /dev/null
+++ b/remote_services/remote_service_admin_dfi/tst/run_tests.cpp
@@ -0,0 +1,18 @@
+/*
+ * Licensed under Apache License v2. See LICENSE for more information.
+ */
+#include <CppUTest/TestHarness.h>
+#include "CppUTest/CommandLineTestRunner.h"
+
+#include <stdio.h>
+
+#include "launcher.h"
+
+
+int main(int argc, char** argv) {
+    celixLauncher_launch("config.properties");
+    int rc = RUN_ALL_TESTS(argc, argv);
+    framework_stop((celixLauncher_getFramework()));
+    celixLauncher_waitForShutdown();
+    return rc;
+}
\ No newline at end of file

Reply via email to