CI & Automation
Relevant source files
The following files were used as context for generating this wiki page:
The CI & Automation system in librelp is designed to ensure code quality, protocol reliability, and cross-platform compatibility through automated build, test, and analysis pipelines. The system leverages containerized environments to provide consistent build states across different infrastructure providers, such as Travis CI.
The automation suite covers the entire development lifecycle, from code style enforcement and static analysis to functional test benches and code coverage reporting. It specifically targets multiple TLS libraries (GnuTLS and OpenSSL) and various compiler versions to maintain the library's "reliable" protocol guarantees.
CI Execution Lifecycle
The primary entry point for CI runs is the run-ci.sh script, which orchestrates the build and test sequence within a development container.
The diagram above shows the linear progression of a generic CI run as defined in the project's automation scripts.
Sources: devtools/run-ci.sh:4-65
Core Components and Environment
The CI environment is heavily parameterized to support different configurations. Key variables include:
- DEV_CONTAINER: The specific Docker image used for the run.
- CC / CFLAGS: Compiler selection (e.g.,
gcc-9,clang-9) and flags, including sanitizers. - CI_CHECK_CMD: The specific test command, defaulting to
check. - CI_VALGRIND_SUPPRESSIONS: Path to Valgrind suppression files for the testbench.
Sources: devtools/run-ci.sh:5-23, devtools/devcontainer.sh:40-66
Build and Static Analysis
Automation includes specialized scripts for static analysis and multi-compiler verification.
Static Analysis Pipeline
The run-static-analyzer.sh script utilizes scan-build with clang to identify potential logic errors and memory mismanagement without executing the code.
Sources: devtools/run-static-analyzer.sh:5-30
Multi-Compiler Testing
The project runs explicit compile tests across different environments to ensure broad compatibility. This includes:
- Style Checks: Enforcement of coding standards via
check-codestyle.sh. - Compiler Matrix: Specific steps for
gcc-9andclang-9. - OS Variants: Verification of Alpine Linux builds via Docker.
- TLS Matrix: Separate passes for
--enable-tls(GnuTLS) and--enable-tls-openssl(OpenSSL).
Sources: devtools/travis-run-compile-tests.sh:9-62
Test Framework and Logging
The functional testing of librelp is supported by a comprehensive shell-based framework that manages mock RELP entities.
Test Orchestration
The test-framework.sh provides utility functions to manage the lifecycle of RELP senders and receivers during integration tests. It handles port allocation, process startup verification via PID files, and Valgrind integration.
| Function | Description |
|---|---|
get_free_port | Uses Python to dynamically find an available TCP port. |
startup_receiver | Launches the ./receive test binary and waits for PID confirmation. |
check_msg_count | Verifies the number of messages processed using the chkseq tool. |
do_tls_subtests | Iterates through available TLS libraries to run tests against both GnuTLS and OpenSSL. |
Sources: tests/test-framework.sh:25-212
Log Management and Reporting
To prevent CI timeouts and handle large log volumes, gather-check-logs.sh processes test results.
- Failure Detection: Scans
.trsfiles for:test-result: FAIL. - Size Limiting: If a log exceeds 4,000 lines, it truncates the middle, showing only the head and tail to stay within CI buffer limits.
- Incomplete Tests: Identifies tests that aborted without producing a
.trsfile.
Sources: devtools/gather-check-logs.sh:7-54
Containerized Execution Logic
The devcontainer.sh script facilitates the mapping of local source code into a standardized rsyslog development container. It proxies environment variables and capabilities (like SYS_PTRACE for debuggers) to ensure the container environment matches the requirements for low-level network testing.
The sequence above illustrates how local developer commands are wrapped in container execution for environmental parity.
Sources: devtools/devcontainer.sh:20-68
Summary
The CI & Automation infrastructure of librelp ensures protocol reliability by enforcing strict code styling, performing deep static analysis, and running an automated testbench across a matrix of compilers and TLS implementations. By utilizing containerization and automated log gathering, the project maintains high visibility into build health and test failures.