Rainer Gerhards b2caab060e
testbench: add --yaml-only mode to generate_conf
Why:
  Tests that exercise the YAML configuration loader need to run without
  any RainerScript preamble.  The existing generate_conf function always
  writes a .conf file using legacy and RainerScript directives, making it
  impossible to test pure-YAML startup paths.

Technical Overview:
  - imdiag: replace EMPTY_STRUCT with real modConfData_s fields; add
    BEGINsetModCnf (listenportfilename, aborttimeout), BEGINendCnfLoad,
    BEGINnewInpInst (port), and the three STD_CONF2 queryEtryPt macros.
    Legacy $IMDiag* directives are preserved unchanged.  Fix a NULL
    deref in addTCPListener when pszLstnPortFileName is not set.
  - diag.sh: generate_conf gains a --yaml-only flag that writes a pure
    YAML preamble (version/global/mainqueue/modules/inputs) instead of a
    .conf file.  net.ipprotocol is resolved before the preamble is written
    to avoid a duplicate global: key.  add_yaml_conf() mirrors add_conf()
    for the yaml path.  startup_common selects .yaml when
    RSYSLOG_YAML_ONLY=1.  wait_startup comment documents that .started is
    absent in yaml-only mode and that the OR logic handles it.
  - tests/yaml-basic-yamlonly.sh: new test exercising the yaml-only path
    end-to-end (imtcp, 100 messages, seq_check).
  - tests/Makefile.am: register yaml-basic-yamlonly.sh under TESTS_LIBYAML.
  - tests/AGENTS.md: document the yaml-only mode, its limitations, and
    the expected naming/registration conventions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-29 10:25:09 +02:00
..
2022-02-17 10:54:12 +01:00
2025-10-11 15:24:04 +02:00
2020-01-19 16:09:44 +01:00
2022-02-17 10:54:12 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-11 16:30:26 +01:00
2022-02-17 10:54:12 +01:00
2022-02-17 10:54:12 +01:00
2022-02-17 10:54:12 +01:00
2019-12-27 13:57:25 +01:00
2019-12-27 14:14:54 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2025-09-05 09:35:26 +02:00
2019-12-27 13:57:25 +01:00
2019-08-20 09:11:16 +02:00
2020-01-19 16:09:44 +01:00
2022-07-15 15:46:27 +02:00
2019-07-30 09:00:01 +02:00
2020-01-19 16:09:44 +01:00
2025-09-05 09:35:26 +02:00
2019-12-27 13:57:25 +01:00
2020-01-19 16:09:44 +01:00
2019-12-27 13:57:25 +01:00
2019-12-27 13:57:25 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2025-09-05 09:35:26 +02:00
2020-01-19 16:09:44 +01:00
2026-01-15 15:08:39 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2020-01-19 16:09:44 +01:00
2022-07-13 14:31:51 +02:00

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# rsyslog testbench quick reference

This directory houses the rsyslog Automake test suite. The
[`tests/AGENTS.md`](./AGENTS.md) file gives AI agents authoring guidance and
conventions; this README focuses on operators and contributors who need to run
the suite.

Most scripts validate a single module, but complex end-to-end scenarios are
welcome. For a minimal example, examine `rtinit.c`, which performs a simple
runtime init/deinit cycle.

## Quickstart

Bootstrap the build tree before attempting to run tests:

```sh
./autogen.sh
./configure --enable-testbench
make -j$(nproc)
make check
```

`make check` compiles the helper binaries, prepares fixtures, and then executes
the entire suite. Use <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop an ongoing run.

## Running individual scenarios

```
make <test-name>.log
```

For example, `make imfile-basic.log` produces `imfile-basic.log` and
`imfile-basic.trs`. Remove those files before re-running to clear cached
results. When you need Automakes logging but do not want to type the `.log`
suffix, use:

```
make check TESTS='imfile-basic.sh'
```

You can also execute scripts directly (`./tests/imfile-basic.sh`) for quicker
iteration, though Automake will not capture transcripts.

## Harness conventions

- Source `diag.sh` at the top of every shell test: `. "$srcdir/diag.sh"`.
- Prefer helpers such as `cmp_exact` and `require_plugin` over ad-hoc shell so
  diagnostics stay consistent. See `tests/AGENTS.md` for a longer checklist.
- Name Valgrind-enabled wrappers with the `-vg.sh` suffix and Helgrind-enabled
  scripts with `-vgthread.sh`. `tests/timereported-utc-vg.sh` illustrates how to
  source the base scenario rather than duplicating it and how to trim emitted
  messages when a slow test would otherwise become prohibitively long under
  Valgrind. Some legacy wrappers predate this pattern; follow the newer style
  when adding or refactoring coverage.

## Environment setup snippets

### MariaDB/MySQL

```
echo "create user 'rsyslog'@'localhost' identified by 'testbench';" | mysql -u root
mysql -u root < ../plugins/ommysql/createDB.sql
echo "grant all on Syslog.* to 'rsyslog'@'localhost';" | mysql -u root
```

### openSUSE tips

Use the graphical `yast2` tool to adjust hostname and firewall rules. SSH
access is disabled in the firewall by default.

## Debugging aids

To pause a test and attach a debugger, add the following guard:

```sh
. "$srcdir/diag.sh" startup
if [ -n "${USE_GDB:-}" ]; then
    echo "attach gdb here"
    sleep 54321 || :
fi
```

Run the scenario in the background, wait for the prompt, and attach GDB:

```
USE_GDB=1 make mytest.sh.log &
tail -f mytest.sh.log  # wait for "attach gdb here"
gdb ../tools/rsyslogd <rsyslogd-pid>
```

After continuing in GDB, terminate the `sleep` with `pkill -f 54321` (or locate
the PID via `ps -ef | grep 54321`).

## Core dump analysis

The harness can inspect core dumps automatically. Ensure the operating system
allows them to be written:

1. Set `ulimit -c unlimited` (you might need to adjust `/etc/security/limits.conf`
   to raise `soft core unlimited`).
2. Confirm `/proc/sys/kernel/core_pattern` is set to `core`. Systemd-based
   distributions often redirect cores elsewhere; revert to the classic format
   with `sudo bash -c 'echo core > /proc/sys/kernel/core_pattern'`.

Avoid applying these tweaks on production hosts.