diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | .vscode/c_cpp_properties.json | 3 | ||||
-rw-r--r-- | CMakeLists.txt (renamed from 02_exercise/CMakeLists.txt) | 35 | ||||
m--------- | externals/sanitizers-cmake | 0 | ||||
-rw-r--r-- | shell/.gitignore (renamed from 02_exercise/.gitignore) | 1 | ||||
-rw-r--r-- | shell/CMakeLists.txt | 34 | ||||
-rw-r--r-- | shell/Makefile (renamed from 02_exercise/Makefile) | 0 | ||||
-rw-r--r-- | shell/array.c (renamed from 02_exercise/array.c) | 0 | ||||
-rw-r--r-- | shell/array.h (renamed from 02_exercise/array.h) | 0 | ||||
-rw-r--r-- | shell/beispiele/dup/Makefile (renamed from 02_exercise/beispiele/dup/Makefile) | 0 | ||||
-rw-r--r-- | shell/beispiele/dup/dup.c (renamed from 02_exercise/beispiele/dup/dup.c) | 0 | ||||
-rw-r--r-- | shell/beispiele/fork_example/Makefile (renamed from 02_exercise/beispiele/fork_example/Makefile) | 0 | ||||
-rw-r--r-- | shell/beispiele/fork_example/fork.c (renamed from 02_exercise/beispiele/fork_example/fork.c) | 0 | ||||
-rw-r--r-- | shell/beispiele/fork_signal/Makefile (renamed from 02_exercise/beispiele/fork_signal/Makefile) | 0 | ||||
-rw-r--r-- | shell/beispiele/fork_signal/fork.c (renamed from 02_exercise/beispiele/fork_signal/fork.c) | 0 | ||||
-rw-r--r-- | shell/beispiele/fork_signal/signal.c (renamed from 02_exercise/beispiele/fork_signal/signal.c) | 0 | ||||
-rw-r--r-- | shell/beispiele/pipe_bidirect/Makefile (renamed from 02_exercise/beispiele/pipe_bidirect/Makefile) | 0 | ||||
-rw-r--r-- | shell/beispiele/pipe_bidirect/log.txt (renamed from 02_exercise/beispiele/pipe_bidirect/log.txt) | 0 | ||||
-rw-r--r-- | shell/beispiele/pipe_bidirect/pingpong.c (renamed from 02_exercise/beispiele/pipe_bidirect/pingpong.c) | 0 | ||||
-rw-r--r-- | shell/beispiele/pipe_example/Makefile (renamed from 02_exercise/beispiele/pipe_example/Makefile) | 0 | ||||
-rw-r--r-- | shell/beispiele/pipe_example/pipe.c (renamed from 02_exercise/beispiele/pipe_example/pipe.c) | 0 | ||||
-rw-r--r-- | shell/process.c (renamed from 02_exercise/process.c) | 0 | ||||
-rw-r--r-- | shell/process.h (renamed from 02_exercise/process.h) | 0 | ||||
-rw-r--r-- | shell/process_test.c (renamed from 02_exercise/process_test.c) | 4 | ||||
-rw-r--r-- | shell/prog.c (renamed from 02_exercise/prog.c) | 0 | ||||
-rw-r--r-- | shell/prompt_utils.c (renamed from 02_exercise/prompt_utils.c) | 0 | ||||
-rw-r--r-- | shell/prompt_utils.h (renamed from 02_exercise/prompt_utils.h) | 0 | ||||
-rw-r--r-- | shell/prompt_utils_test.c (renamed from 02_exercise/prompt_utils_test.c) | 4 | ||||
-rw-r--r-- | shell/prompt_utils_test.h (renamed from 02_exercise/prompt_utils_test.h) | 0 | ||||
-rw-r--r-- | shell/shell.c (renamed from 02_exercise/shell.c) | 3 |
31 files changed, 57 insertions, 33 deletions
@@ -3,4 +3,5 @@ *_exe *.d cmake-build-debug/ -bootloader.bin
\ No newline at end of file +bootloader.bin +build
\ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b49debd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "externals/sanitizers-cmake"] + path = externals/sanitizers-cmake + url = git://github.com/arsenm/sanitizers-cmake.git diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index d57b434..2796da8 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -22,7 +22,8 @@ "-MMD", "-MP", "-D=_GNU_SOURCE" - ] + ], + "configurationProvider": "ms-vscode.cmake-tools" } ], "version": 4 diff --git a/02_exercise/CMakeLists.txt b/CMakeLists.txt index ca67d1a..4db1f5d 100644 --- a/02_exercise/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,31 +1,16 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.0.0) +project(Betriebsysteme VERSION 0.1.0) -project(shell C) +include(CTest) +enable_testing() -set(CMAKE_C_COMPILER gcc) -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED True) - -add_executable(prog prog.c) -add_executable(shell shell.c) -target_link_libraries(shell PRIVATE array prompt_utils process) -add_compile_definitions(_GNU_SOURCE) - -add_library(array array.c) - -add_library(prompt_utils prompt_utils.c) -target_link_libraries(prompt_utils PRIVATE array) - -add_executable(prompt_utils_test prompt_utils_test.c) -target_link_libraries(prompt_utils_test PRIVATE prompt_utils array) - -add_library(process process.c) -target_link_libraries(process PRIVATE array) - -add_executable(process_test process_test.c) -target_link_libraries(process_test PRIVATE process) +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH}) +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) +include(CPack) +add_subdirectory(shell) set(CLANG_WARNINGS -Wall @@ -53,5 +38,3 @@ set(GCC_WARNINGS # probably wanted ) set(PROJECT_WARNINGS ${GCC_WARNINGS}) -target_compile_options(shell INTERFACE ${PROJECT_WARNINGS}) -target_compile_options(prompt_utils INTERFACE ${PROJECT_WARNINGS})
\ No newline at end of file diff --git a/externals/sanitizers-cmake b/externals/sanitizers-cmake new file mode 160000 +Subproject 99e159ec9bc8dd362b08d18436bd40ff0648417 diff --git a/02_exercise/.gitignore b/shell/.gitignore index 5aacf99..819a501 100644 --- a/02_exercise/.gitignore +++ b/shell/.gitignore @@ -1,2 +1,3 @@ prog shell +build
\ No newline at end of file diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt new file mode 100644 index 0000000..9cae089 --- /dev/null +++ b/shell/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.5) + +project(shell C) + +set(CMAKE_C_COMPILER gcc) +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED True) + +find_package(Sanitizers) + +add_executable(prog prog.c) +add_executable(shell shell.c) +target_link_libraries(shell PRIVATE array prompt_utils process) + +add_sanitizers(shell) +add_compile_definitions(_GNU_SOURCE) + +add_library(array array.c) + +add_library(prompt_utils prompt_utils.c) +target_link_libraries(prompt_utils PRIVATE array) + +add_executable(prompt_utils_test prompt_utils_test.c) +target_link_libraries(prompt_utils_test PRIVATE prompt_utils array) + +add_library(process process.c) +target_link_libraries(process PRIVATE array) + +add_executable(process_test process_test.c) +target_link_libraries(process_test PRIVATE process) + +target_compile_options(shell INTERFACE ${PROJECT_WARNINGS}) +target_compile_options(prompt_utils INTERFACE ${PROJECT_WARNINGS}) +target_compile_options(process INTERFACE ${PROJECT_WARNINGS}) diff --git a/02_exercise/Makefile b/shell/Makefile index 5d1b360..5d1b360 100644 --- a/02_exercise/Makefile +++ b/shell/Makefile diff --git a/02_exercise/array.c b/shell/array.c index 4f08366..4f08366 100644 --- a/02_exercise/array.c +++ b/shell/array.c diff --git a/02_exercise/array.h b/shell/array.h index 78d21c9..78d21c9 100644 --- a/02_exercise/array.h +++ b/shell/array.h diff --git a/02_exercise/beispiele/dup/Makefile b/shell/beispiele/dup/Makefile index 0f73ac4..0f73ac4 100644 --- a/02_exercise/beispiele/dup/Makefile +++ b/shell/beispiele/dup/Makefile diff --git a/02_exercise/beispiele/dup/dup.c b/shell/beispiele/dup/dup.c index ea3c5a6..ea3c5a6 100644 --- a/02_exercise/beispiele/dup/dup.c +++ b/shell/beispiele/dup/dup.c diff --git a/02_exercise/beispiele/fork_example/Makefile b/shell/beispiele/fork_example/Makefile index 8f69ed9..8f69ed9 100644 --- a/02_exercise/beispiele/fork_example/Makefile +++ b/shell/beispiele/fork_example/Makefile diff --git a/02_exercise/beispiele/fork_example/fork.c b/shell/beispiele/fork_example/fork.c index 7377b0f..7377b0f 100644 --- a/02_exercise/beispiele/fork_example/fork.c +++ b/shell/beispiele/fork_example/fork.c diff --git a/02_exercise/beispiele/fork_signal/Makefile b/shell/beispiele/fork_signal/Makefile index 499b8cb..499b8cb 100644 --- a/02_exercise/beispiele/fork_signal/Makefile +++ b/shell/beispiele/fork_signal/Makefile diff --git a/02_exercise/beispiele/fork_signal/fork.c b/shell/beispiele/fork_signal/fork.c index b144577..b144577 100644 --- a/02_exercise/beispiele/fork_signal/fork.c +++ b/shell/beispiele/fork_signal/fork.c diff --git a/02_exercise/beispiele/fork_signal/signal.c b/shell/beispiele/fork_signal/signal.c index 500d2e1..500d2e1 100644 --- a/02_exercise/beispiele/fork_signal/signal.c +++ b/shell/beispiele/fork_signal/signal.c diff --git a/02_exercise/beispiele/pipe_bidirect/Makefile b/shell/beispiele/pipe_bidirect/Makefile index 361ac97..361ac97 100644 --- a/02_exercise/beispiele/pipe_bidirect/Makefile +++ b/shell/beispiele/pipe_bidirect/Makefile diff --git a/02_exercise/beispiele/pipe_bidirect/log.txt b/shell/beispiele/pipe_bidirect/log.txt index c59b0bb..c59b0bb 100644 --- a/02_exercise/beispiele/pipe_bidirect/log.txt +++ b/shell/beispiele/pipe_bidirect/log.txt diff --git a/02_exercise/beispiele/pipe_bidirect/pingpong.c b/shell/beispiele/pipe_bidirect/pingpong.c index f38394f..f38394f 100644 --- a/02_exercise/beispiele/pipe_bidirect/pingpong.c +++ b/shell/beispiele/pipe_bidirect/pingpong.c diff --git a/02_exercise/beispiele/pipe_example/Makefile b/shell/beispiele/pipe_example/Makefile index d69473e..d69473e 100644 --- a/02_exercise/beispiele/pipe_example/Makefile +++ b/shell/beispiele/pipe_example/Makefile diff --git a/02_exercise/beispiele/pipe_example/pipe.c b/shell/beispiele/pipe_example/pipe.c index 422e4d5..422e4d5 100644 --- a/02_exercise/beispiele/pipe_example/pipe.c +++ b/shell/beispiele/pipe_example/pipe.c diff --git a/02_exercise/process.c b/shell/process.c index 093b712..093b712 100644 --- a/02_exercise/process.c +++ b/shell/process.c diff --git a/02_exercise/process.h b/shell/process.h index 3b7e833..3b7e833 100644 --- a/02_exercise/process.h +++ b/shell/process.h diff --git a/02_exercise/process_test.c b/shell/process_test.c index a7b0b9c..c14aa59 100644 --- a/02_exercise/process_test.c +++ b/shell/process_test.c @@ -53,11 +53,11 @@ void test_ls(){ free_processes(&processes); } -/* + int main() { test_ls(); test_simple_case(); test_detached(); test_pipe(); return 0; -}*/ +} diff --git a/02_exercise/prog.c b/shell/prog.c index efd2527..efd2527 100644 --- a/02_exercise/prog.c +++ b/shell/prog.c diff --git a/02_exercise/prompt_utils.c b/shell/prompt_utils.c index 168c088..168c088 100644 --- a/02_exercise/prompt_utils.c +++ b/shell/prompt_utils.c diff --git a/02_exercise/prompt_utils.h b/shell/prompt_utils.h index 36d065d..36d065d 100644 --- a/02_exercise/prompt_utils.h +++ b/shell/prompt_utils.h diff --git a/02_exercise/prompt_utils_test.c b/shell/prompt_utils_test.c index 8bc29de..1be6162 100644 --- a/02_exercise/prompt_utils_test.c +++ b/shell/prompt_utils_test.c @@ -36,10 +36,10 @@ void test_relative_path() { test_paths("/B/C", "/", "../.."); } -/* + int main(void) { test_relative_path(); test_get_separator_indices(); return 0; } -*/ + diff --git a/02_exercise/prompt_utils_test.h b/shell/prompt_utils_test.h index 59717d0..59717d0 100644 --- a/02_exercise/prompt_utils_test.h +++ b/shell/prompt_utils_test.h diff --git a/02_exercise/shell.c b/shell/shell.c index f456465..dd0085d 100644 --- a/02_exercise/shell.c +++ b/shell/shell.c @@ -30,7 +30,6 @@ int main(void) { if (strspn(line, " \n\t") == strlen(line)) { continue; } - line[length - 1] = '\0'; // cut the line feed Process * processes = NULL; @@ -68,6 +67,8 @@ int main(void) { clean: free((void *)line); + line = NULL; + cap = 0; free_processes(&processes); } |