Commit d8c71f77 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Merge branch '14-add-api-function-to-print-out-error-messages' into 'main'

Resolve "Add API function to print out error messages"

Closes #14

See merge request !10
parents 754f6f57 3cbc9066
Loading
Loading
Loading
Loading
Loading
+31 −4
Original line number Diff line number Diff line
@@ -13,7 +13,16 @@ build:
    - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
    - mkdir -p build
    - cd build
    - cmake -DCMAKE_PREFIX_PATH:STRING=/usr/local -DCMAKE_INSTALL_PREFIX:STRING=${CI_PROJECT_DIR}/compiled -DSCORD_BUILD_EXAMPLES:BOOL=ON -DSCORD_TRANSPORT_LIBRARY=libfabric -DSCORD_TRANSPORT_PROTOCOL=ofi+tcp -DSCORD_BIND_ADDRESS=127.0.0.1 -DSCORD_BIND_PORT=52000 ..
    - cmake
      -DCMAKE_PREFIX_PATH:STRING=/usr/local
      -DCMAKE_INSTALL_PREFIX:STRING=${CI_PROJECT_DIR}/compiled
      -DSCORD_BUILD_EXAMPLES:BOOL=ON
      -DSCORD_BUILD_TESTS:BOOL=ON
      -DSCORD_TRANSPORT_LIBRARY=libfabric
      -DSCORD_TRANSPORT_PROTOCOL=ofi+tcp
      -DSCORD_BIND_ADDRESS=127.0.0.1
      -DSCORD_BIND_PORT=52000
      ..
    - make -j$(nproc) install
  artifacts:
    paths:
@@ -21,6 +30,7 @@ build:
      - compiled/etc/
      - compiled/lib/
      - build/examples/
      - build/tests/
      # depending on your build setup it's most likely a good idea to cache outputs to reduce the build time
  cache:
    key: $CI_COMMIT_REF_SLUG
@@ -29,14 +39,31 @@ build:
      - compiled/bin
      - compiled/etc

# run tests using the binary built before
test:
# run RPC tests using the binary built before
rpc:
  stage: test
  needs: [build]
  script:
    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${CI_PROJECT_DIR}/compiled/lib
    - compiled/bin/scord -f --force-console &
    - build/examples/ping ofi+tcp://127.0.0.1:52000
    - build/examples/cxx/ping ofi+tcp://127.0.0.1:52000
    - pkill -TERM scord
  cache:
    key: $CI_COMMIT_REF_SLUG

# run unit tests
unit:
  stage: test
  needs: [build]
  script:
    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${CI_PROJECT_DIR}/compiled/lib
    - cd build/tests
    - ctest -j$(nproc) --output-junit report.xml
  cache:
    key: $CI_COMMIT_REF_SLUG
  artifacts:
    expire_in: 1 week
    paths:
      - build/tests/report.xml
    reports:
      junit: build/tests/report.xml
+30 −3
Original line number Diff line number Diff line
@@ -123,6 +123,8 @@ message(STATUS "[${PROJECT_NAME}] server bind port: ${SCORD_BIND_PORT}")

option(SCORD_BUILD_EXAMPLES "Build examples (disabled by default)" OFF)

