From 8a82286a489ff7c7000414d2aedd9482e3aa7d3e Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Thu, 24 Aug 2023 13:27:06 +0200 Subject: [PATCH 1/7] setup image for ci Update .gitlab-ci.yml file From 9b3378c2759e4783550a8b8438ba67ffee43d767 Mon Sep 17 00:00:00 2001 From: Claus Date: Tue, 29 Aug 2023 12:29:42 +0200 Subject: [PATCH 2/7] Enable more sanitizer checks Add more compiler warnings Prevent or ignore some clang-tdiy warnings too. --- .clang-tidy | 8 ++++---- CMakeLists.txt | 27 ++++++++++++++++++++------- tftpd.hpp | 2 +- tftpd_options.cpp | 14 +++++++------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 207049f..5e3ce97 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,8 +6,6 @@ Checks: boost-*, bugprone-*, cert-*, - -cert-env33-c, - -cert-err58-cpp, clang-analyzer-*, cppcoreguidelines-*, -cppcoreguidelines-avoid-*, @@ -22,6 +20,7 @@ Checks: -hicpp-signed-bitwise, -hicpp-vararg, misc-*, + google-*, -misc-non-private-member-variables-in-classes, modernize-*, -modernize-macro-to-enum, @@ -34,11 +33,12 @@ Checks: -readability-identifier-length, -*avoid-c-arrays, -*magic-numbers, + -bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions ' HeaderFilterRegex: '.*' -#TODO: this is not realy pedantic! CK +#TODO: this isn't realy pedantic tody! CK WarningsAsErrors: - 'clang-diagnostic-error' + '*' diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f20c26..0aed157 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,19 +67,32 @@ target_include_directories( ) if(PROJECT_IS_TOP_LEVEL AND CMAKE_BUILD_TYPE STREQUAL "Debug") +# Enable sanitizers and static analyzers when running the tests + if($ENV{CI}) + set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") + endif() + + check_sanitizers_support( + ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR + ENABLE_SANITIZER_LEAK ENABLE_SANITIZER_THREAD ENABLE_SANITIZER_MEMORY + ) + project_options( PREFIX ${PROJECT_NAME} ENABLE_CACHE ENABLE_COVERAGE - ENABLE_CLANG_TIDY - ENABLE_SANITIZER_ADDRESS - ENABLE_SANITIZER_UNDEFINED_BEHAVIOR - # ENABLE_SANITIZER_LEAK - # ENABLE_SANITIZER_THREAD - # ENABLE_SANITIZER_MEMORY + ${ENABLE_CLANG_TIDY} + ${ENABLE_SANITIZER_ADDRESS} + ${ENABLE_SANITIZER_LEAK} + ${ENABLE_SANITIZER_MEMORY} + ${ENABLE_SANITIZER_THREAD} + ${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR} + ENABLE_CONTROL_FLOW_PROTECTION + ENABLE_STACK_PROTECTION + ENABLE_OVERFLOW_PROTECTION + ENABLE_INCLUDE_WHAT_YOU_USE # XXX NO! WARNINGS_AS_ERRORS - # ENABLE_INCLUDE_WHAT_YOU_USE ) target_link_libraries( diff --git a/tftpd.hpp b/tftpd.hpp index aad0ac7..35cfbcb 100644 --- a/tftpd.hpp +++ b/tftpd.hpp @@ -208,7 +208,7 @@ class server socket_.async_send_to(boost::asio::buffer(txdata), senderEndpoint_, [this](std::error_code /*ec*/, std::size_t /*bytes_sent*/) { // XXX if (ec) { syslog(LOG_ERR, "do_send_error: %s\n", ec.message().c_str()); } - // TODO: now we have no timer running, the run loop terminates + // TODO(CK): now we have no timer running, the run loop terminates timer_.cancel(); throw std::system_error(std::make_error_code(std::errc::operation_canceled)); }); diff --git a/tftpd_options.cpp b/tftpd_options.cpp index 4d155e5..2d769f3 100644 --- a/tftpd_options.cpp +++ b/tftpd_options.cpp @@ -57,7 +57,7 @@ static constexpr bool tsize_ok{true}; // only octet mode supported! uintmax_t g_timeout = MS_1K; // NOTE: 1 s as ms! CK uintmax_t g_segsize{default_blksize}; -off_t g_tsize{0}; +uintmax_t g_tsize{0}; static bool set_blksize(uintmax_t *vp); static bool set_blksize2(uintmax_t *vp); @@ -103,7 +103,7 @@ static bool set_blksize(uintmax_t *vp) sz = max_blksize; } - *vp = g_segsize = sz; + *vp = g_segsize = sz; // TODO(CK): const cast away blksize_set = true; return true; } @@ -137,7 +137,7 @@ static bool set_blksize2(uintmax_t *vp) } } - *vp = g_segsize = sz; + *vp = g_segsize = sz; // TODO(CK): const cast away blksize_set = true; return true; } @@ -176,7 +176,7 @@ static bool set_tsize(uintmax_t *vp) g_tsize = sz; // in case of WRQ } - *vp = sz; + *vp = sz; // TODO(CK): const cast away return true; } @@ -185,7 +185,7 @@ static bool set_tsize(uintmax_t *vp) * to be the (default) retransmission timeout, but being an * integer in seconds it seems a bit limited. */ -static bool set_timeout(uintmax_t *vp) +static bool set_timeout(uintmax_t *vp) // NOLINT(readability-non-const-parameter) { uintmax_t const to = *vp; @@ -201,7 +201,7 @@ static bool set_timeout(uintmax_t *vp) /* * Similar, but in microseconds. We allow down to 10 ms. */ -static bool set_utimeout(uintmax_t *vp) +static bool set_utimeout(uintmax_t *vp) // NOLINT(readability-non-const-parameter) { uintmax_t const to = *vp; @@ -258,7 +258,7 @@ void do_opt(const char *opt, const char *val, char **ackbuf_ptr) errno = 0; char *vend = nullptr; - uintmax_t v = strtoumax(val, &vend, 10); // TODO: or std::strtoul! CK + uintmax_t v = strtoumax(val, &vend, 10); // TODO(CK): or std::strtoul! if (*vend != 0 || errno == ERANGE) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) syslog(LOG_ERR, "tftpd: Invallid option value (%s:%s)\n", opt, val); From e932f05c50dac51be7e547217e5bd8cf1b154388 Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 30 Aug 2023 11:55:29 +0200 Subject: [PATCH 3/7] OSX does not support ENABLE_SANITIZER_LEAK Merge branch 'develop-patch-1613' into 'feature/setup-ci' Update file CPM.cmake Update github ci workflow Use cache for ccache too Update pip too Use cpack for Release build on CI --- .github/workflows/cmake.yml | 57 ++++++++++++++++++++++++------------- .gitlab-ci.yml | 26 ++++++++++++++++- CMakeLists.txt | 3 ++ cmake/CPM.cmake | 12 ++++++++ 4 files changed, 77 insertions(+), 21 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index ab516e4..f050c88 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -2,15 +2,19 @@ name: CMake on: - push: - branches: ["develop"] pull_request: - branches: ["develop"] + merge_group: + push: + branches: + - 'master' + - 'releases/**' env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Debug + # XXX BUILD_TYPE: Debug CTEST_OUTPUT_ON_FAILURE: 1 + CMAKE_EXPORT_COMPILE_COMMANDS: 1 + CCACHE_DIR: ${{ github.workspace }}/.ccache CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules jobs: @@ -20,6 +24,7 @@ jobs: matrix: os: [macos, ubuntu] + BUILD_TYPE: [Debug, Release] runs-on: ${{ matrix.os }}-latest @@ -28,46 +33,58 @@ jobs: - uses: actions/cache@v3 with: - path: "**/cpm_modules" + path: | + "**/.ccache" + "**/cpm_modules" key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }} + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' # caching pip dependencies + + - run: | + sudo python -m pip install --upgrade pip + sudo pip install -r requirements.txt + - name: Setup Cpp if: startsWith(matrix.os, 'ubuntu') uses: aminya/setup-cpp@v1 with: - cmake: true - ninja: true - gcovr: true + llvm: true + ccache: true clangtidy: true + clangformat: true - - name: Install boost filesystem libs and python3 tftpy module on macos + - name: Install boost libs and ccache on macos if: startsWith(matrix.os, 'macos') shell: bash run: | - sudo pip3 install tftpy gcovr - brew install boost ccache cmake ninja + brew install boost ccache - - name: Install boost tftpy module on ubuntu + - name: Install boost filesystem libs on ubuntu if: startsWith(matrix.os, 'ubuntu') shell: bash run: | - sudo pip3 install tftpy - sudo apt-get install libboost-filesystem-dev ccache + sudo apt-get install libboost-filesystem-dev - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} - name: Build # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}} - name: Test working-directory: ${{github.workspace}}/build # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: sudo ctest -C ${{env.BUILD_TYPE}} --verbose + run: sudo ctest -C ${{matrix.BUILD_TYPE}} - name: TestCoverage + if: startsWith(matrix.BUILD_TYPE, 'Debug') run: gcovr -e option_test.cpp -e tftpd_test.cpp . + + - name: Install + if: startsWith(matrix.BUILD_TYPE, 'Rel') + working-directory: ${{github.workspace}}/build + run: cpack -C ${{matrix.BUILD_TYPE}} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24522e0..19ee0be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,30 @@ # This specific template is located at: # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml +# Configure pipeline workflow / execution accordingly: +# - Tag pipelines always. +# - Merge request pipelines when a merge request is open for the branch. +# - Branch pipelines when a merge request is not open for the branch. +# https://docs.gitlab.com/ee/ci/yaml/workflow.html# +# switch-between-branch-pipelines-and-merge-request-pipelines +workflow: + rules: + - if: $CI_COMMIT_TAG + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS + when: never + - if: $CI_COMMIT_BRANCH + +variables: + # GIT_CONFIG_PARAMETERS: 'url.git@code.rsint.net:mirror/github.com/.insteadOf=https://github.com/' + PIP_INDEX_URL: "https://pypi.rsint.net/api/pypi/rs_pypi_virtual/simple" + # Required CPU's for execution in Kubernetes cluster + KUBERNETES_CPU_LIMIT: 2 + CICD_BUILD_ARCH: x86_64 + CICD_USER: $SERVICE_USER + CICD_PASSWORD: $SERVICE_USER_API_KEY + + default: image: saas-linux-small-amd64 tags: [linux] @@ -39,7 +63,7 @@ build-job: # This job runs in the build stage, which runs first. - .standard-rules # Reuse the configuration in `.standard-rules` here script: - echo "Compiling the code..." - - cmake --preset default + - GIT_CONFIG_PARAMETERS=url.git@code.rsint.net:mirror/github.com/.insteadOf=https://github.com/ cmake --preset default - cmake --build --preset default - echo "Compile complete." diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aed157..cb80cc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,9 @@ if(PROJECT_IS_TOP_LEVEL AND CMAKE_BUILD_TYPE STREQUAL "Debug") ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR ENABLE_SANITIZER_LEAK ENABLE_SANITIZER_THREAD ENABLE_SANITIZER_MEMORY ) + if(APPLE) + unset(ENABLE_SANITIZER_LEAK) + endif() project_options( PREFIX diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 0abb277..da65d75 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -17,6 +17,18 @@ set(CPM_DOWNLOAD_LOCATION get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) function(download_cpm) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + set(GITHUB_MIRROR "https://code.rsint.net/mirror/github.com") + file(DOWNLOAD ${GITHUB_MIRROR}/cpm-cmake/CPM.cmake/-/raw/v${CPM_DOWNLOAD_VERSION}/cmake/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) + # Version number needs to be patched. + file(READ ${CPM_DOWNLOAD_LOCATION} FILE_CONTENT) + string(REPLACE "1.0.0-development-version" "${CPM_DOWNLOAD_VERSION}" FILE_CONTENT "${FILE_CONTENT}") + file(WRITE ${CPM_DOWNLOAD_LOCATION} "${FILE_CONTENT}") +endfunction() + +function(download_cpm_orig) message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") file( DOWNLOAD From 27d8c194af71565f133542f4c6fcb291e3734089 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Thu, 31 Aug 2023 06:07:32 +0200 Subject: [PATCH 4/7] update git config settings for gitlab CI Setup githup mirror on gitlab Fix cpm bootstrap on CI Use Workaround to prevent load of submodules Needed as ProjectOptions try to load an example as git submodue. Prevent load of unused packages --- .gitlab-ci.yml | 31 +++++++++++++++++++++++++------ CMakeLists.txt | 41 +++++++++++++++++++++++++++++++---------- CMakePresets.json | 17 +++++++++++++++++ cmake/CPM.cmake | 30 +++++++++++++++++++----------- 4 files changed, 92 insertions(+), 27 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 19ee0be..7fc8f99 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,7 @@ # - Branch pipelines when a merge request is not open for the branch. # https://docs.gitlab.com/ee/ci/yaml/workflow.html# # switch-between-branch-pipelines-and-merge-request-pipelines +--- workflow: rules: - if: $CI_COMMIT_TAG @@ -31,21 +32,39 @@ workflow: - if: $CI_COMMIT_BRANCH variables: - # GIT_CONFIG_PARAMETERS: 'url.git@code.rsint.net:mirror/github.com/.insteadOf=https://github.com/' PIP_INDEX_URL: "https://pypi.rsint.net/api/pypi/rs_pypi_virtual/simple" + # GIT_SUBMODULE_STRATEGY: normal + # GIT_SUBMODULE_DEPTH: 1 # Required CPU's for execution in Kubernetes cluster KUBERNETES_CPU_LIMIT: 2 CICD_BUILD_ARCH: x86_64 CICD_USER: $SERVICE_USER CICD_PASSWORD: $SERVICE_USER_API_KEY - default: +<<<<<<< HEAD image: saas-linux-small-amd64 tags: [linux] before_script: | export PATH="$HOME/.local/bin:$PATH" pip install -U -r requirements.txt +======= + image: docker.rsint.net/rs_common/rs-ubuntu:22.04-buildessential-2023-07-02 + tags: [linux-container] + before_script: + - echo -e "\e[0Ksection_start:`date +%s`:my_setup_linux[collapsed=true]\r\e[0KHeader of the setup linux collapsible section" + - export PATH="$HOME/.local/bin:$PATH" + - sudo ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime + - sudo apt update + - sudo apt install --assume-yes clang-tidy python3-pip libboost-filesystem-dev + - python3 -m pip install -U -r requirements.txt + - echo -e "\e[0Ksection_end:`date +%s`:my_setup_linux\r\e[0K" + # - git config --global url.git@code.rsint.net:mirror/github.com/.insteadOf https://github.com/ + - git config --global user.name "Claus Klein" + - git config --global user.email "claus.klein@rohde-schwarz.com" + - git config --global -l + - git clone https://github.com/aminya/project_options.git +>>>>>>> 2d8f8eb (update git config settings for gitlab CI) .standard-rules: # Make a hidden job to hold the common rules rules: @@ -62,10 +81,9 @@ build-job: # This job runs in the build stage, which runs first. extends: - .standard-rules # Reuse the configuration in `.standard-rules` here script: - - echo "Compiling the code..." - - GIT_CONFIG_PARAMETERS=url.git@code.rsint.net:mirror/github.com/.insteadOf=https://github.com/ cmake --preset default - - cmake --build --preset default - - echo "Compile complete." + - echo "Build default workflow ..." + - cmake --workflow --preset default --fresh + - echo "Build workflow complete." unit-test-job: # This job runs in the test stage. stage: test # It only starts when the job in the build stage completes successfully. @@ -73,6 +91,7 @@ unit-test-job: # This job runs in the test stage. - .standard-rules # Reuse the configuration in `.standard-rules` here script: - echo "Running unit tests... This will take about a view seconds." + - cmake --preset default --fresh - cmake --build --preset default --target test - gcovr . diff --git a/CMakeLists.txt b/CMakeLists.txt index cb80cc2..1569442 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ include(GNUInstallDirs) # COMPONENTS filesystem asio headers # REQUIRED # ) - # ---- Add other dependencies via CPM ---- # see https://github.com/cpm-cmake/CPM.cmake for more info @@ -67,17 +66,37 @@ target_include_directories( ) if(PROJECT_IS_TOP_LEVEL AND CMAKE_BUILD_TYPE STREQUAL "Debug") -# Enable sanitizers and static analyzers when running the tests - if($ENV{CI}) + # ProjectOptions will be used for compiler settings and appropriate CMake options + # NOTE(CK): Set GIT_SUBMODULES to empty string to NOT initializes submodules! + cmake_policy(SET CMP0097 NEW) + CPMAddPackage( + NAME ProjectOptions + GIT_TAG v0.32.1 + GITHUB_REPOSITORY + aminya/project_options + GIT_SUBMODULES + "docs" # NOTE(CK): Workaround existing dir to prevent load of submodule + ) + if(ProjectOptions_SOURCE_DIR) + message(DEBUG "${ProjectOptions_SOURCE_DIR} added") + list(APPEND CMAKE_MODULE_PATH ${ProjectOptions_SOURCE_DIR}/src) + endif() + + # Enable sanitizers and static analyzers when running the tests + set(ENABLE_CLANG_TIDY NO) + if(DEFINED ENV{CI}) set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") + set(ENABLE_SANITIZER_THREAD "ENABLE_SANITIZER_THREAD") + else() + check_sanitizers_support( + ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR + ENABLE_SANITIZER_LEAK ENABLE_SANITIZER_THREAD + ENABLE_SANITIZER_MEMORY + ) endif() - check_sanitizers_support( - ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR - ENABLE_SANITIZER_LEAK ENABLE_SANITIZER_THREAD ENABLE_SANITIZER_MEMORY - ) if(APPLE) - unset(ENABLE_SANITIZER_LEAK) + set(ENABLE_SANITIZER_LEAK NO) endif() project_options( @@ -110,6 +129,9 @@ endif() # Install and export tftpd-targets #--------------------------------------------------------------------------------------- if(NOT CMAKE_SKIP_INSTALL_RULES) + # PackageProject.cmake will be used to make our target installable + CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.11.0") + packageProject( NAME ${PROJECT_NAME} VERSION ${PROJECT_VERSION} @@ -152,9 +174,8 @@ if(NETKIT_TFTP_TESTS) enable_testing() add_executable(option_test option_test.cpp async_tftpd_server.hpp) - #NO! CK target_include_directories(option_test SYSTEM PRIVATE include) target_link_libraries(option_test PRIVATE tftpd) - add_test(NAME option_test COMMAND option_test) + # FIXME add_test(NAME option_test COMMAND option_test) add_executable(tftpd_test tftpd_test.cpp async_tftpd_server.hpp) target_link_libraries(tftpd_test PRIVATE tftpd) diff --git a/CMakePresets.json b/CMakePresets.json index 6f09c59..0d350fe 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -106,6 +106,23 @@ "name": "default" } ] + }, + { + "name": "debug", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "default" + }, + { + "type": "test", + "name": "default" + } + ] } ] } diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index da65d75..e82bac8 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -18,27 +18,35 @@ get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) function(download_cpm) message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") - set(GITHUB_MIRROR "https://code.rsint.net/mirror/github.com") - file(DOWNLOAD ${GITHUB_MIRROR}/cpm-cmake/CPM.cmake/-/raw/v${CPM_DOWNLOAD_VERSION}/cmake/CPM.cmake - ${CPM_DOWNLOAD_LOCATION} + file( + DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} ) - # Version number needs to be patched. - file(READ ${CPM_DOWNLOAD_LOCATION} FILE_CONTENT) - string(REPLACE "1.0.0-development-version" "${CPM_DOWNLOAD_VERSION}" FILE_CONTENT "${FILE_CONTENT}") - file(WRITE ${CPM_DOWNLOAD_LOCATION} "${FILE_CONTENT}") endfunction() -function(download_cpm_orig) - message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") +function(download_cpm_CI) + message(STATUS "Downloading CPM.cmake ON CI to ${CPM_DOWNLOAD_LOCATION}") + set(GITHUB_MIRROR "https://code.rsint.net/mirror/github.com") file( DOWNLOAD - https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${GITHUB_MIRROR}/cpm-cmake/CPM.cmake/-/raw/v${CPM_DOWNLOAD_VERSION}/cmake/CPM.cmake ${CPM_DOWNLOAD_LOCATION} ) + # Version number needs to be patched. + file(READ ${CPM_DOWNLOAD_LOCATION} FILE_CONTENT) + string(REPLACE "1.0.0-development-version" "${CPM_DOWNLOAD_VERSION}" + FILE_CONTENT "${FILE_CONTENT}" + ) + file(WRITE ${CPM_DOWNLOAD_LOCATION} "${FILE_CONTENT}") endfunction() if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) - download_cpm() + if(DEFINED ENV{CICD_USER}) + download_cpm_ci() + else() + download_cpm() + endif() else() # resume download if it previously failed file(READ ${CPM_DOWNLOAD_LOCATION} check) From 3e282e3d3aacbf5a4ce8c0787c8b886f40427b12 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Thu, 15 Feb 2024 10:10:42 +0100 Subject: [PATCH 5/7] Install with pip -U Use default compiler on CI use git@code.rsint.net:mirror --- .clang-tidy | 2 +- .github/workflows/cmake.yml | 25 +++++++++++++++---------- .gitlab-ci.yml | 18 ------------------ CMakeLists.txt | 5 ++++- GNUmakefile | 6 +++--- 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 5e3ce97..359370b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -39,6 +39,6 @@ Checks: HeaderFilterRegex: '.*' -#TODO: this isn't realy pedantic tody! CK +#TODO: this isn't realy pedantic today! CK WarningsAsErrors: '*' diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f050c88..c883690 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -38,21 +38,22 @@ jobs: "**/cpm_modules" key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }} - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - cache: 'pip' # caching pip dependencies + # - uses: actions/setup-python@v4 + # with: + # python-version: '3.11' + # cache: 'pip' # caching pip dependencies + # # pip but doesn't exist on disk: /home/runner/.cache/pip - - run: | - sudo python -m pip install --upgrade pip - sudo pip install -r requirements.txt + - name: Setup python3 + run: | + sudo python3 -m pip install --upgrade pip + sudo python3 -m pip install -U -r requirements.txt + # /root/.cache/pip/ - name: Setup Cpp if: startsWith(matrix.os, 'ubuntu') uses: aminya/setup-cpp@v1 with: - llvm: true - ccache: true clangtidy: true clangformat: true @@ -69,7 +70,11 @@ jobs: sudo apt-get install libboost-filesystem-dev - name: Configure CMake - run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} + run: | + which cmake ninja + cmake --version + cmake --version + cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} - name: Build # Build your program with the given configuration diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7fc8f99..156bceb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,29 +42,11 @@ variables: CICD_PASSWORD: $SERVICE_USER_API_KEY default: -<<<<<<< HEAD image: saas-linux-small-amd64 tags: [linux] before_script: | export PATH="$HOME/.local/bin:$PATH" pip install -U -r requirements.txt -======= - image: docker.rsint.net/rs_common/rs-ubuntu:22.04-buildessential-2023-07-02 - tags: [linux-container] - before_script: - - echo -e "\e[0Ksection_start:`date +%s`:my_setup_linux[collapsed=true]\r\e[0KHeader of the setup linux collapsible section" - - export PATH="$HOME/.local/bin:$PATH" - - sudo ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime - - sudo apt update - - sudo apt install --assume-yes clang-tidy python3-pip libboost-filesystem-dev - - python3 -m pip install -U -r requirements.txt - - echo -e "\e[0Ksection_end:`date +%s`:my_setup_linux\r\e[0K" - # - git config --global url.git@code.rsint.net:mirror/github.com/.insteadOf https://github.com/ - - git config --global user.name "Claus Klein" - - git config --global user.email "claus.klein@rohde-schwarz.com" - - git config --global -l - - git clone https://github.com/aminya/project_options.git ->>>>>>> 2d8f8eb (update git config settings for gitlab CI) .standard-rules: # Make a hidden job to hold the common rules rules: diff --git a/CMakeLists.txt b/CMakeLists.txt index 1569442..228e478 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,7 +175,10 @@ if(NETKIT_TFTP_TESTS) add_executable(option_test option_test.cpp async_tftpd_server.hpp) target_link_libraries(option_test PRIVATE tftpd) - # FIXME add_test(NAME option_test COMMAND option_test) + + if(NOT DEFINED ENV{CI}) + add_test(NAME option_test COMMAND option_test) + endif() add_executable(tftpd_test tftpd_test.cpp async_tftpd_server.hpp) target_link_libraries(tftpd_test PRIVATE tftpd) diff --git a/GNUmakefile b/GNUmakefile index 974a664..6e7c10b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -22,8 +22,8 @@ PROJECT_NAME:=$(shell basename $${PWD}) # prevent hard config of find_package(asio 1.14.1 CONFIG CMAKE_FIND_ROOT_PATH_BOTH) ifeq (NO${CROSS_COMPILE},NO) ifeq (${UNAME},Darwin) - #TODO CC:=/usr/local/opt/llvm/bin/clang - #TODO CXX:=/usr/local/opt/llvm/bin/clang++ + CC:=/usr/bin/gcc + CXX:=/usr/bin/g++ BOOST_ROOT:=/usr/local/opt/boost export BOOST_ROOT endif @@ -44,7 +44,7 @@ endif #NO! BUILD_TYPE=Coverage make lcov BUILD_TYPE?=Debug BUILD_TYPE?=Release -# GENERATOR:=Xcode +GENERATOR:=Xcode GENERATOR?=Ninja # end of config part From b96c595131262232ce7a21cd0f8a8fd4da065bde Mon Sep 17 00:00:00 2001 From: Claus Klein Date: Thu, 15 Feb 2024 12:05:30 +0100 Subject: [PATCH 6/7] Refactory cmake preset add Debug and Relese workflow presets use Ninja Multi-Config generator for Debug --- .gitlab-ci.yml | 8 +- CMakeLists.txt | 7 +- CMakePresets.json | 233 ++++++++++++++++++++++++---------------------- test.sh | 63 +++++++------ 4 files changed, 162 insertions(+), 149 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 156bceb..c314af9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,8 +63,8 @@ build-job: # This job runs in the build stage, which runs first. extends: - .standard-rules # Reuse the configuration in `.standard-rules` here script: - - echo "Build default workflow ..." - - cmake --workflow --preset default --fresh + - echo "Build Release workflow ..." + - cmake --workflow --preset Release --fresh - echo "Build workflow complete." unit-test-job: # This job runs in the test stage. @@ -73,8 +73,8 @@ unit-test-job: # This job runs in the test stage. - .standard-rules # Reuse the configuration in `.standard-rules` here script: - echo "Running unit tests... This will take about a view seconds." - - cmake --preset default --fresh - - cmake --build --preset default --target test + - cmake --preset Release --fresh + - cmake --build --preset Release --target test - gcovr . lint-test-job: # This job also runs in the test stage. diff --git a/CMakeLists.txt b/CMakeLists.txt index 228e478..1ff5d92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,9 +89,8 @@ if(PROJECT_IS_TOP_LEVEL AND CMAKE_BUILD_TYPE STREQUAL "Debug") set(ENABLE_SANITIZER_THREAD "ENABLE_SANITIZER_THREAD") else() check_sanitizers_support( - ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR - ENABLE_SANITIZER_LEAK ENABLE_SANITIZER_THREAD - ENABLE_SANITIZER_MEMORY + ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR ENABLE_SANITIZER_LEAK + ENABLE_SANITIZER_THREAD ENABLE_SANITIZER_MEMORY ) endif() @@ -186,7 +185,7 @@ if(NETKIT_TFTP_TESTS) if(UNIX) add_test( NAME tftpd_test - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh $ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif() diff --git a/CMakePresets.json b/CMakePresets.json index 0d350fe..0291d4e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,128 +1,141 @@ { - "version": 6, - "cmakeMinimumRequired": { - "major": 3, - "minor": 25, - "patch": 0 - }, - "configurePresets": [ - { - "name": "default", - "displayName": "Default user Config", - "description": "Default build using Ninja generator", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build", - "installDir": "${sourceDir}/stagedir", - "cacheVariables": { - "CMAKE_PREFIX_PATH": { - "type": "path", - "value": "${sourceDir}/stagedir" - }, - "CMAKE_CXX_STANDARD": "20", - "CMAKE_BUILD_TYPE": "Release", - "CMAKE_DEBUG_POSTFIX": "D", - "BUILD_SHARED_LIBS": true - }, - "environment": { - "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", - "CPM_USE_LOCAL_PACKAGES": "NO", - "CPM_SOURCE_CACHE": "$env{HOME}/.cache/CPM", - "PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}" - }, - "warnings": { - "deprecated": true, - "uninitialized": true - } - }, - { - "name": "ninja-multi", - "inherits": "default", - "displayName": "Ninja Multi-Config", - "description": "Default build using Ninja Multi-Config generator", - "generator": "Ninja Multi-Config" - }, - { - "name": "windows-only", - "inherits": "default", - "displayName": "Windows-only configuration", - "description": "This build is only available on Windows", - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" - } - } - ], - "buildPresets": [ - { - "name": "default", - "configurePreset": "default" + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 }, - { - "name": "install", - "configurePreset": "default", - "targets": ["install"] - } - ], - "testPresets": [ - { - "name": "default", - "configurePreset": "default", - "output": {"outputOnFailure": true}, - "execution": {"noTestsAction": "error", "stopOnFailure": true} - } - ], - "packagePresets": [ - { - "name": "default", - "configurePreset": "default", - "generators": [ - "TGZ" - ] - } - ], - "workflowPresets": [ - { - "name": "default", - "steps": [ + "configurePresets": [ { - "type": "configure", - "name": "default" + "name": "Release", + "displayName": "Release user Config", + "description": "Release build using Ninja generator", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/{presetName}", + "installDir": "${sourceDir}/stagedir", + "cacheVariables": { + "CMAKE_PREFIX_PATH": { + "type": "path", + "value": "${sourceDir}/stagedir" + }, + "CMAKE_CXX_STANDARD": "20", + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_DEBUG_POSTFIX": "D", + "BUILD_SHARED_LIBS": true + }, + "environment": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", + "CPM_USE_LOCAL_PACKAGES": "NO", + "CPM_SOURCE_CACHE": "$env{HOME}/.cache/CPM", + "PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}" + }, + "warnings": { + "deprecated": true, + "uninitialized": true + } }, { - "type": "build", - "name": "default" - }, + "name": "Debug", + "inherits": "Release", + "displayName": "Ninja Multi-Config", + "description": "Debug build using Ninja Multi-Config generator", + "generator": "Ninja Multi-Config" + } + ], + "buildPresets": [ { - "type": "test", - "name": "default" + "name": "Debug", + "configurePreset": "Debug", + "configuration": "Debug" }, { - "type": "build", - "name": "install" + "name": "Release", + "configurePreset": "Release" }, { - "type": "package", - "name": "default" + "name": "install", + "configurePreset": "Release", + "targets": [ + "install" + ] } - ] - }, - { - "name": "debug", - "steps": [ + ], + "testPresets": [ { - "type": "configure", - "name": "default" + "name": "Release", + "configurePreset": "Release", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } }, { - "type": "build", - "name": "default" + "name": "Debug", + "configurePreset": "Debug", + "configuration": "Debug", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + } + ], + "packagePresets": [ + { + "name": "Release", + "configurePreset": "Release", + "generators": [ + "TGZ" + ] + } + ], + "workflowPresets": [ + { + "name": "Release", + "steps": [ + { + "type": "configure", + "name": "Release" + }, + { + "type": "build", + "name": "Release" + }, + { + "type": "test", + "name": "Release" + }, + { + "type": "build", + "name": "install" + }, + { + "type": "package", + "name": "Release" + } + ] }, { - "type": "test", - "name": "default" + "name": "Debug", + "steps": [ + { + "type": "configure", + "name": "Debug" + }, + { + "type": "build", + "name": "Debug" + }, + { + "type": "test", + "name": "Debug" + } + ] } - ] - } - ] + ] } diff --git a/test.sh b/test.sh index e387d25..502e187 100755 --- a/test.sh +++ b/test.sh @@ -12,6 +12,7 @@ cd ${PWD} UNAME=`uname` script_dir=`dirname "$0"` ln -sf ${script_dir}/tftpy_client.py . +tftpd_test="$1" ############################################## if test "${UNAME}" == "Linux"; then @@ -24,7 +25,7 @@ fi ############################################## ## TODO: upload should fail, no tftpboot dir -# bin/tftpd_test 1234 & +# $tftpd_test 1234 & # sleep 1 # ${TFTP} -m binary -c put build.ninja zero.dat && exit 1 # wait @@ -37,7 +38,7 @@ chmod 400 ${TFTPDIR}/zero.dat # NOTE: we start server at bg # download must fail, dir not world readable -bin/tftpd_test 1234 & +$tftpd_test 1234 & sleep 1 chmod 700 ${TFTPDIR} sync @@ -45,13 +46,13 @@ ${TFTP} --download=zero.dat && exit 1 wait ## TODO: upload should fail in secure mode if file not world writeable -# bin/tftpd_test 1234 & +# $tftpd_test 1234 & # ${TFTP} -m binary -c put build.ninja zero.dat && exit 1 # wait # must fail no such file chmod 777 ${TFTPDIR} -bin/tftpd_test 1234 & +$tftpd_test 1234 & sleep 1 ${TFTP} --download=none.dat && exit 1 wait @@ -67,16 +68,16 @@ fi ############################################## ## test exact blocksize upload -dd if=bin/tftpd_test of=test1block.dat bs=512 count=1 -bin/tftpd_test 1234 & +dd if=$tftpd_test of=test1block.dat bs=512 count=1 +$tftpd_test 1234 & sleep 1 ${TFTP} --upload=test1block.dat diff ${TFTPDIR}/test1block.dat test1block.dat wait ############################################## ## test modulo blocksize upload -dd if=bin/tftpd_test of=test1k.dat bs=1024 count=1 -bin/tftpd_test 1234 & +dd if=$tftpd_test of=test1k.dat bs=1024 count=1 +$tftpd_test 1234 & sleep 1 ${TFTP} --upload=test1k.dat diff ${TFTPDIR}/test1k.dat test1k.dat @@ -84,8 +85,8 @@ wait ############################################## # NOTE: we start server at bg # only one upload should fail -dd if=bin/tftpd_test of=test16k.dat bs=1024 count=16 -bin/tftpd_test 1234 & +dd if=$tftpd_test of=test16k.dat bs=1024 count=16 +$tftpd_test 1234 & sleep 1 ${TFTP} --input=test16k.dat --upload=first.dat & ${TFTP} --input=test16k.dat --upload=second.dat & @@ -98,47 +99,47 @@ test -f ${TFTPDIR}/second.dat && diff test16k.dat ${TFTPDIR}/second.dat # not 1 client only! touch ${TFTPDIR}/zero.dat chmod 666 ${TFTPDIR}/zero.dat -bin/tftpd_test 1234 & +$tftpd_test 1234 & sleep 1 ${TFTP} --download=zero.dat && exit 1 wait ############################################## if test "${UNAME}" == "Linux"; then - dd if=bin/tftpd_test of=test64k.dat bs=1024 count=64 + dd if=$tftpd_test of=test64k.dat bs=1024 count=64 - bin/tftpd_test 1234 & + $tftpd_test 1234 & sleep 1 ${TFTP} --blksize=16384 --upload=test64k.dat --input=test64k.dat wait #--------------------------------------------- - bin/tftpd_test 1234 & + $tftpd_test 1234 & sleep 1 ${TFTP} --blksize=32768 --upload=test64k.dat --input=test64k.dat wait #--------------------------------------------- - bin/tftpd_test 1234 & + $tftpd_test 1234 & sleep 1 ${TFTP} --blksize=65536 --upload=test64k.dat --input=test64k.dat wait else /bin/dd if=/dev/zero of=test64m.dat bs=1m count=64 - bin/tftpd_test 1234 & + $tftpd_test 1234 & sleep 1 ${TFTP} --blksize=1024 --upload=test64m.dat --input=test64m.dat wait #--------------------------------------------- - bin/tftpd_test 1234 & + $tftpd_test 1234 & sleep 1 ${TFTP} --blksize=2048 --upload=test64m.dat --input=test64m.dat wait #--------------------------------------------- - bin/tftpd_test 1234 & + $tftpd_test 1234 & sleep 1 ${TFTP} --blksize=4096 --upload=test64m.dat --input=test64m.dat wait @@ -150,7 +151,7 @@ fi ############################################## # normal binary upload with duplicate ack's # TODO: should not fail -## bin/tftpd_test 1234 & +## $tftpd_test 1234 & ## sleep 1 ## printf "rexmt 1\nverbose\ntrace\nbinary\nput build.ninja\n" | bin/tftp 127.0.0.1 1234 ## test -f ${TFTPDIR}/build.ninja && diff ${TFTPDIR}/build.ninja build.ninja @@ -161,47 +162,47 @@ fi # upload large file > 224K: echo "NOTE: must fail, disk full!" if test "${UNAME}" == "Linux"; then - bin/tftpd_test 1234 & + /bin/dd if=/dev/zero of=test256k.dat bs=1024 count=256 + $tftpd_test 1234 & sleep 1 - ${TFTP} --input=bin/tftpd_test --upload=tftpd_test && exit 1 - #XXX diff ${TFTPDIR}/tftpd_test bin/tftpd_test || echo "OK" + ${TFTP} --input=test256k.dat --upload=test256k.dat && exit 1 wait fi ############################################## echo "NOTE: absolute path upload must fail!" -dd if=bin/tftpd_test of=test32k.dat bs=1024 count=32 -bin/tftpd_test 1234 & +dd if=$tftpd_test of=test32k.dat bs=1024 count=32 +$tftpd_test 1234 & sleep 1 ${TFTP} --input=test32k.dat --upload=${TFTPDIR}/test32k.dat && exit 1 wait ############################################## # TODO: ascii upload should fail -## bin/tftpd_test 1234 & +## $tftpd_test 1234 & ## sleep 1 ## ${TFTP} -m ascii -c put build.ninja && exit 1 ## wait # relative path upload must fail -bin/tftpd_test 1234 & +$tftpd_test 1234 & sleep 1 ${TFTP} --input=build.ninja --upload=../build.ninja && exit 1 wait # relative path upload must fail -bin/tftpd_test 1234 & +$tftpd_test 1234 & sleep 1 ${TFTP} --input=build.ninja --upload=./../build.ninja && exit 1 wait # invalid absolute path upload must fail -bin/tftpd_test 1234 & +$tftpd_test 1234 & sleep 1 ${TFTP} --input=build.ninja --upload=//srv///tftp/build.ninja && exit 1 wait # relative path to nonexisting subdir must fail -bin/tftpd_test 1234 & +$tftpd_test 1234 & sleep 1 ${TFTP} --input=build.ninja --upload=./tftp/build.ninja && exit 1 wait @@ -209,8 +210,8 @@ wait ############################################## echo "test idle timeout (10 seconds) ..." # port must be free, no error expected -bin/tftpd_test 1234 +$tftpd_test 1234 # test help -bin/tftpd_test || echo "OK" +$tftpd_test || echo "OK" From c354fddcb3c99f4b080748e92f915c7d0c62b10a Mon Sep 17 00:00:00 2001 From: Claus Klein Date: Thu, 15 Feb 2024 12:25:50 +0100 Subject: [PATCH 7/7] Use /dev/random for test data --- CMakePresets.json | 2 +- test.sh | 57 +++++++++++++++++------------------------------ 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 0291d4e..a6589e5 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -11,7 +11,7 @@ "displayName": "Release user Config", "description": "Release build using Ninja generator", "generator": "Ninja", - "binaryDir": "${sourceDir}/build/{presetName}", + "binaryDir": "${sourceDir}/build/${presetName}", "installDir": "${sourceDir}/stagedir", "cacheVariables": { "CMAKE_PREFIX_PATH": { diff --git a/test.sh b/test.sh index 502e187..5965be0 100755 --- a/test.sh +++ b/test.sh @@ -106,44 +106,29 @@ wait ############################################## if test "${UNAME}" == "Linux"; then - dd if=$tftpd_test of=test64k.dat bs=1024 count=64 - - $tftpd_test 1234 & - sleep 1 - ${TFTP} --blksize=16384 --upload=test64k.dat --input=test64k.dat - wait - - #--------------------------------------------- - $tftpd_test 1234 & - sleep 1 - ${TFTP} --blksize=32768 --upload=test64k.dat --input=test64k.dat - wait - - #--------------------------------------------- - $tftpd_test 1234 & - sleep 1 - ${TFTP} --blksize=65536 --upload=test64k.dat --input=test64k.dat - wait + /bin/dd if=/dev/random of=test64k.dat bs=1024 count=64 else /bin/dd if=/dev/zero of=test64m.dat bs=1m count=64 +fi - $tftpd_test 1234 & - sleep 1 - ${TFTP} --blksize=1024 --upload=test64m.dat --input=test64m.dat - wait +#--------------------------------------------- +$tftpd_test 1234 & +sleep 1 +${TFTP} --blksize=16384 --upload=test64k.dat --input=test64k.dat +wait - #--------------------------------------------- - $tftpd_test 1234 & - sleep 1 - ${TFTP} --blksize=2048 --upload=test64m.dat --input=test64m.dat - wait +#--------------------------------------------- +$tftpd_test 1234 & +sleep 1 +${TFTP} --blksize=32768 --upload=test64k.dat --input=test64k.dat +wait + +#--------------------------------------------- +$tftpd_test 1234 & +sleep 1 +${TFTP} --blksize=65536 --upload=test64k.dat --input=test64k.dat +wait - #--------------------------------------------- - $tftpd_test 1234 & - sleep 1 - ${TFTP} --blksize=4096 --upload=test64m.dat --input=test64m.dat - wait -fi ############################################## ############################################## @@ -162,7 +147,7 @@ fi # upload large file > 224K: echo "NOTE: must fail, disk full!" if test "${UNAME}" == "Linux"; then - /bin/dd if=/dev/zero of=test256k.dat bs=1024 count=256 + /bin/dd if=/dev/random of=test256k.dat bs=1024 count=256 $tftpd_test 1234 & sleep 1 ${TFTP} --input=test256k.dat --upload=test256k.dat && exit 1 @@ -170,10 +155,10 @@ if test "${UNAME}" == "Linux"; then fi ############################################## echo "NOTE: absolute path upload must fail!" -dd if=$tftpd_test of=test32k.dat bs=1024 count=32 +dd if=$tftpd_test of=test16k.dat bs=1024 count=16 $tftpd_test 1234 & sleep 1 -${TFTP} --input=test32k.dat --upload=${TFTPDIR}/test32k.dat && exit 1 +${TFTP} --input=test16k.dat --upload=${TFTPDIR}/test16k.dat && exit 1 wait ##############################################