This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/509-remove-cpputests in repository https://gitbox.apache.org/repos/asf/celix.git
commit 8af7bff25226d4bc915566fcf07c43e5742f4a7b Author: Pepijn Noltes <[email protected]> AuthorDate: Sat Dec 23 17:11:54 2023 +0100 Remove cpputest config, cpputest usage and linked list Also refactor shell tui history to use array list instead of linked list. --- bundles/shell/shell_tui/gtest/CMakeLists.txt | 1 + .../shell/shell_tui/gtest/src/ShellTuiTestSuite.cc | 36 ++++--- bundles/shell/shell_tui/src/activator.c | 2 +- bundles/shell/shell_tui/src/history.c | 111 +++++++++++++-------- bundles/shell/shell_tui/src/history.h | 26 ++--- bundles/shell/shell_tui/src/shell_tui.c | 41 ++++---- bundles/shell/shell_tui/src/shell_tui.h | 6 +- cmake/Modules/FindCppUTest.cmake | 69 ------------- libs/framework/include_deprecated/bundle.h | 2 - libs/framework/include_deprecated/module.h | 9 -- libs/framework/src/bundle.c | 38 ++----- libs/framework/src/bundle_archive.c | 1 - libs/framework/src/framework.c | 1 - libs/framework/src/manifest_parser.h | 1 - libs/framework/src/module.c | 16 --- libs/utils/CMakeLists.txt | 39 -------- libs/utils/include_deprecated/linked_list.h | 92 ----------------- .../include_deprecated/linked_list_iterator.h | 66 ------------ 18 files changed, 142 insertions(+), 415 deletions(-) diff --git a/bundles/shell/shell_tui/gtest/CMakeLists.txt b/bundles/shell/shell_tui/gtest/CMakeLists.txt index 76f201cf..79cf1ea7 100644 --- a/bundles/shell/shell_tui/gtest/CMakeLists.txt +++ b/bundles/shell/shell_tui/gtest/CMakeLists.txt @@ -21,6 +21,7 @@ add_executable(test_shell_tui target_link_libraries(test_shell_tui PRIVATE Celix::framework GTest::gtest GTest::gtest_main) add_celix_bundle_dependencies(test_shell_tui Celix::shell Celix::shell_tui) +target_include_directories(test_shell_tui PRIVATE ../src) target_compile_definitions(test_shell_tui PRIVATE -DSHELL_BUNDLE_LOCATION=\"$<TARGET_PROPERTY:shell,BUNDLE_FILE>\") target_compile_definitions(test_shell_tui PRIVATE -DSHELL_TUI_BUNDLE_LOCATION=\"$<TARGET_PROPERTY:shell_tui,BUNDLE_FILE>\") diff --git a/bundles/shell/shell_tui/gtest/src/ShellTuiTestSuite.cc b/bundles/shell/shell_tui/gtest/src/ShellTuiTestSuite.cc index ca15a4f6..5cde351e 100644 --- a/bundles/shell/shell_tui/gtest/src/ShellTuiTestSuite.cc +++ b/bundles/shell/shell_tui/gtest/src/ShellTuiTestSuite.cc @@ -22,6 +22,7 @@ #include "celix/FrameworkFactory.h" #include "celix/BundleContext.h" +#include "history.h" class ShellTuiTestSuite : public ::testing::Test { public: @@ -144,41 +145,40 @@ public: int outputWriteFd = -1; }; -TEST_F(ShellTuiTestSuite, testStartStop) { +TEST_F(ShellTuiTestSuite, StartStopTest) { //simple start/stop bundles, but should not leak createFrameworkWithShellBundles(); } -TEST_F(ShellTuiTestSuite, testExecuteLb) { +TEST_F(ShellTuiTestSuite, ExecuteLbTest) { testExecuteLb(false); } -TEST_F(ShellTuiTestSuite, testExecuteLbWithAnsiControlEnabled) { +TEST_F(ShellTuiTestSuite, ExecuteLbWithAnsiControlEnabledTest) { testExecuteLb(true); } -TEST_F(ShellTuiTestSuite, testAutoCompleteHelpCommand) { +TEST_F(ShellTuiTestSuite, AutoCompleteHelpCommandTest) { //note incomplete command with a tab -> should complete command to `help` testAutoCompleteForCommand("hel\t", "help"); } -TEST_F(ShellTuiTestSuite, testAutoCompleteCelixLbCommand) { +TEST_F(ShellTuiTestSuite, AutoCompleteCelixLbCommandTest) { //note incomplete command with a tab -> should complete command to `celix::help` testAutoCompleteForCommand("celix::hel\t", "celix::help"); } -TEST_F(ShellTuiTestSuite, testAutoCompleteLbUsageCommand) { +TEST_F(ShellTuiTestSuite, AutoCompleteLbUsageCommandTest) { //note complete help command with a tab -> should print usage testAutoCompleteForCommand("help \t", "Usage:"); } -TEST_F(ShellTuiTestSuite, testAutoCompleteCelixLbUsageCommand) { +TEST_F(ShellTuiTestSuite, AutoCompleteCelixLbUsageCommandTest) { //note complete celix::help command with a tab -> should print usage testAutoCompleteForCommand("celix::help \t", "Usage:"); } - -TEST_F(ShellTuiTestSuite, testShellTuiWithInvalidFD) { +TEST_F(ShellTuiTestSuite, ShellTuiWithInvalidFDTest) { celix::Properties config{ {"SHELL_TUI_USE_ANSI_CONTROL_SEQUENCES", "true"}, {"SHELL_TUI_INPUT_FILE_DESCRIPTOR", "555"}, //note invalid fd @@ -190,15 +190,15 @@ TEST_F(ShellTuiTestSuite, testShellTuiWithInvalidFD) { writeCmd("lb\n"); } -TEST_F(ShellTuiTestSuite, testShellTuiWithoutShell) { +TEST_F(ShellTuiTestSuite, ShellTuiWithoutShellTest) { testExecuteLbWithoutShell(false); } -TEST_F(ShellTuiTestSuite, testShellTuiWithAnsiControlWithoutShell) { +TEST_F(ShellTuiTestSuite, ShellTuiWithAnsiControlWithoutShellTest) { testExecuteLbWithoutShell(true); } -TEST_F(ShellTuiTestSuite, testAnsiControl) { +TEST_F(ShellTuiTestSuite, AnsiControlTest) { celix::Properties config{ {"SHELL_TUI_USE_ANSI_CONTROL_SEQUENCES", "true"} }; @@ -235,4 +235,14 @@ TEST_F(ShellTuiTestSuite, testAnsiControl) { writeCmd(cmd); std::cout << readPipeOutput() << std::endl; -} \ No newline at end of file +} + +TEST_F(ShellTuiTestSuite, WriteMoreThanMaxHistoryLines) { + createFrameworkWithShellBundles(); + + //WRITE more than hist max lines + int maxHist = CELIX_SHELL_TUI_HIST_MAX; + for (int i = 0; i < maxHist + 1; ++i) { + writeCmd("lb\n"); + } +} diff --git a/bundles/shell/shell_tui/src/activator.c b/bundles/shell/shell_tui/src/activator.c index 3ae833d5..fed53440 100644 --- a/bundles/shell/shell_tui/src/activator.c +++ b/bundles/shell/shell_tui/src/activator.c @@ -70,7 +70,7 @@ static celix_status_t celix_shellTuiActivator_start(celix_shell_tui_activator_t* char *term = getenv("TERM"); useCommands = term != NULL; //if TERM exist, default is to use commands useCommands = celix_bundleContext_getPropertyAsBool(ctx, SHELL_TUI_USE_ANSI_CONTROL_SEQUENCES, useCommands); - act->shellTui = shellTui_create(useCommands, inputFd, outputFd, errorFd); + act->shellTui = shellTui_create(ctx, useCommands, inputFd, outputFd, errorFd); { celix_service_tracking_options_t opts = CELIX_EMPTY_SERVICE_TRACKING_OPTIONS; diff --git a/bundles/shell/shell_tui/src/history.c b/bundles/shell/shell_tui/src/history.c index 2c034f5f..6a0f8051 100644 --- a/bundles/shell/shell_tui/src/history.c +++ b/bundles/shell/shell_tui/src/history.c @@ -17,64 +17,91 @@ * under the License. */ -#include "history.h" #include <stdlib.h> #include <string.h> -#include "linked_list.h" -#define HIST_SIZE 32 +#include "celix_array_list.h" +#include "celix_bundle_context.h" +#include "celix_stdlib_cleanup.h" +#include "celix_utils.h" +#include "history.h" -struct history { - linked_list_pt history_lines; - int currentLine; +struct celix_shell_tui_history { + celix_bundle_context_t* ctx; + celix_array_list_t* historyLines; + int currentLine; }; -history_t *historyCreate() { - history_t* hist = calloc(1, sizeof(*hist)); - linkedList_create(&hist->history_lines); - hist->currentLine = -1; - return hist; -} +celix_shell_tui_history_t* celix_shellTuiHistory_create(celix_bundle_context_t* ctx) { + celix_autofree celix_shell_tui_history_t* hist = calloc(1, sizeof(*hist)); + if (hist) { + hist->ctx = ctx; + celix_array_list_create_options_t opts = CELIX_EMPTY_ARRAY_LIST_CREATE_OPTIONS; + opts.simpleRemovedCallback = free; + hist->historyLines = celix_arrayList_createWithOptions(&opts); + hist->currentLine = -1; + } -void historyDestroy(history_t *hist) { - unsigned int size = linkedList_size(hist->history_lines); - for(unsigned int i = 0; i < size; i++) { - char *line = linkedList_get(hist->history_lines, i); - free(line); - } - linkedList_destroy(hist->history_lines); - free(hist); + if (!hist || !hist->historyLines) { + celix_bundleContext_log(ctx, CELIX_LOG_LEVEL_ERROR, "Error creating history"); + return NULL; + } + + return celix_steal_ptr(hist); } -void history_addLine(history_t *hist, const char *line) { - linkedList_addFirst(hist->history_lines, strdup(line)); - if(linkedList_size(hist->history_lines) == HIST_SIZE) { - char *lastLine = (char*)linkedList_get(hist->history_lines, HIST_SIZE-1); - free(lastLine); - linkedList_removeIndex(hist->history_lines, HIST_SIZE-1); - } +void celix_shellTuiHistory_destroy(celix_shell_tui_history_t* hist) { + if (hist) { + celix_arrayList_destroy(hist->historyLines); + free(hist); + } } -char *historyGetPrevLine(history_t *hist) { - hist->currentLine = (hist->currentLine + 1) % linkedList_size(hist->history_lines); - return (char*)linkedList_get(hist->history_lines, hist->currentLine); +void celix_shellTuiHistory_addLine(celix_shell_tui_history_t* hist, const char* line) { + if (line == NULL || strlen(line) == 0) { + return; //ignore empty lines + } + celix_autofree char* lineCopy = celix_utils_strdup(line); + celix_status_t status = CELIX_SUCCESS; + if (lineCopy) { + status = celix_arrayList_add(hist->historyLines, lineCopy); + if (celix_arrayList_size(hist->historyLines) > CELIX_SHELL_TUI_HIST_MAX) { + celix_arrayList_removeAt(hist->historyLines, 0); + } + } + + if (!lineCopy || status != CELIX_SUCCESS) { + celix_bundleContext_log(hist->ctx, CELIX_LOG_LEVEL_ERROR, "Error adding line to history"); + } else { + hist->currentLine = celix_arrayList_size(hist->historyLines); + celix_steal_ptr(lineCopy); + } } -char *historyGetNextLine(history_t *hist) { - if(linkedList_size(hist->history_lines) > 0) { - if (hist->currentLine <= 0) { - hist->currentLine = linkedList_size(hist->history_lines) - 1; - } else { - hist->currentLine--; - } +const char* celix_shellTuiHistory_getPrevLine(celix_shell_tui_history_t* hist) { + hist->currentLine--; + if (hist->currentLine < 0) { + hist->currentLine = 0; } - return (char*)linkedList_get(hist->history_lines, hist->currentLine); + int size = celix_arrayList_size(hist->historyLines); + if (size > 0) { + return celix_arrayList_get(hist->historyLines, hist->currentLine); + } + return NULL; } -void historyLineReset(history_t *hist) { - hist->currentLine = -1; +const char* celix_shellTuiHistory_getNextLine(celix_shell_tui_history_t* hist) { + hist->currentLine++; + int size = celix_arrayList_size(hist->historyLines); + if (hist->currentLine >= size) { + hist->currentLine = size - 1; + } + if (size > 0) { + return celix_arrayList_get(hist->historyLines, hist->currentLine); + } + return NULL; } -unsigned int historySize(history_t *hist) { - return linkedList_size(hist->history_lines); +void celix_shellTuiHistory_lineReset(celix_shell_tui_history_t* hist) { + hist->currentLine = celix_arrayList_size(hist->historyLines); } diff --git a/bundles/shell/shell_tui/src/history.h b/bundles/shell/shell_tui/src/history.h index c45790be..22e3f807 100644 --- a/bundles/shell/shell_tui/src/history.h +++ b/bundles/shell/shell_tui/src/history.h @@ -16,25 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -/** - * history.h - * - * \date Jan 16, 2016 - * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ #ifndef SHELL_TUI_HISTORY #define SHELL_TUI_HISTORY -typedef struct history history_t; +#include "celix_bundle_context.h" + +#define CELIX_SHELL_TUI_HIST_MAX 32 + +typedef struct celix_shell_tui_history celix_shell_tui_history_t; -history_t *historyCreate(); -void historyDestroy(history_t *hist); -void history_addLine(history_t *hist, const char *line); -char *historyGetPrevLine(history_t *hist); -char *historyGetNextLine(history_t *hist); -void historyLineReset(history_t *hist); -unsigned int historySize(history_t *hist); +celix_shell_tui_history_t* celix_shellTuiHistory_create(celix_bundle_context_t* ctx); +void celix_shellTuiHistory_destroy(celix_shell_tui_history_t* hist); +void celix_shellTuiHistory_addLine(celix_shell_tui_history_t* hist, const char* line); +const char* celix_shellTuiHistory_getPrevLine(celix_shell_tui_history_t* hist); +const char* celix_shellTuiHistory_getNextLine(celix_shell_tui_history_t* hist); +void celix_shellTuiHistory_lineReset(celix_shell_tui_history_t* hist); #endif // SHELL_TUI_HISTORY diff --git a/bundles/shell/shell_tui/src/shell_tui.c b/bundles/shell/shell_tui/src/shell_tui.c index 3f284db7..a370ec93 100644 --- a/bundles/shell/shell_tui/src/shell_tui.c +++ b/bundles/shell/shell_tui/src/shell_tui.c @@ -51,6 +51,8 @@ const char * const SHELL_NOT_AVAILABLE_MSG = "[Shell TUI] Shell service not available."; struct shell_tui { + celix_bundle_context_t* ctx; + celix_thread_mutex_t mutex; //protects shell celix_shell_t* shell; celix_thread_t thread; @@ -70,7 +72,7 @@ typedef struct shell_context { char buffer[LINE_SIZE+1]; char dline[LINE_SIZE+1]; int pos; - history_t* hist; + celix_shell_tui_history_t* hist; } shell_context_t; struct OriginalSettings { @@ -98,8 +100,9 @@ static void writePrompt(shell_tui_t*); // Unfortunately has to be static, it is not possible to pass user defined data to the handler static struct OriginalSettings originalSettings; -shell_tui_t* shellTui_create(bool useAnsiControlSequences, int inputFd, int outputFd, int errorFd) { +shell_tui_t* shellTui_create(celix_bundle_context_t* ctx, bool useAnsiControlSequences, int inputFd, int outputFd, int errorFd) { shell_tui_t* result = calloc(1, sizeof(*result)); + result->ctx = ctx; result->inputFd = inputFd; result->output = outputFd == STDOUT_FILENO ? stdout : fdopen(outputFd, "a"); if (result->output == NULL) { @@ -183,7 +186,7 @@ static void* shellTui_runnable(void *data) { //setup shell context shell_context_t ctx; memset(&ctx, 0, sizeof(ctx)); - ctx.hist = historyCreate(); + ctx.hist = celix_shellTuiHistory_create(shellTui->ctx); struct termios term_new; if (shellTui->useAnsiControlSequences && shellTui->inputFd == STDIN_FILENO) { @@ -246,7 +249,7 @@ static void* shellTui_runnable(void *data) { } } - historyDestroy(ctx.hist); + celix_shellTuiHistory_destroy(ctx.hist); if (shellTui->useAnsiControlSequences && shellTui->inputFd == STDIN_FILENO) { tcsetattr(STDIN_FILENO, TCSANOW, &originalSettings.term_org); sigaction(SIGINT, &originalSettings.oldSigIntAction, NULL); @@ -303,26 +306,28 @@ static int shellTui_parseInputForControl(shell_tui_t* shellTui, shell_context_t* char* buffer = ctx->buffer; char* in = ctx->in; char* dline = ctx->dline; - history_t* hist = ctx->hist; + celix_shell_tui_history_t* hist = ctx->hist; int pos = ctx->pos; - char* line = NULL; + const char* line = NULL; - int nr_chars = read(shellTui->inputFd, buffer, LINE_SIZE-pos-1); + int nr_chars = (int)read(shellTui->inputFd, buffer, LINE_SIZE-pos-1); for(int bufpos = 0; bufpos < nr_chars; bufpos++) { if (buffer[bufpos] == KEY_ESC1 && buffer[bufpos+1] == KEY_ESC2) { switch (buffer[bufpos+2]) { case KEY_UP: - if(historySize(hist) > 0) { - strncpy(in, historyGetPrevLine(hist), LINE_SIZE); - pos = strlen(in); - writeLine(shellTui, in, pos); + line = celix_shellTuiHistory_getPrevLine(hist); + if (line) { + strncpy(in, line, LINE_SIZE); + pos = (int)strlen(in); + writeLine(shellTui, line, pos); } break; case KEY_DOWN: - if(historySize(hist) > 0) { - strncpy(in, historyGetNextLine(hist), LINE_SIZE); - pos = strlen(in); - writeLine(shellTui, in, pos); + line = celix_shellTuiHistory_getNextLine(hist); + if (line) { + strncpy(in, line, LINE_SIZE); + pos = (int)strlen(in); + writeLine(shellTui, line, pos); } break; case KEY_RIGHT: @@ -385,7 +390,7 @@ static int shellTui_parseInputForControl(shell_tui_t* shellTui, shell_context_t* writeLine(shellTui, in, pos); fprintf(shellTui->output, "\n"); remove_newlines(in); - history_addLine(hist, in); + celix_shellTuiHistory_addLine(hist, in); memset(dline, 0, LINE_SIZE); strncpy(dline, in, LINE_SIZE); @@ -397,7 +402,7 @@ static int shellTui_parseInputForControl(shell_tui_t* shellTui, shell_context_t* if ((strlen(line) == 0)) { continue; } - historyLineReset(hist); + celix_shellTuiHistory_lineReset(hist); celixThreadMutex_lock(&shellTui->mutex); if (shellTui->shell != NULL) { shellTui->shell->executeCommand(shellTui->shell->handle, line, shellTui->output, shellTui->error); @@ -440,7 +445,7 @@ static void writePrompt(shell_tui_t* shellTui) { static void writeLine(shell_tui_t* shellTui, const char* line, int pos) { clearLine(shellTui); - fwrite( PROMPT, 1, strlen(PROMPT), shellTui->output); + fwrite(PROMPT, 1, strlen(PROMPT), shellTui->output); fwrite(line, 1, strlen(line), shellTui->output); cursorLeft(shellTui, strlen(line)-pos); } diff --git a/bundles/shell/shell_tui/src/shell_tui.h b/bundles/shell/shell_tui/src/shell_tui.h index f15e8832..b78d5aea 100644 --- a/bundles/shell/shell_tui/src/shell_tui.h +++ b/bundles/shell/shell_tui/src/shell_tui.h @@ -22,8 +22,9 @@ #include <stdlib.h> -#include "celix_threads.h" +#include "celix_bundle_context.h" #include "celix_shell.h" +#include "celix_threads.h" typedef struct shell_tui shell_tui_t ; @@ -35,7 +36,8 @@ typedef struct shell_tui shell_tui_t ; * @param outputFd The output file descriptor to use. * @param errorFd The error output file descriptor to use. */ -shell_tui_t* shellTui_create(bool useAnsiControlSequences, int inputFd, int outputFd, int errorFd); +shell_tui_t* +shellTui_create(celix_bundle_context_t* ctx, bool useAnsiControlSequences, int inputFd, int outputFd, int errorFd); /** * @brief Start the shell tui and the thread reading the tty and optional extra read file descriptor. diff --git a/cmake/Modules/FindCppUTest.cmake b/cmake/Modules/FindCppUTest.cmake deleted file mode 100644 index b747b7d1..00000000 --- a/cmake/Modules/FindCppUTest.cmake +++ /dev/null @@ -1,69 +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. - -FIND_PATH(CppUTest_INCLUDE_DIR NAMES CppUTest/TestHarness.h - PATHS $ENV{CPPUTEST_DIR} ${CPPUTEST_DIR} /usr /usr/local /opt/local - PATH_SUFFIXES include -) - -FIND_PATH(CppUTest_EXT_INCLUDE_DIR NAMES CppUTestExt/MockSupport.h - PATHS $ENV{CPPUTEST_DIR} ${CPPUTEST_DIR} /usr /usr/local /opt/local - PATH_SUFFIXES include -) - -FIND_LIBRARY(CppUTest_LIBRARY NAMES CppUTest - PATHS $ENV{CPPUTEST_DIR} ${CPPUTEST_DIR} /usr /usr/local /opt/local - PATH_SUFFIXES lib lib64 -) - -FIND_LIBRARY(CppUTest_EXT_LIBRARY NAMES CppUTestExt - PATHS $ENV{CPPUTEST_DIR} ${CPPUTEST_DIR} /usr /usr/local /opt/local - PATH_SUFFIXES lib lib64 -) - -# handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CppUTest DEFAULT_MSG CppUTest_LIBRARY CppUTest_INCLUDE_DIR) - - -IF(CppUTest_FOUND) - SET(CppUTest_LIBRARIES ${CppUTest_LIBRARY}) - SET(CppUTest_INCLUDE_DIRS ${CppUTest_INCLUDE_DIR}) - if(NOT TARGET CppUTest) - add_library(CppUTest STATIC IMPORTED) - set_target_properties(CppUTest PROPERTIES - IMPORTED_LOCATION "${CppUTest_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${CppUTest_INCLUDE_DIR}" - ) - if (NOT TARGET CppUTest::CppUTest) - add_library(CppUTest::CppUTest ALIAS CppUTest) - endif () - endif() - SET(CppUTest_EXT_LIBRARIES ${CppUTest_EXT_LIBRARY}) - SET(CppUTest_EXT_INCLUDE_DIRS ${CppUTest_EXT_INCLUDE_DIR}) - if(NOT TARGET CppUTestExt) - add_library(CppUTestExt STATIC IMPORTED) - set_target_properties(CppUTestExt PROPERTIES - IMPORTED_LOCATION "${CppUTest_EXT_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${CppUTest_EXT_INCLUDE_DIR}" - ) - if (NOT TARGET CppUTest::CppUTestExt) - add_library(CppUTest::CppUTestExt ALIAS CppUTestExt) - endif () - endif() -ENDIF(CppUTest_FOUND) diff --git a/libs/framework/include_deprecated/bundle.h b/libs/framework/include_deprecated/bundle.h index c1d8cc44..44bf3c49 100644 --- a/libs/framework/include_deprecated/bundle.h +++ b/libs/framework/include_deprecated/bundle.h @@ -82,8 +82,6 @@ CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_status_t bundle_revise(celix_bundle_t *b CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_status_t bundle_addModule(celix_bundle_t *bundle, module_pt module); -CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_status_t bundle_closeModules(const celix_bundle_t *bundle); - // Service Reference Functions CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_array_list_t *getUsingBundles(service_reference_pt reference); diff --git a/libs/framework/include_deprecated/module.h b/libs/framework/include_deprecated/module.h index 3c09f666..c17b0791 100644 --- a/libs/framework/include_deprecated/module.h +++ b/libs/framework/include_deprecated/module.h @@ -32,7 +32,6 @@ typedef struct module celix_module_t; #include <stdbool.h> -#include "linked_list.h" #include "manifest.h" #include "version.h" #include "array_list.h" @@ -59,20 +58,12 @@ CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_status_t module_getSymbolicName(module_p CELIX_FRAMEWORK_DEPRECATED_EXPORT char *module_getId(module_pt module); -CELIX_FRAMEWORK_DEPRECATED_EXPORT linked_list_pt module_getWires(module_pt module); - -CELIX_FRAMEWORK_DEPRECATED_EXPORT void module_setWires(module_pt module, linked_list_pt wires); - CELIX_FRAMEWORK_DEPRECATED_EXPORT bool module_isResolved(module_pt module); CELIX_FRAMEWORK_DEPRECATED_EXPORT void module_setResolved(module_pt module); CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_bundle_t *module_getBundle(module_pt module); -CELIX_FRAMEWORK_DEPRECATED_EXPORT linked_list_pt module_getRequirements(module_pt module); - -CELIX_FRAMEWORK_DEPRECATED_EXPORT linked_list_pt module_getCapabilities(module_pt module); - CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_array_list_t *module_getDependentImporters(module_pt module); CELIX_FRAMEWORK_DEPRECATED_EXPORT void module_addDependentImporter(module_pt module, module_pt importer); diff --git a/libs/framework/src/bundle.c b/libs/framework/src/bundle.c index 20a14e7e..731441b5 100644 --- a/libs/framework/src/bundle.c +++ b/libs/framework/src/bundle.c @@ -343,36 +343,18 @@ celix_status_t bundle_closeRevisions(const_bundle_pt bundle) { return status; } -celix_status_t bundle_closeModules(const_bundle_pt bundle) { - celix_status_t status = CELIX_SUCCESS; - - unsigned int i = 0; - for (i = 0; i < arrayList_size(bundle->modules); i++) { - module_pt module = (module_pt) arrayList_get(bundle->modules, i); - module_setWires(module, NULL); - } - - return status; -} - celix_status_t bundle_refresh(bundle_pt bundle) { - celix_status_t status; - module_pt module; - - status = bundle_closeModules(bundle); - if (status == CELIX_SUCCESS) { - arrayList_clear(bundle->modules); - status = bundle_createModule(bundle, &module); - if (status == CELIX_SUCCESS) { - status = bundle_addModule(bundle, module); - if (status == CELIX_SUCCESS) { - __atomic_store_n(&bundle->state, CELIX_BUNDLE_STATE_INSTALLED, __ATOMIC_RELEASE); - } - } - } - - framework_logIfError(bundle->framework->logger, status, NULL, "Failed to refresh bundle"); + module_pt module; + arrayList_clear(bundle->modules); + celix_status_t status = bundle_createModule(bundle, &module); + if (status == CELIX_SUCCESS) { + status = bundle_addModule(bundle, module); + if (status == CELIX_SUCCESS) { + __atomic_store_n(&bundle->state, CELIX_BUNDLE_STATE_INSTALLED, __ATOMIC_RELEASE); + } + } + framework_logIfError(bundle->framework->logger, status, NULL, "Failed to refresh bundle"); return status; } diff --git a/libs/framework/src/bundle_archive.c b/libs/framework/src/bundle_archive.c index d5f0059d..68856734 100644 --- a/libs/framework/src/bundle_archive.c +++ b/libs/framework/src/bundle_archive.c @@ -37,7 +37,6 @@ #include "bundle_archive_private.h" #include "bundle_revision_private.h" #include "framework_private.h" -#include "linked_list_iterator.h" /** * The bundle archive which is used to store the bundle data and can be reused when a framework is restarted. diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c index 227eb77e..bdfd0ee6 100644 --- a/libs/framework/src/framework.c +++ b/libs/framework/src/framework.c @@ -1998,7 +1998,6 @@ static celix_status_t celix_framework_uninstallBundleEntryImpl(celix_framework_t if (status == CELIX_SUCCESS) { celix_framework_waitForEmptyEventQueue(framework); //to ensure that the uninstall event is triggered and handled - (void)bundle_closeModules(bnd); (void)bundle_destroy(bnd); if(permanent) { celix_bundleArchive_invalidate(archive); diff --git a/libs/framework/src/manifest_parser.h b/libs/framework/src/manifest_parser.h index f19de356..a4136633 100644 --- a/libs/framework/src/manifest_parser.h +++ b/libs/framework/src/manifest_parser.h @@ -30,7 +30,6 @@ #include "module.h" #include "version.h" #include "manifest.h" -#include "linked_list.h" typedef struct manifestParser * manifest_parser_pt; diff --git a/libs/framework/src/module.c b/libs/framework/src/module.c index 0ff49057..ed68c45a 100644 --- a/libs/framework/src/module.c +++ b/libs/framework/src/module.c @@ -26,7 +26,6 @@ #include "utils.h" #include "module.h" #include "manifest_parser.h" -#include "linked_list_iterator.h" #include "celix_libloader.h" #include "celix_framework.h" #include "celix_constants.h" @@ -187,13 +186,6 @@ char * module_getId(module_pt module) { return module->id; } -linked_list_pt module_getWires(module_pt module) { - return NULL; -} - -void module_setWires(module_pt module, linked_list_pt wires) { -} - bool module_isResolved(module_pt module) { return module->resolved; } @@ -206,14 +198,6 @@ bundle_pt module_getBundle(module_pt module) { return module->bundle; } -linked_list_pt module_getRequirements(module_pt module) { - return NULL; -} - -linked_list_pt module_getCapabilities(module_pt module) { - return NULL; -} - array_list_pt module_getDependentImporters(module_pt module) { return NULL; } diff --git a/libs/utils/CMakeLists.txt b/libs/utils/CMakeLists.txt index f9b01260..a9b31234 100644 --- a/libs/utils/CMakeLists.txt +++ b/libs/utils/CMakeLists.txt @@ -33,8 +33,6 @@ if (UTILS) set(UTILS_SRC src/array_list.c src/hash_map.c - src/linked_list.c - src/linked_list_iterator.c src/celix_threads.c src/version.c src/version_range.c @@ -137,43 +135,6 @@ if (UTILS) target_link_libraries(utils_cut PUBLIC ${UTILS_PUBLIC_DEPS} ${UTILS_PRIVATE_DEPS}) add_subdirectory(gtest) - - find_package(CppUTest) - - if (CppUTest_FOUND) - include_directories(SYSTEM PRIVATE ${CppUTest_INCLUDE_DIR}) - include_directories(include) - include_directories(src) - - add_executable(hash_map_test private/test/hash_map_test.cpp) - target_include_directories(hash_map_test PRIVATE include_deprecated) - target_link_libraries(hash_map_test utils_cut CppUTest pthread) - - add_executable(array_list_test private/test/array_list_test.cpp) - target_include_directories(array_list_test PRIVATE include_deprecated) - target_link_libraries(array_list_test utils_cut CppUTest pthread) - - add_executable(linked_list_test private/test/linked_list_test.cpp) - target_include_directories(linked_list_test PRIVATE include_deprecated) - target_link_libraries(linked_list_test utils_cut CppUTest pthread) - - add_executable(ip_utils_test private/test/ip_utils_test.cpp) - target_include_directories(ip_utils_test PRIVATE include_deprecated) - target_link_libraries(ip_utils_test CppUTest utils_cut pthread) - - add_test(NAME run_array_list_test COMMAND array_list_test) - add_test(NAME run_hash_map_test COMMAND hash_map_test) - add_test(NAME run_linked_list_test COMMAND linked_list_test) - add_test(NAME run_ip_utils_test COMMAND ip_utils_test) - - setup_target_for_coverage(hash_map_test) - setup_target_for_coverage(array_list_test) - setup_target_for_coverage(linked_list_test) - setup_target_for_coverage(ip_utils_test) - else () - message(WARNING "Cannot find CppUTest, deprecated cpputest-based unit test will not be added") - endif () #end CppUTest_FOUND - endif () add_subdirectory(benchmark) diff --git a/libs/utils/include_deprecated/linked_list.h b/libs/utils/include_deprecated/linked_list.h deleted file mode 100644 index 5e379153..00000000 --- a/libs/utils/include_deprecated/linked_list.h +++ /dev/null @@ -1,92 +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. - */ -/** - * linked_list.h - * - * \date Jul 16, 2010 - * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ - -#ifndef LINKED_LIST_H_ -#define LINKED_LIST_H_ - - -#include "celix_errno.h" -#include "celix_utils_export.h" - -#include <stdbool.h> - -#ifdef __cplusplus -extern "C" { -#endif -typedef struct linked_list_entry *linked_list_entry_pt __attribute__((deprecated("linked_list is deprecated use celix_long_hash_map or celix_array_list instead"))); -typedef struct linked_list *linked_list_pt __attribute__((deprecated("linked_list is deprecated use celix_long_hash_map or celix_array_list instead"))); - -CELIX_UTILS_DEPRECATED_EXPORT celix_status_t linkedList_create(linked_list_pt *list); - -CELIX_UTILS_DEPRECATED_EXPORT celix_status_t linkedList_destroy(linked_list_pt list); - -CELIX_UTILS_DEPRECATED_EXPORT celix_status_t linkedList_clone(linked_list_pt list, linked_list_pt *clone); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedList_getFirst(linked_list_pt list); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedList_getLast(linked_list_pt list); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedList_removeFirst(linked_list_pt list); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedList_removeLast(linked_list_pt list); - -CELIX_UTILS_DEPRECATED_EXPORT void linkedList_addFirst(linked_list_pt list, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT void linkedList_addLast(linked_list_pt list, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT bool linkedList_contains(linked_list_pt list, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT int linkedList_size(linked_list_pt list); - -CELIX_UTILS_DEPRECATED_EXPORT bool linkedList_isEmpty(linked_list_pt list); - -CELIX_UTILS_DEPRECATED_EXPORT bool linkedList_addElement(linked_list_pt list, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT bool linkedList_removeElement(linked_list_pt list, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT void linkedList_clear(linked_list_pt list); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedList_get(linked_list_pt list, int index); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedList_set(linked_list_pt list, int index, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT void linkedList_addIndex(linked_list_pt list, int index, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedList_removeIndex(linked_list_pt list, int index); - -CELIX_UTILS_DEPRECATED_EXPORT linked_list_entry_pt linkedList_entry(linked_list_pt list, int index); - -CELIX_UTILS_DEPRECATED_EXPORT int linkedList_indexOf(linked_list_pt list, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT linked_list_entry_pt linkedList_addBefore(linked_list_pt list, void *element, linked_list_entry_pt entry); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedList_removeEntry(linked_list_pt list, linked_list_entry_pt entry); - -#ifdef __cplusplus -} -#endif - -#endif /* LINKED_LIST_H_ */ diff --git a/libs/utils/include_deprecated/linked_list_iterator.h b/libs/utils/include_deprecated/linked_list_iterator.h deleted file mode 100644 index 2de1b724..00000000 --- a/libs/utils/include_deprecated/linked_list_iterator.h +++ /dev/null @@ -1,66 +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. - */ -/** - * linked_list_iterator.h - * - * \date Jul 16, 2010 - * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ - -#ifndef LINKED_LIST_ITERATOR_H_ -#define LINKED_LIST_ITERATOR_H_ - -#include <stdbool.h> - -#include "linked_list.h" -#include "celix_utils_export.h" - -#ifdef __cplusplus -extern "C" { -#endif -typedef struct linkedListIterator *linked_list_iterator_pt; - -CELIX_UTILS_DEPRECATED_EXPORT linked_list_iterator_pt linkedListIterator_create(linked_list_pt list, unsigned int index); - -CELIX_UTILS_DEPRECATED_EXPORT void linkedListIterator_destroy(linked_list_iterator_pt iterator); - -CELIX_UTILS_DEPRECATED_EXPORT bool linkedListIterator_hasNext(linked_list_iterator_pt iterator); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedListIterator_next(linked_list_iterator_pt iterator); - -CELIX_UTILS_DEPRECATED_EXPORT bool linkedListIterator_hasPrevious(linked_list_iterator_pt iterator); - -CELIX_UTILS_DEPRECATED_EXPORT void *linkedListIterator_previous(linked_list_iterator_pt iterator); - -CELIX_UTILS_DEPRECATED_EXPORT int linkedListIterator_nextIndex(linked_list_iterator_pt iterator); - -CELIX_UTILS_DEPRECATED_EXPORT int linkedListIterator_previousIndex(linked_list_iterator_pt iterator); - -CELIX_UTILS_DEPRECATED_EXPORT void linkedListIterator_remove(linked_list_iterator_pt iterator); - -CELIX_UTILS_DEPRECATED_EXPORT void linkedListIterator_set(linked_list_iterator_pt iterator, void *element); - -CELIX_UTILS_DEPRECATED_EXPORT void linkedListIterator_add(linked_list_iterator_pt iterator, void *element); - -#ifdef __cplusplus -} -#endif - -#endif /* LINKED_LIST_ITERATOR_H_ */