option(SCORD_BUILD_TESTS "Build tests (disabled by default)" OFF)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# ##############################################################################
@@ -225,6 +227,27 @@ FetchContent_Declare(

FetchContent_MakeAvailable(expected)

if (SCORD_BUILD_TESTS)

  enable_testing()

  ### catch2: required for unit testing
  message(STATUS "[${PROJECT_NAME}] Downloading and building Catch2")
  FetchContent_Declare(
    Catch2
    GIT_REPOSITORY https://github.com/catchorg/Catch2.git
    GIT_TAG 605a34765aa5d5ecbf476b4598a862ada971b0cc # v3.0.1
    GIT_SHALLOW ON
    GIT_PROGRESS ON
  )

  FetchContent_MakeAvailable(Catch2)

  # Ensure that CMake can find Catch2 extra CMake modules in case
  # they are needed
  list(APPEND CMAKE_MODULE_PATH "${catch2_SOURCE_DIR}/extras")
endif ()

### Mark any CMake variables imported from {fmt} and spdlog as advanced, so
### that they don't appear in cmake-gui or ccmake. Similarly for FETCHCONTENT
### variables.
@@ -248,3 +271,7 @@ add_subdirectory(src)
if (SCORD_BUILD_EXAMPLES)
  add_subdirectory(examples)
endif ()

if(SCORD_BUILD_TESTS)
  add_subdirectory(tests)
endif()
+23 −3
Original line number Diff line number Diff line
@@ -27,8 +27,9 @@ available in the system:
The following libraries are also required by `scord`, but will be downloaded
and compiled by the project as part of the standard build process.

- [{fmt}]() version 8.0.1 or later.
- [spdlog]() version 1.9.2 or later.
- [{fmt}](https://fmt.dev/latest/index.html) version 8.0.1 or later.
- [spdlog](https://github.com/gabime/spdlog) version 1.9.2 or later.
- [Catch2](https://github.com/catchorg/Catch2) version 3.0.1 or later.

> **ℹ️** **Important**  
Margo and Argobots use `pkg-config` to ensure they compile and link correctly
@@ -75,8 +76,10 @@ The following CMake options can be used to configure how `scord` is built:
  communicate with the service. The value provided here will be used to set
  the `bind_port` configuration option in the `${PREFIX}/etc/scord.conf`
  installed alongside the service.
- `SCORD_BUILD_EXAMPLES`: This option instructs CMakes to build the programs
- `SCORD_BUILD_EXAMPLES`: This option instructs CMake to build the programs
  contained in the `examples` subdirectory.
- `SCORD_BUILD_TESTS`: This option instructs CMake to build the tests
  contained in the `tests` subdirectory.

Thus, let's assume that we want to build `scord` with the following
configuration:
@@ -98,6 +101,7 @@ mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH:STRING=/opt \
      -DCMAKE_INSTALL_PREFIX:STRING=/usr/local \
      -DSCORD_BUILD_EXAMPLES:BOOL=ON \
      -DSCORD_BUILD_TESTS:BOOL=ON \
      -DSCORD_TRANSPORT_LIBRARY=libfabric \
      -DSCORD_TRANSPORT_PROTOCOL=ofi+tcp \
      -DSCORD_BIND_ADDRESS=192.168.0.111 \
@@ -106,6 +110,22 @@ cmake -DCMAKE_PREFIX_PATH:STRING=/opt \
make
```

## Running tests

Tests are integrated in [CTest](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Testing%20With%20CMake%20and%20CTest.html), CMake's testing facility. Once built, the
tests can be run in parallel using the `ctest` command line tool:

```console
~/projects/scord/build $ ctest --parallel 4
Test project /home/amiranda/var/projects/scord/repo/build
    Start 1: Scenario: Error messages can be printed
1/1 Test #1: Scenario: Error messages can be printed ...   Passed    0.14 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.14 sec
```

## Installing

Assuming that the CMAKE_INSTALL_PREFIX has been set (see previous step) and
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ add_library(adm_iosched SHARED)

target_sources(adm_iosched
  PUBLIC admire.h admire.hpp
  PRIVATE admire.cpp c_wrapper.cpp detail/impl.hpp detail/impl.cpp)
  PRIVATE admire.cpp c_wrapper.cpp detail/impl.hpp detail/impl.cpp errors.c)

target_include_directories(adm_iosched PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

+10 −15
Original line number Diff line number Diff line
@@ -60,16 +60,15 @@ register_job(const server& srv, ADM_job_requirements_t reqs) {
    const auto rv = detail::register_job(srv, reqs);

    if(!rv) {
        /* TODO ADM_strerror(rv.error()) */
        throw std::runtime_error("ADM_register_job() error");
        throw std::runtime_error(fmt::format("ADM_register_job() error: {}",
                                             ADM_strerror(rv.error())));
    }

    return rv.value();
}

ADM_return_t
update_job(const server& srv, ADM_job_t job,
           ADM_job_requirements_t reqs) {
update_job(const server& srv, ADM_job_t job, ADM_job_requirements_t reqs) {
    (void) srv;
    (void) job;
    (void) reqs;
@@ -152,8 +151,7 @@ register_adhoc_storage(const server& srv, ADM_job_t job,
}

ADM_return_t
update_adhoc_storage(const server& srv, ADM_job_t job,
                     ADM_adhoc_context_t ctx,
update_adhoc_storage(const server& srv, ADM_job_t job, ADM_adhoc_context_t ctx,
                     ADM_adhoc_storage_handle_t adhoc_handle) {
    (void) srv;
    (void) job;
@@ -301,8 +299,8 @@ set_dataset_information(const server& srv, ADM_job_t job,
}

ADM_return_t
set_io_resources(const server& srv, ADM_job_t job,
                 ADM_storage_handle_t tier, ADM_storage_resources_t resources) {
set_io_resources(const server& srv, ADM_job_t job, ADM_storage_handle_t tier,
                 ADM_storage_resources_t resources) {
    (void) srv;
    (void) job;
    (void) tier;
@@ -447,8 +445,7 @@ get_pending_transfers(const server& srv, ADM_job_t job,
}

ADM_return_t
set_qos_constraints(const server& srv, ADM_job_t job,
                    ADM_limit_t limit) {
set_qos_constraints(const server& srv, ADM_job_t job, ADM_limit_t limit) {
    (void) srv;
    (void) job;
    (void) limit;
@@ -477,9 +474,8 @@ set_qos_constraints(const server& srv, ADM_job_t job,
}

ADM_return_t
get_qos_constraints(const server& srv, ADM_job_t job,
                    ADM_qos_scope_t scope, ADM_qos_entity_t entity,
                    ADM_limit_t** limits) {
get_qos_constraints(const server& srv, ADM_job_t job, ADM_qos_scope_t scope,
                    ADM_qos_entity_t entity, ADM_limit_t** limits) {
    (void) srv;
    (void) job;
    (void) scope;
@@ -641,8 +637,7 @@ link_transfer_to_data_operation(const server& srv, ADM_job_t job,
}

ADM_return_t
get_statistics(const server& srv, ADM_job_t job,
               ADM_job_stats_t** stats) {
get_statistics(const server& srv, ADM_job_t job, ADM_job_stats_t** stats) {
    (void) srv;
    (void) job;
    (void) stats;
Loading