Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Test Suite

Functional and integration tests that verify the correctness of every layer, from raw io_uring events up to full GObj protocol stacks. All tests are registered as ctest targets and run automatically with yunetas test.

Source: tests/c/

This page describes the tests by subject, and not every binary has a row here. The complete index is tests/c/README.md in the repository: every directory that tests/c/CMakeLists.txt builds, the binaries of each directory that has more than one, and the ctest name of each. Each directory’s own README.md says what its binaries check (for timeranger2, all 37 of them).

# Run the full suite
yunetas test

# Run a single test by name
ctest -R '^test_c_timer$' --output-on-failure --test-dir build

# Run ctest in a loop until first failure (flaky-test detection)
./ctest-loop.sh

# Run tests at once
ctest -j8 -R "c_tcp|c_mqtt|tcps" --test-dir build

Tests that run at once

ctest -j runs test binaries at the same time, so no two of them can use one fixed port (the second fails with “bind() FAILED”) or one fixed directory. Every test binary under tests/c and performance/c listens on ports of its own, and a new test takes new ones, below 32768: Linux gives the ports of its ephemeral range (32768-60999) to any socket that does not bind one, so a fixed port there can be held by a client of another test, or by a yuno running beside the suite, and the test fails to bind it by chance (test_c_udp_s_tx did, on 34282). The UDP tests use 24281-24301.

python3 scripts/check_test_ports.py          # exit 1 when two binaries share a port, a port is in the ephemeral range, or a file cannot be read
python3 scripts/check_test_ports.py --list   # every port and the binary of it
python3 scripts/check_test_ports.py --build-dir=X   # another build tree (default: build)

The files of one binary can share a port (main_<name>.c with c_<name>.c, or everything under <test>/src/). A port given at compile time is read from the target_compile_definitions() of the CMakeLists.txt when it is written there (TEST7_PORT_TLS="7798"), and from the build tree when CMake computes it: c_task_authenticate gives each binary of its loop its own IDP_PORT (18911-18942):

math(EXPR idp_port "18910 + ${test_number}")
target_compile_definitions(${binary} PRIVATE IDP_PORT="${idp_port}")

The script reads those values from the flags.make of each target, so it needs a configured build/ of the Makefile generator (as check_test_databases.py does, and yunetas configures it that way). Without one, or when a computed name is in no flags.make of the dir (a Ninja tree has none), it names the CMakeLists.txt and exits 1: a port it cannot read is a port it did not check.

The c_mqtt tests that keep a store make a work dir of their own run, <$TMPDIR or /tmp>/<name>.<pid>.<n>, and remove it at the end (tests/c/c_mqtt/test_work_dir.c). Up to 7.25.20 ten ports were shared (the c_tcp/c_tcps families on 7778, the c_auth_bff binaries on 18801/18802, the yev_events tests on 3333, among others), and each c_mqtt test wiped a fixed /tmp/test_mqtt_<name> at its start. Two whole suites at once on one machine still share each binary’s port.

A directory under ~/tests_yuneta that two binaries use is declared in their CMakeLists.txt, so ctest never runs them at once. Each binary that holds the directory takes a RESOURCE_LOCK named after it. When one binary fills the directory and others read it, the writer is the FIXTURES_SETUP and the readers are FIXTURES_REQUIRED, so ctest also runs the writer first when you ask for one reader alone:

set_tests_properties("timeranger2/test_topic_pkey_integer" PROPERTIES
    FIXTURES_SETUP tr_topic_pkey_integer
    RESOURCE_LOCK tr_topic_pkey_integer
)
set_tests_properties("timeranger2/test_topic_pkey_integer_iterator3" PROPERTIES
    FIXTURES_REQUIRED tr_topic_pkey_integer
    RESOURCE_LOCK tr_topic_pkey_integer
)

The locks in use are tr_topic_pkey_integer (with DEPENDS: _iterator6 appends to the directory, so it runs after the other iterators), tr_msg, tr_delete_instance, perf_topic_integer, and inotify_flood (the two tests that flood the per-user inotify queue). The benchmarks and the tr_topic_pkey_integer chain are RUN_SERIAL: the release trend reads their times, and other tests that run at the same time change them. So are the tests that assert a time window of the wall clock (test_yevent_timer_once1, _once2, _periodic1, _kept_after_post, test_c_timer, test_c_timer0, test_static_resolv_numeric): a stall of a loaded machine moved test_yevent_timer_once1 from 1.0 s to 1.8 s, out of its 0.9-1.1 s window. And test_fs_watcher_overflow, which asserts the watcher’s cost per directory on a big tree against a small one: under -j8 on a loaded node it measured 713 us against 48, where 6 times is the bound. And test_c_controlcenter_scenarios, which asserts the rate of a burst over its 1.5 s tick.

To compare the TIMES of two runs, compare runs of one job count. yunetas test names its log after it (build/<date>.j<N>.txt, CLI 0.21.1+), and only the RUN_SERIAL tests run alone under -j. Take the times of the others from a serial run:

yunetas test --serial     # build/<date>.j1.txt
grep "timeranger2/test_topic_pkey_integer \.\.\." build/*.j1.txt

A new test that reuses a directory of another test must declare the same lock.

scripts/check_test_databases.py checks it, as check_test_ports.py checks the ports. It reads the directories of each test from its sources (a #define of a *DATABASE* or *STORE* name, a build_path() segment after "tests_yuneta" or after path_root, the "database" key of a C_TRANGER/C_NODE/C_TREEDB kw, the domain of register_yuneta_environment(), a literal /tmp/<path>) and the properties from ctest itself, so it needs a configured and built build/. Two tests that name one directory (or one under the other) collide unless ctest keeps them apart: a shared RESOURCE_LOCK, RUN_SERIAL on one of them, a DEPENDS between them, or one the FIXTURES_SETUP of what the other FIXTURES_REQUIRED:

python3 scripts/check_test_databases.py          # exit 1 on a collision, or a test not read
python3 scripts/check_test_databases.py --list   # every directory and its tests

An illustration (if a third test names tr_msg without the lock, it gets this report. In fact, test_pkey2_empty uses tr_msg2db_test):

~/tests_yuneta/tr_msg COLLISION
    tr_msg/test_tr_msg1: tests/c/tr_msg/test_tr_msg1.c  [tr_msg]
    tr_msg/test_tr_msg2: tests/c/tr_msg/test_tr_msg2.c  [tr_msg]
    tr_msg2db/test_pkey2_empty: tests/c/tr_msg2db/test_pkey2_empty.c
    can run at once: tr_msg/test_tr_msg1 <-> tr_msg2db/test_pkey2_empty

Tests that run the same executable with other arguments (the groups of test_c_treedb_literal_wins) are not compared, and a directory built at run time from a format is not seen.

scripts/check_test_links.py fails when a test’s CMakeLists.txt names an SDK archive bare (libtimeranger2.a instead of ${LIB_DEST_DIR}/libtimeranger2.a or ${YUNETAS_KERNEL_LIBS}): a bare name is a -l search, not a dependency of the link, and the test keeps the old library when that one changes.

ctest -j also needs the inotify limits of 99-yuneta-core.conf (installed by the package). With the Linux defaults (128 instances per user), several treedb tests at once fail with “inotify_init1() FAILED”. Two checkouts on one machine share ~/tests_yuneta, so do not run two suites at once.

Asserting on the logs

Most tests here assert on what was LOGGED, not on a returned value: they whitelist the log messages the run is allowed to emit, and anything else fails the test. Two functions do it, and choosing between them is a real decision.

set_expected_results() is strict FIFO. Every captured log must match the HEAD of the list, so the list states the exact messages, in the exact order, the exact number of times. This is what nearly every test wants and what you use by default.

json_t *errors_list = json_pack("[{s:s}, {s:s}, {s:s}]",
    "msg", "Starting yuno",
    "msg", "Playing yuno",
    "msg", "Yuno stopped, gobj end"
);
set_expected_results(
    APP_NAME,     // test name
    errors_list,  // the messages the run may emit, in order
    NULL,         // expected json, NULL to check only the logs
    NULL,         // ignore_keys
    1             // verbose
);
...
result += test_json(NULL);   // NULL: check only the logs

An entry matches the keys it names, and only those: msgset, peername or any other field of the log can be asked for beside msg. The priority is one more (since SDK 7.27.0): the captured log carries "__priority__" ("ERROR", "WARNING", "INFO"...), which the logged json does not have. Ask for it where the severity IS the behavior under test: a peer’s mistake that must stay a WARNING, or a broken contract that must stay an ERROR. The same msg at another priority then fails the test. An entry that does not name it matches any priority, as before.

json_t *errors_list = json_pack("[{s:s, s:s}, {s:s, s:s}]",
    "msg", "Cannot link self node", "__priority__", "WARNING",  // a command's: a peer
    "msg", "Field required: 'name'", "__priority__", "ERROR"     // a C caller's
);

set_expected_results_unordered() reads the same list as a whitelist: a captured log matches ANY entry, a match does not consume the entry (so a message can repeat), every entry must still be matched at least once, and anything matching no entry fails the test. It gives up “in this order, this many times” and keeps “these things happened, and nothing else did”.

set_expected_results_unordered(APP_NAME, errors_list, NULL, NULL, 1);

Use it only when the order is not ours to decide. The case it was written for is c_tcp2/test2: two C_TCP gobjs (the client and the accepted server side) log "Connected" and "Disconnected" independently, and the driver calls set_yuno_must_die() from inside one side’s close callback, which logs "Exit to die" synchronously and shuts the yuno down. The other side’s last log is swallowed, or is not, depending on whether the two close completions land in the same io_uring batch. The count moved, not only the order, so no ordered list can be right, and the test failed on a busy box naming a message that was correct.

That is the bar. A test whose sequence is only wrong must have its sequence fixed, not its assertion relaxed.

Event loop (yev_loop)

Low-level tests for the io_uring event loop, without the GObj layer.

BinaryDescription
test_yevent_listen1–4Server creates a listen socket and accepts one client connection.
test_yevent_connect1–2Client connects to a listening server, then makes sure that the connection succeeds.
test_yevent_traffic1–6Client ↔ server message echo over plain TCP (multiple variants).
test_yevent_udp_traffic1UDP message echo.
test_yevent_traffic_secure1TLS-encrypted TCP message echo.
test_yevent_timer_once1–2One-shot timer expiration.
test_yevent_timer_periodic1Periodic (recurring) timer.
test_yevent_sq_fullA full submission queue: the loop flushes it and asks again. When the kernel takes nothing, the submission is kept for the next cycle (a start answers 0, a stop of a kept start gets STOPPED with -ECANCELED).
test_yevent_sq_nomemNo memory to keep a submission (largest block 100 000 bytes): the 1025th write start answers -1 with “No memory to keep a submission: event NOT started”, the 1024 kept writes complete, and the memory tracking is whole at the end.
test_yevent_sq_retryio_uring_submit() failing on demand: an entry left in the queue is submitted again at the next cycle and the timer fires. A stop takes back a read still in the queue, so a new timer with the same fd number fires. 100 cycles without the kernel taking anything log one ERROR, and one INFO when it takes them again.
test_yevent_stop_in_flightA stop of a read, a write to a full socket and a recvmsg the kernel has: the event keeps its gbuffer until the completion of the cancel, and the callback gets it STOPPED, -ECANCELED, without gbuffer.
test_yevent_udp_ipv6IPv6 peers on [::1]: a UDP listener on udp://[::1]:0, a datagram received from an IPv6 client and sent back to it (the peer address in the gbuffer with its length), and a TCP connect to tcp://[::1]. Skipped without IPv6 on the host.
test_yevent_udp_zerocopyA zero-copy UDP send gives two completions: the callback is called once, an event destroyed in its callback lives until its notification, and a failed send (-EMSGSIZE) is STOPPED with no warning.
test_yevent_loop_end_drainA loop ended with destroyed events whose completions have not come: yev_loop_destroy() frees each of them, and one whose completion never comes after 1 second, with an ERROR. A zero-copy send waiting for its notification is waited for 5 seconds and then NOT freed, with a WARNING: the kernel can still read its gbuffer.
test_yevent_connect_src_urlA connect bound to a local address (src_url): 127.0.0.1:<port>, [::1]:<port> and tcp://127.0.0.1:<port>. The listener sees the peer at that port, and a bad src_url ([::1:5000) gives no socket and an error. A destination of two families (localhost) with a src_url of the second one skips the first address and connects to the second.
test_yevent_stop_nomemA stop without memory for its cancel answers -1 and gives up nothing: the timer keeps its fd, the read its gbuffer, and the read then completes with its data. A loop destroyed with no room for the cancel of its dying events says so before the final error.
test_yevent_kept_after_postA posted action (gobj_post_event()) stops a timer whose start is kept: the STOPPED reaches the callback at the next cycle, not at the timeout of the run.
test_yevent_close_fd_keptThe socket of a connect event is closed (a stop, then a destroy) while a write of another event on it is still untaken (in the submission queue, then kept): the write is taken back and its callback gets STOPPED, -ECANCELED. A new socketpair that takes the number reads nothing.
test_yevent_stop_stale_sqeA ring of 4 entries, wrapped: a timer armed 4 times and stopped RUNNING gets exactly one STOPPED callback (destroyed in it, no completion after). A connect stopped RUNNING on the fd number whose old slots name a READ event leaves that read untouched. No take-back is warned, memory is clean. The loop clears the fd and the event of every ring entry it hands out, and a stop prepares its cancel before it closes the fd.
test_static_resolv_spoofThe static resolver (yuneta_getaddrinfo()) accepts a DNS answer only from the nameserver it asked: a forged answer from another source port is dropped by the kernel (the UDP socket is connected).
test_static_resolv_numericThe static resolver sends no numeric host to DNS: an address of the family asked for is answered directly, one of the other family ("::1" in AF_INET) answers EAI_ADDRFAMILY, and AI_NUMERICHOST with a name answers EAI_NONAME. As in glibc, "127.0.0.1" in AF_INET6 with AI_V4MAPPED answers ::ffff:127.0.0.1 and "::ffff:1.2.3.4" in AF_INET answers 1.2.3.4 (both EAI_ADDRFAMILY up to 7.25.20). The IPv4 forms glibc takes as numeric ("127.1", "10.1.2", "0x7f.1", "0177.0.0.1", "2130706433") are answered as glibc answers them, in every family and with AI_NUMERICHOST too (up to 7.25.20 they went to DNS). But "1.2.3.4x", "256.1", "08.1" or a blank around it stay names. Each case must also answer fast.
test_gobj_post_eventgobj_post_event(): an event posted is not delivered at once, it arrives on the next cycle of the loop, in order, each with its own kw.
test_gobj_dispatchA gobj destroyed while an event is dispatched to it or published by it. A subscriber that destroys the PARENT of its publisher is an ERROR (“Destroying a gobj while its tree is publishing”), the destroy is done, the publication stops (the next subscriber hears nothing) and the freed publisher is not read. With the machine trace on, a gobj that destroys itself in its own action, one that publishes its last event and then destroys itself, and one destroyed by its host in its EV_STOPPED, are no error. A subscriber of EV_STATE_CHANGED that destroys the gobj whose FSM is moving it: the action of the event is not run (an ERROR). A gobj that ends itself in its own mt_start, mt_stop or mt_play: the walks of gobj_start_tree() / gobj_stop_tree() do not go into it, no ERROR. A publisher that destroys itself in an action a subscriber sends it, and a gobj whose action sends to a peer that sends back the event that destroys it, are an ERROR (“one of its actions is still running” for the second). Up to 7.26.9 the first case was a SegFault, and under ASan the others read or wrote freed memory. A RUNNING gobj destroyed whose mt_stop publishes EV_STOPPED at once, and whose host destroys it there: the outer gobj_destroy() returns, the gobj freed once (up to 7.26.9 it went on with the freed gobj: under ASan a use of freed memory at its obflag, plain a “Deleting item with DIFFERENT dl_list_t” and an abort). Walks of the tree whose callback destroys more than the gobj it was given: the stop of a child destroys its next sibling (in gobj_stop_tree() and in gobj_stop_children()), the stop of a child destroys the root of the walk (a host that ends itself in its child’s EV_STOPPED), and the destroy of a running child, inside the destroy of its parent, destroys the next child: each walk goes on from what is left (up to 7.26.9 each read the freed next gobj, under ASan). An action of a gobj that began INSIDE its own EV_STOPPED (its host sends it an event from there) and is still running when the gobj is destroyed further in: an ERROR (“one of its actions is still running”): only the code the farewell runs inside of is excused. A gobj whose own action walks its parent’s children and is destroyed by that walk (its callback, gobj_destroy_children(), gobj_destroy_named_children() with the gobj’s own name): no ERROR, the watch frames of the walk are not the code that destroys. A walk of gobj_start_tree(), gobj_start_children(), gobj_stop_tree() or gobj_stop_children() whose child destroys itself AND the next one: the walk goes on from the child after them, which is started or stopped. With a child before them whose start is refused (a required attribute empty), one that stops itself in its mt_start and one that starts itself again in its mt_stop: none is started or stopped twice (the refusal is logged once). A host that renews its transport in the transport’s EV_STOPPED (destroys the pair, creates and starts a new one): gobj_stop_children() and gobj_stop_tree() stop the children they had and end, and the new pair stays running (the first fix of 7.27.0 started again from the first child, and never ended). A gobj_walk_gobj_children() / gobj_walk_gobj_children_tree() in the six walk types whose callback destroys the child AND its next one: each child left is given once. gobj_stop_children() of 8000 children and 4000 such pairs takes about four times what 2000 and 1000 take, not sixteen (the first fix of 7.27.0 was quadratic). gobj_destroy_named_children() with a NULL or empty name fails with an ERROR (up to 7.26.9 a NULL crashed). gobj_destroy_children() of a live host that renews its transport in its EV_STOPPED destroys the children it had and leaves the new pair. For a gobj being destroyed whose running child creates a sibling in its mt_stop, the create is refused with an ERROR (“Cannot create a child of a gobj that is being destroyed”) and the destroy ends (the first fix of 7.27.0 took the new children too, and never ended: the test has a 60 s limit). A play whose mt_play destroys its gobj fails, and so does a play whose implicit start is refused (a required attribute empty), which leaves the gobj not playing. WALK_BYLEVEL in both directions over a tree of leaves and branches gives each child once, in its order, and not a sibling created during the walk with a child of its own, nor that child: the pass over the children’s children steps over a leaf without the watch, and must end there as the watch does.
test_c_pty_flow_controlA C_PTY running bash prints seq 1 200000. Paused inside its EV_TTY_DATA: nothing in 500 ms. Paused, resumed with a read in flight and paused again: at most that read. Resumed: every line in order. Stopped while paused: EV_TTY_CLOSE and EV_STOPPED at once. Created paused: nothing until resumed (7.30.26: no rx_paused, and a non-volatile C_PTY published EV_STOPPED undeclared).

Source: tests/c/yev_loop/yev_events/, tests/c/yev_loop/yev_events_tls/, tests/c/yev_loop/static_resolv/, tests/c/gobj_post_event/, tests/c/gobj_dispatch/

Timers

BinaryDescription
test_c_timerC_TIMER GClass: periodic timeout operations.
test_c_timer0C_TIMER0 GClass: basic (low-level) timer.
test_c_counterC_COUNTER: one that expires (its own C_TIMER) publishes its final count once, with the count so far, on the next turn, and is gone. One expired from outside does not count what arrives after. One that reaches its count publishes inside the last count. One expired from outside and STOPPED by its owner before its final count is delivered publishes none, and the volatile counter is gone. One that is not volatile, expired from outside, stopped and STARTED again goes on counting in ST_IDLE (the expiration of the run before is dropped). Neither says “Publish event WITHOUT subscribers” (a stopped counter has no subscribers left) nor “Event NOT DEFINED in state”. Up to 7.26.9 the expiration freed the timer under its own publication (under ASan, a read of freed memory in C_TIMER and in the kernel).

Source: tests/c/c_timer/, tests/c/c_timer0/, tests/c/c_counter/

TCP networking

Plain and TLS TCP through the full GObj protocol stack.

BinaryDescription
c_tcp/test1–4Plain TCP: connect, disconnect, echo, and rapid multi-message burst.
c_tcp/test5A write that does not start (an empty gbuffer): C_TCP drops the connection, frees the write, and a stop reaches ST_STOPPED. An empty write gets its EV_TX_READY a turn later, connected and, for a client that connects on demand (timeout_inactivity), while still disconnected (no connect).
c_tcp/test6The stop of a client already disconnected (nobody listens): EV_STOPPED once, ST_STOPPED, and a start after it works (twice).
c_tcp/test8A C_IOGATE with send_type 1 sends one gbuffer message to its 3 channels (C_PROT_TCP4H): every raw peer gets the whole frame. Up to 7.25.20 the first channel read the shared gbuffer out and the others sent an empty frame.
c_tcp/test7Data sent to a C_TCP while its drop waits in ST_WAIT_STOPPED: dropped with no error, and ONE warning with dropped_msgs and dropped_bytes when the close ends. A second C_TCP stopped and destroyed while it still waits says its drop at the destroy. The disconnect_cause of a drop (Local dropping) and of an inactivity close (Inactivity timeout) are what the owner reads at EV_DISCONNECTED and after the close, not the cancel of the read.
c_tcp/test9A C_TCP client and a clisrv, both checked connected, are each sent a write, stopped and DESTROYED in one turn, before EV_STOPPED (the way every yuno ends): the destroy cancels the write in flight and nothing of the gobj is used after, and the clisrv’s socket is closed as the stop closes it. With data its peer sent still unread, the peer must read the end of the connection (a FIN), not a reset. Up to 7.29.3 the completion of the write ran on the freed gobj (a SegFault in a plain build), and the clisrv’s socket was left open. In the fixes after 7.29.3 it was closed with no shutdown(SHUT_WR), and the peer got a RST. Two writes queued behind the one in flight are dropped by the stop with ONE INFO per stop (“tcp data queued at a local stop, dropped”, dropped_msgs 2, dropped_bytes 54, dropped_tls_bytes 0 on plain TCP), and txMsgsDroppedAtStop is 2 (7.30.26: in silence). The client is started again and stopped again (the count adds both: 4), and stats __reset__ puts it back to 0.
c_tcp/test10A client dropped with a write in flight keeps its socket open until the write ends: a file opened right after the drop gets nothing, the peer gets whole chunks, and the socket closes at EV_DISCONNECTED. Up to 7.30.17 the drop closed the socket at once, and a short completion re-sent its rest with the closed number.
c_tcp/test11A TLS client’s handshake deadline holds against its timeout_inactivity (a peer dripping a byte each 200 ms is dropped at the deadline), and the deadline warning is one per 10 s for the yuno: four deadlines give one warning, "suppressed": 0. Three in the next window give the next one, "suppressed": 3, and the two others of that window are said at the end of the yuno, “TLS handshakes not ended in time, connections dropped, not said in their window”, "suppressed": 2 (up to 7.30.18 nobody said them).
c_tcp/test12A TLS client and a TLS clisrv of one yuno. The client is sent a message while the Finished of its TLS 1.3 handshake is in flight (its record waits in the queue of the TLS output) and stopped in the next turn: ONE INFO “tcp data queued at a local stop, dropped” with dropped_msgs 0 and dropped_tls_bytes more than the text, and txMsgsDroppedAtStop 0 (a TLS record is not a message of the host). Up to 7.30.26 the TLS output went in silence.
c_tcp/test13A clear and a TLS client of the test, each with a clisrv of the test: 5 messages of 1000 bytes in one turn give at once txMsgs 1, cur_tx_queue 4, cur_tx_bytes 5000, and at the client’s EV_TX_READY 5, 0, 0. Three more give cur_tx_bytes 3000, and it is 0 at the EV_DISCONNECTED of the dropped clear client and right after the stop of the TLS one. Up to 7.30.26 the TLS client’s txMsgs stayed 0, and there was no cur_tx_bytes.
c_tcp2/test1–4Same scenarios using the newer C_TCP_S method (no child_tree_filter).
c_tcps/test1–4TLS TCP: connect, disconnect, echo, and multi-message burst.
c_tcps/test6A TLS server (child_tree_filter) stopped and started again in the same turn while a connection of it lives, and its certificates reloaded (reload-certs): the echo of a message on the old connection returns on it, and, the old one closed, the echo of one on a new connection returns on the new one. The certificates are copies: a restart with them unchanged reloads nothing, and one after the copy is touched reloads it. Freed memory is poisoned, so a use of a freed ytls fails every run (up to 7.25.20 it did: the restart freed the ytls of the live connection).
c_tcps/test7A connection accepted into a channel with no C_TCP of its own (C_CHANNEL -> C_WEBSOCKET) gets a volatile C_TCP, destroyed by the websocket when it publishes EV_STOPPED. A client that sends a request that is not HTTP is dropped from inside that C_TCP’s own EV_RX_DATA, over TLS and in clear: both clients are disconnected and no C_TCP is left. Freed memory is poisoned (up to 7.25.21 a SegFault on both: the C_TCP used itself after the publish). test7_mbedtls runs it on mbedTLS when both backends are compiled in.
c_tcps/test9A TLS client whose ssl_trusted_certificate does not exist fails its connection with one ERROR, and the yuno goes on (an atexit() turns an exit into a failure). Up to 7.30.3 the OpenSSL backend exited the yuno with code 0 there, which ctest took for a pass, but mbedTLS only refused the connection.
c_tcps/test10 (+ _mbedtls)A TLS server with ssl_verify_mode request takes a client’s self-signed certificate as it comes: its peer_cert has verified false and the spki_sha256 of the client’s key, and no “did NOT verify” warning is logged. A client without a certificate is let in with no peer_cert. Its "request" server also has a CA that signs the client’s certificate: verified must be false on both backends, because "request" does not use that CA.
c_tcps/test11 (+ _mbedtls)C_TCP’s timeout_tls_handshake: a wss server drops two raw clients that never complete a handshake at the deadline (the three deadlines of the test write ONE warning: one per 10 s for the yuno). A TLS server drops non-TLS bytes at once. A wss client keeps its session past the deadline. A wss client against a silent plain server drops at the deadline and connects again. The two deadlines after its warning are said at the end of the yuno (“... not said in their window”, "suppressed": 2).
c_tcps/test12C_TCP’s inactivity timer does not fire after a local drop that waits with a write in flight (timeout_stop_tx 0).
c_tcps/test13C_TCP’s timeout_stop_tx on a client: stopped with 8 MB in flight to a listener that never accepts, it reaches ST_STOPPED within 8 s, with ONE warning.
c_tcps/test14A TLS C_TCP_S without its certificate does not listen and the yuno goes on. It listens when the certificate is there, with no restart. Three servers share one pool of channels, as the agent’s do: plain_port takes a peer, tls_port refuses a connect (listening and tls_ready false), reload-certs answers -1. A try of its timer that finds the files unchanged says nothing. Once the files are copied, reload-certs of tls_port2 answers 0 and it listens at once, tls_port listens at its next try, and a TLS client completes its handshake. Up to 7.30.17 ytls exited the yuno with code 0 at the start. test14_mbedtls runs it on mbedTLS when both backends are built. Its three servers set exitOnError 0 (the default exits).
ytls/test_server_init_not_fatalytls_init() of a server is never fatal: a certificate that does not exist, a key of another certificate (OpenSSL), a trusted certificate that does not exist, and an unknown library (server and client) answer NULL, and the process goes on. A good pair gives a context. On every backend compiled in. Up to 7.30.17 each of them exited the process with code 0. A key of another certificate and a server without ssl_certificate give NULL on every backend built, and a reload of a new certificate with the old key answers -1 and keeps the context (up to 7.30.18 mbedTLS took all three).
c_tcps2/test1–4TLS TCP with the newer method.
c_tcp_inactivity/test1–4C_TCP’s timeout_inactivity.
c_tcp_inactivity/test5C_TCP with timeout_between_connections 0 retries at a 1000 ms floor, with one warning (up to 7.26.9 it never reconnected).
test_c_tcp_s_ip_listsC_TCP_S at accept: a peer in denied_ips is refused (with or without only_allowed_ips, and the deny wins over allowed_ips), with only_allowed_ips a peer not in allowed_ips is refused, loopback is exempt from both lists. A refusal is logged on the transition (the first one of a cause, then one a minute at most) and counted in the stat refusedConnxs: a denied peer that connects 5 times more writes no line, and refusedConnxs is 8 (up to 7.25.4 there was no stat, and each refusal wrote a line). A full server (3 channels taken) refuses 3 more with one warning, counted in noChannelConnxs (up to 7.25.21 an ERROR each, counted nowhere). It checks the list key of each peername form (1.2.3.4:80, [2001:db8::1]:443, [::ffff:1.2.3.4]:80). The add-/remove- ip commands store the form a peer is looked up by (2001:DB8::1 as 2001:db8::1, ::ffff:203.0.113.7 as 203.0.113.7, fe80::2%lo as fe80::2%1) and refuse what is not an ip. A link-local entry without its interface denies on every interface and is refused in allowed_ips. Entries stored as typed by 7.25.4 are renamed or dropped at load, with a warning, and saved.
test_c_qiogate_statsA C_MQIOGATE (broadcast) over two C_QIOGATE whose peer does not listen: 5 messages sent, its stats say msgs_in_queue 5 and pending_acks 0 for each child, and so do the children’s attributes (up to 7.25.21 only the gate’s own mt_stats said them, which a C_MQIOGATE never asks). Then a gate with min_free_disk_percentage 101 refuses 3 messages (-1 to the sender, dropped_msgs 3, one ERROR), the other gate takes them, and with 0 it accepts messages again (up to 7.28.3 a message that the queue failed to save aborted the yuno). A gate whose queue cannot be opened (its path under a regular file) refuses messages and counts them, with ONE ERROR, then opens the queue at its try and takes the next (up to 7.30.17 “Subprocess aborted” at the first message). queue_mark_pending and queue_mark_notpending answer -1 on a queue that is not open, and on the open queue mark it and leave it working (up to 7.30.17 a SIGSEGV). A message with a gbuffer leaves the gbuffer with only the sender’s reference (up to 7.30.17 refcount 2 and “system memory not free”). output-q3 queues with_metadata: a message’s __temp__ is not queued, its other metadata is (up to 7.30.26 the queue kept it and sent it to the peer).
test_c_iogate_channelA C_IOGATE with no channel: a message whose __temp__ is not a dict (four events) gets the channel it came in by, with one ERROR each, “temp of a message is not a dict, replaced” (up to 7.30.26 two ERRORs per message and the other value reached the subscriber as the channel). A __temp__ that is a string or an integer is replaced too, and a dict without the channel keeps its keys and gets it. 2500 sends with no channel give three ERRORs “No channel FOUND to send”, repeated 0, 999, 999 (up to 7.30.26 one ERROR per send), and the end of each run (a send that finds a channel, the gate’s stop) one INFO “Sends with no channel ended” with without_channel and not_said, after which the count starts again. A send to all goes through the same brake, and a send to all that finds an open channel ends the run. A drop of an unknown channel before an outage counts in a run of its own (the outage’s first ERROR is still said, and its end counts 2500 sends. The drops’ run ends at the stop, “Drops of a channel not found ended”). txMsgsNoChannel counts every send with no channel, and stats __reset__ zeroes it.
test_c_qiogate_alertThe queue-size alerts of C_QIOGATE (alert_queue_size 10), with the acks made by the test: two gates alert at 10 and both log that there is no emailsender (the email limit is each gate’s), one alert at 20, none while the queue swings 19 <-> 20 fifty times (up to 7.30.3, fifty), one at 20 after it fell to 14, and one at 10 after it fell to 4.
test_c_tcp_s_statsThe connection stats of C_TCP_S: one server accepts with child_tree_filter, the other with the new method (each channel’s C_TCP accepts by itself). Raw peers connect, close and connect again: connxs is 2, 1, 2 and tconnxs 2, 2, 3 on both, read as attributes and in the stats answer. Two more servers share one pool of channels and one port on two hosts (127.0.0.1:7816, 127.0.0.2:7816): each counts only its own connections, also after one is stopped and started again in the same turn (it listens again when its stop ends). A new-method server stopped alone and started again in the same turn: its clisrvs go and come with it, and it accepts again. A server whose only clisrv is destroyed while its stop waits for it listens when started. A server destroyed leaves no clisrv naming it, and one made in its place stops and starts again. A gate of the new method stopped and started again with a channel added: the new clisrv is named clisrv-3, and the clisrvs started again leak nothing. Up to 7.25.20 both read 0 always (SDF_STATS without mt_reading, a connxs never decremented, and no count at all with the new method), and a clisrv of the new method started again overwrote its first accept event.
test_c_tcp_s_busy_channelAn accept of C_TCP_S with child_tree_filter never takes a channel whose C_TCP is running: two servers, one TLS and one plain, share a channel, and a peer stays in the handshake while another connects. Up to 7.30.1 that ended the yuno. It needs /yuneta/agent/certs/localhost.{crt,key}: without them tls_port does not listen and the yuno goes on: the test fails with “TEST: tls_port is not listening”. A third server, nokw_port (port 7880, gate __nokw__), has a child_tree_filter with no "kw": a peer is accepted there, and the memory audit at the end fails the test if the accept leaks (up to 7.30.14 it leaked a json each time).
test_c_tcp_s_addr_in_useA C_TCP_S whose address is in use at its start, held by a raw listening socket: one bind() FAILED (a WARNING), “Address in use: listening again”, and when the port is released the retry listens (“Listening: its address in use was released”, ST_IDLE) and accepts a client. Held longer than listen_retry_msec (1 ms), the retry is refused too and the listen fails with ONE ERROR, “Listen failed: not listening, trying again” (errno 98), and the yuno goes on: a first try refused in silence, the port released, the second try listens (“Listening again after a failed listen”) and accepts a client. With listen_retry_msec 0 it fails at once, and its stop takes the try back. An empty url, one of port 0 and one with no schema are each an ERROR with no try, and the good url written listens at once. The yuno’s tick is 50 ms and the test’s C_TIMER subscribes to it before the server’s, so the count of refused binds is exact. Up to 7.27.3 the first refusal failed the start: the yuno exited, and its watcher launched it again 2 s later. Up to 7.30.17 a port held past listen_retry_msec exited the yuno (exitOnError). Its degrading gobjs set exitOnError 0. test_exit_on_error checks the defaults: each case is a yuno in a child process, and the parent reads its exit code and line. The results: C_TCP_S port held 255, TLS without certificate 0, exitOnError 7 gives 7, C_UDP_S port held 0, C_QIOGATE blocked queue 255 (in 7.30.18 no yuno exited).

Source: tests/c/c_tcp/, tests/c/c_tcp2/, tests/c/c_tcps/, tests/c/c_tcps2/, tests/c/c_tcp_inactivity/, tests/c/c_tcp_s_ip_lists/, tests/c/c_tcp_s_stats/, tests/c/c_tcp_s_busy_channel/, tests/c/c_tcp_s_addr_in_use/, tests/c/c_qiogate_stats/, tests/c/c_iogate_channel/

UDP networking

BinaryDescription
test_c_udp_s_txC_UDP_S sends every datagram of its queue, in order, and drops one it cannot send, leaks nothing, and goes on listening. A datagram it cannot send has no peer address (an error), is refused by the kernel, or has a peer port 0 (a warning with the peer and EINVAL). Then it is sent a datagram, stopped and DESTROYED in one turn: no error, and the send in flight is canceled (up to 7.29.3 its completion ran on the freed gobj, which was a SegFault, and an ERROR said “GObj NOT STOPPED. UV handler ACTIVE!”).
test_c_udp_txC_UDP, the UDP client (not registered by the SDK: the test registers it), sends every datagram of its queue, in order, publishes EV_TX_READY once when the queue is done and one turn after an empty send (never inside the send), counts 3 datagrams and 11 bytes, and its stop ends in ST_STOPPED with EV_STOPPED. A send, a stop, a send while the stop waits (dropped, ONE warning) and a start in one turn: the start is taken when the stop ends, with no EV_STOPPED, and the datagram in flight goes. A second C_UDP destroyed with its send in flight frees nothing in use, and logs no error. Against 7.29.3 it did not build (c_udp.h declared another name) nor register, and only the first datagram was sent.
test_c_udp_tx_refusedA C_UDP sends 50 datagrams to a port of the loopback where nobody listens: its read fails with ECONNREFUSED while a send is in flight, and it stops by itself, ending in ST_STOPPED, NOT running, with ONE EV_STOPPED. A gobj_start() then works. Then 25 times a send, a stop (checked in ST_WAIT_STOPPED) and a start in one turn: the C_UDP must stay running in ST_IDLE, with no EV_STOPPED. Then 25 times a send, a stop and a start made at its EV_STOPPED, when the completion of the cancel of the read can still be to come (the send in flight is what makes this phase red on its own with the read kept across starts): it must run in ST_IDLE, with one EV_STOPPED per stop. In the fixes after 7.29.3 it stayed in ST_WAIT_STOPPED for ever, and the start said “GObj ALREADY RUNNING”. Also, the start (in the stop, or at its EV_STOPPED) armed the read again with the completion of its cancel still to come, which failed it: the C_UDP stopped by itself at every restart.
test_c_udp_s_restartC_UDP_S stopped with a send in flight ends the stop with EV_STOPPED. Started again after a file took the number of its old socket, it reads and sends again. Stopped and started in the same turn (its read still canceling), it reads again.
test_c_udp_s_rxThe pieces of two long frames of two peers, interleaved, come out whole from C_GSS_UDP_S: every datagram is labeled with its peer. The yuno’s ip lists: with only_allowed_ips a peer that is not allowed is dropped with a warning, a peer in denied_ips too (denied wins over allowed), an allowed one and the loopback are heard. A refused peer that insists is said once per cause, not per datagram, and the stat rxRefusedMsgs counts every drop. What a peer holds in a C_GSS_UDP_S is capped: a peer beyond max_channels is dropped (said once), a frame with no NUL within max_frame_size is delivered cut, the bytes of all the unfinished frames stop at max_pending_bytes (the frame of the peer that passes it is dropped), and the memory grows by far less than 1 MB per source port. A host answers the peers of the frames with EV_SEND_MESSAGE: by the label of a frame (no address), by its address (no label), and a send with neither is refused with an ERROR.
test_c_udp_s_self_stopC_UDP_S whose next read cannot be started (an rx_buffer_size of 0, the host answering in the gbuffer it got) says it with an ERROR and stops by itself. With the answer in flight, the stop still ends in ST_STOPPED with EV_STOPPED. A udps:// url is refused at the start (an ERROR, the start fails, nothing listens). A port held by another socket: ONE ERROR, “Listen failed: not listening, trying again”, a silent failed try, and once the port is released the second try listens. An empty url is refused and the yuno goes on. A read that cannot be started is ONE ERROR, “Cannot start the read of the UDP server: not listening, trying again”, and “UDP listening ...” is said once, when the server listens. An atexit() guard makes an exit(0) fail the test: up to 7.30.17 the yuno exited with code 0 at the udps:// case.
test_c_gss_udp_s_self_stopC_GSS_UDP_S when its C_UDP_S stops by itself (the host keeps a datagram and the next read, of 0 bytes, cannot start): one warning. A send is refused with one warning, also in the window where the C_UDP_S is still stopping (ST_WAIT_STOPPED, a send in flight). The C_UDP_S is started again after timeout_base, and a datagram is heard and an answer sent after it. A second self-stop within a minute doubles the backoff. A C_UDP_S stopped from outside is not started again. A timeout_base of 0 is refused with a warning and the default used. Up to 7.25.20 the service stayed deaf and every send logged “Event NOT DEFINED in state”. A port held while its C_UDP_S restarts (with exitOnError 0): no “UDP server started again” until it listens. Sends refused while the C_UDP_S is down and while its listen fails are said with the first send taken once it listens (“UDP server listening again, sends refused while it was not”, tx_dropped 2).
test_c_udp_s_echoA host that answers IN the gbuffer of each C_UDP_S EV_RX_DATA (its kw sent back as EV_TX_DATA): with five sends waiting in the queue and two peers talking in the same turn, and with three datagrams read while each answer is in flight, every answer reaches its own sender, whole, with no error. Up to 7.25.4 the gbuffer was cleared and read into again: an answer was sent empty (dropped) or with the bytes and the peer of another datagram.

Source: tests/c/c_udp_s_tx/, tests/c/c_udp_s_restart/, tests/c/c_udp_s_self_stop/, tests/c/c_gss_udp_s_self_stop/, tests/c/c_udp_s_rx/, tests/c/c_udp_s_echo/

TLS certificate hot-reload

Protects the cert-reload feature. The tests make sure that ytls_reload_certificates() swaps certificates atomically without dropping live sessions and rolls back cleanly on invalid material.

BinaryDescription
test_cert_reloadSwap cert A → B and make sure that view-cert shows the new subject and not_after. Then feed an invalid cert and make sure that the previous context stays intact (rollback).
test_cert_infoytls_get_cert_info() edge cases: short / long validity, self-signed invariant, serial shape, client-side NULL, already-expired cert.
test_cert_reload_mem1000 reloads without any live session and asserts get_cur_system_memory() == 0 (leak gate, run under valgrind for exhaustive checking).
test_yevent_reload_liveOne reload while a TCP session is live. The session keeps working end-to-end.
test_yevent_reload_stress50 reloads with a live session, one echo message per iteration.
test_handshake_reject_openssl, test_handshake_reject_mbedtlsA server-side ytls that receives an HTTP request on its TLS port fails the handshake cleanly, on each backend: no crash, an error that says why. Three failed handshakes in a row: the callback for each, ONE TLS handshake rejected (one per 10 s for the context, suppressed). A second TLS context fails one handshake and writes its own line (the window is per context). At the end of the first context, the two it did not write are said (“TLS handshakes rejected, not said in their window”, "suppressed": 2). Up to 7.30.19 the window was the process’s and the last count was never said. 20 CLIENT contexts that fail 2 handshakes each write one line: the clients’ window is the process’s (in 7.30.20, 40 lines). 11 s later one more reject says the rest: every reject is written or counted in a suppressed. At the end, the yuno ends with a clients’ window open: 40 more client rejects in two contexts still open, the shutdown marked (gobj_set_shutdown()), and both contexts cleaned: the 40 are written or counted, in ONE “not said in their window” line (in 7.30.21 the count of the last window was lost when the yuno ended). The test waits 11 s.
test_session_ticketsA TLS client writes after the TLS 1.3 server sent its session tickets. The server is OpenSSL’s backend (two tickets by default), and the client is each backend compiled in, so with both backends an mbedTLS client crosses to an OpenSSL server. The client’s write is read by the server, the answer reaches the client, and a second write arrives. In 7.30.20 (since 7.28.0) the mbedTLS client failed its write with “mbedtls_ssl_write() FAILED” (-31488). Without OpenSSL it is skipped.
test_tls_floor_opensslThe TLS protocol floor of the OpenSSL backend: a gate built with ssl_min_version="TLS1.0" logs the downgrade, and a peer below the floor is refused with a log.
test_peer_certMutual TLS, on every backend compiled in: a client given ssl_certificate presents it (the OpenSSL client did not load one before), and ytls_get_peer_cert_info() tells each end the cn, the DNS names and whether the chain was verified. A private CA signs the server, a client and, with another CA, a rogue client: mode "required" with a client of the CA passes and both ends read each other verified. Mode "optional" with the rogue client completes the handshake and reads it NOT verified. Mode "required" without a client cert rejects the handshake. A server without CA asks for no cert. A client cert that cannot be loaded makes ytls_init() answer NULL (not a fatal exit). Checked on mbedTLS too, with a build of both backends.
test_tls_verify_opensslPeer verification of the OpenSSL backend: a client with a CA checks the chain and the host name of the server, and a refusal is logged.

Source: tests/c/ytls/, tests/c/yev_loop/yev_events_tls/

HTTP parser (llhttp wrapper) and websocket

BinaryDescription
test_c_llhttp_parserSanity test for the vendored llhttp library and the ghttp_parser wrapper: request/response parse, keep-alive pipelining, HPE_PAUSED_UPGRADE tail bytes, EOF completion via ghttp_parser_finish(). A head of exactly max_header_size is parsed and one byte more refused (headers_refused). An empty header value is kept as "". A name that repeats is one field, its values joined with ", " (COOKIE with "; ", and SET-COOKIE never joined, the last kept). Trailers that repeat a header leave strings, with the same rules. Each header costs GHTTP_HEADER_COST against max_header_size, so 60000 empty repeated headers are refused and never hold 512 KB. A message starts clean on a keep-alive connection, and the limit of the head is per message. Invalid utf-8 gives one warning per message. message_begun is set by a status line, not by garbage. A stopped parser (ghttp_parser_stop()) parses nothing. A header of 4 MB that arrives in pieces of 4 KB costs less than 24 times one of 512 KB (linear is 8, and up to 7.29.3 it was about 100, 0.8 s for 4 MB). The trailing OWS (spaces and tabs) of every header value is dropped, whole and byte by byte. Inner spaces are kept (up to 7.30.15 it stayed in the value).
c_prot_http_cl/test2C_PROT_HTTP_CL: a form with an empty value, a number, a boolean, a NUL and a value of 6 MB goes whole and exact. The form {} goes with Content-Length: 0. A null value is not sent (one error). A response head of 70 KB, and a response with a CR alone, answer the request waiting (headers_too_large, protocol_error) with one warning, its repeated headers joined, and drop. 100 requests in one turn to a server that reads all go, and so do those to a server that reads steadily. A server that never reads is cut after timeout_tx_stall with no write ended, and a request sent while the connection drops is refused with one warning. A response refused while a write is in flight stops the parser: a request sent before the close is refused (-1, one warning), not thrown away by the transport. Garbage after a whole response, or alone, publishes nothing. Trailers that repeat a header leave strings, and a field a trailer must not carry stays out (text/plain stays so). With raw_body_data each response has its own headers, and a refused head publishes nothing. A drop with a write in flight delivers nothing more. The server has one channel, so each step starts only after the server sees the close of the step before (otherwise a fast client is refused: “no free child tree found”).
c_prot_http_sr/test1C_PROT_HTTP_SR: 600 requests in one write to an application that drops at the 3rd deliver 3, with no log (up to 7.29.3, an ERROR with a stack for each one after the drop), and the same with a write in flight. A head over max_header_size gets 431 once, a body over max_body_size 413, each with one warning and the drop timeout_linger after the answer, not before and not later if the peer keeps sending. A 431 behind a request answered later goes after its answer. A peer that reads gets 2000 pipelined answers in the order of its requests, also with requests sent while the ones before them are held, 100 answers of 100 KB too, and one that reads steadily is not dropped (alarm 120 s, and the run takes 46-48 s). Each step fails if it does not end in 60 s: a guard against a hung step only, no step is timed with it (at ctest -j8 on riscv64 step 14 took 10.5 s and step 16 about 25 s). An application that answers later is bounded by the answers it owes: 10000 requests stay within max_tx_queue plus one read, and every answer arrives in order. 30000 requests in one write log nothing. A peer that never reads is held at exactly max_tx_queue answers, and dropped after timeout_tx_stall or past max_rx_held. There are 22 steps. Server 2 runs timeout_tx_stall 4000 and a pipeline that never reads is dropped 4-6 s after the last write that moved. A last answer that fills the transport to max_tx_queue (the server’s send buffer made small, so the step does not depend on the kernel’s tcp_wmem), a refusal held behind the answers owed (one 413, not three), a refusal waiting for late answers (sent, not lost to the full-queue timer), an active peer under a short inactivity (not dropped), and an answer whose body cannot be dumped or that does not fit a gbuffer (a 500 in its place, then the next answer).

| c_websocket/test1 | C_WEBSOCKET: a closing client still receives, and late bytes are discarded. | | c_websocket/test2 | Frame size: a frame of exactly max_payload_size passes, and a 1 MB header is refused with close code 1009. | | c_websocket/test3 | The peer’s Close is logged with its code and reason. | | c_websocket/test4 | The subprotocol a server answers is the first one offered. A value that is not a token, or too long, gets none (255 bytes answered, 256 not). Every 101 carries the accept of RFC 6455 §1.3, and a key of 72 characters is answered 400. | | c_websocket/test5 | The handshake of a client: its key is 16 random bytes, new on each connection. It refuses a 101 with no accept, a wrong accept, a subprotocol, no Upgrade, Upgrade: h2c, no Connection: upgrade, or an extension (one warning each, no EV_ON_OPEN). It delivers a frame written together with the 101. | | c_websocket/test6 | A server with 2 channels and timeout_handshake 1 s: two raw clients that send one byte are closed at the timeout, and a third gets its 101. A data frame inside a fragmented message closes with one warning. | | c_websocket/test7 | A client against a raw server, one case per connection: half a 101 (closed at timeout_handshake). An RSV bit (final and not), a continuation with no message begun, a data frame inside a fragmented message, a ping that is not final, a text frame that is not UTF-8, a ping of 126 bytes (ONE warning each). A 101 with OWS around its values and a frame (delivered). | | c_websocket/test8 | A server of ONE channel: client A sends a text frame that is not final and leaves. Client B on the same channel sends a final continuation and is closed with ONE warning, delivered nothing (up to 7.30.15 it got A’s bytes). | | c_websocket/ws_accept | The SHA-1 and base64 of Sec-WebSocket-Accept, against FIPS 180 and RFC 6455 §1.3. |

Source: tests/c/c_llhttp_parser/, tests/c/c_prot_http_cl/, tests/c/c_prot_http_sr/, tests/c/c_websocket/

OAuth2 / BFF (c_auth_bff)

Self-contained yunos that spin up a mock Keycloak (signed HS256 JWTs, scriptable latency / response status / body override) alongside C_AUTH_BFF and drive /auth/login, /auth/callback, /auth/refresh, /auth/logout through happy paths and failure modes. Each test is its own binary so a crash or leak cannot mask neighbors.

BinaryDescription
test1_loginHappy-path login round-trip through the BFF.
test2_kc_401IdP returns 401. BFF must give a stable error_code, and it must not corrupt its kc_ok counter.
test3_callback/auth/callback code-for-token exchange.
test4_refreshProactive refresh-token round-trip.
test5_logoutLogout clears cookies and drives the IdP revoke endpoint.
test6_invalid_bodyMalformed JSON body → 4xx with error_code mapped for the GUI.
test7_slow_loginIdP replies slowly. The BFF makes the browser wait, and it does not time out early.
test8_queue_fullPipeline 4 POSTs + overflow: dl_list pending queue drops the overflow in order and reports the configured pending_queue_size. The 503 of the 4th is answered LAST, after the three 200s of the requests before it (answers leave in the order of their requests). Up to 7.29.3 it overtook them. Its two logs are WARNINGs, asserted with their priority (“👤BFF pending queue full”, “👤BFF request rejected” server_busy). Up to 7.30.14 both were ERRORs.
test9_browser_cancelBrowser disconnects in the middle of the round-trip. The BFF drops the stale IdP reply (responses_dropped counter) and does not forward it, and the task of the request is gone: the BFF stops it and destroys it (up to 7.26.9 it stayed, a stopped child of the BFF, one per request the browser left).
test10_kc_silenceIdP gives no answer. The idp_timeout_ms watchdog fires, answers 504 to the browser, and drains the task (idp_timeouts counter). Its ERROR (“BFF IdP outbound watchdog fired”) says its cause, and what the outbound was then: connected 1, tcp_state ST_CONNECTED.
test11_cancel_retryCancel-then-retry: state cleanup between two back-to-back logins on the same browser.
test12_stale_replyPer-task browser generation blocks cross-user token leak races.
test13_refresh_expiredExpired refresh token → mapped error, no silent kc_error.
test14_method_not_allowedNon-POST on an auth endpoint → 405.
test15_missing_bodyMissing body → 4xx with mapped error.
test16_unknown_endpointUnknown /auth/* path → 404, not 5xx.
test18_discovery_failureThe IdP’s discovery document has issuer but no token_endpoint: the BFF refuses it with a WARNING (no ERROR: it is data of a peer) and does not mark the discovery done.
test19_logout_no_cookiePOST /auth/logout with no cookie answers 200 {"success": true} at once: nothing to end, nothing is queued, the IdP is not called, and nothing is counted as an error. Up to 7.29.3 it answered 401 missing_refresh_token.
test20_discovery_timeoutThe IdP accepts the discovery GET and never answers: the discovery task ends by idp_timeout_ms, one ERROR for its cause (“OIDC discovery: IdP did not answer in time”, and no request is queued, so no answer adds its own), counted in idp_timeouts.
test21_big_tokenA browser keeps a cookie whose name and value take at most 4096 bytes. A login answered with an access_token of 4084 bytes (4096 with its name) fits, and its claims are still read (username, email). Then, on the same connection, an access_token of 4085 bytes and a refresh_token of 4084 (one byte over, with their names) are refused by their size, 500 token_too_large, the error saying the size. A refresh_token of 4083 bytes fits. An IdP success with no access_token is refused, 502 auth_unexpected_error, with one WARNING (“👤BFF IdP answer refused”: data of a peer, not an ERROR). No WARNING about a payload that cannot be read (warnings captured too). Up to 7.29.3 a token of 4 to 8 KB got a 200 with a cookie a browser drops, and a success with no access_token a 200 with empty cookies.
test22_discovery_unreachableThe IdP cannot be reached (a listener of the test with its accept queue full: the SYN is dropped). The connect watchdog (idp_connect_timeout_ms) ends the discovery with one ERROR for its cause. The login queued behind it is answered 502 Bad Gateway on the wire, auth_service_unavailable, with the ERROR of that answer. In the fixes after 7.29.3 the failure was three ERRORs. Up to 7.29.3 the 502 went out as 500 Internal Server Error.
test23_cookie_no_hostcookie_domain set: a login with a Host of the domain gets Domain= on its cookies, one with no Host gets none, with a WARNING. Up to 7.29.3 a request with no Host kept the Domain. A Host of the domain whose name is 300 bytes (longer than a host name) gets no Domain, with a WARNING whose host_len is 300, the length in the request, not the 255 bytes the BFF keeps of a Host. One of 253 bytes and a port gets it. Up to 7.29.3 a name over 253 bytes got the Domain, the Host read cut to 255 bytes with nothing said. The answers with Domain=example.com first expire the other variants of each cookie (no Domain, and Domain=<host>). The answers with no host name to write expire nothing.
test24_no_refresh_tokenTwenty requests on one connection, each answered by the mock IdP with its envelope changed. A login answered with no refresh_token gets the access_token cookie, its refresh_token cookie cleared (Max-Age=0) and no refresh_expires_in in the answer, with one WARNING for two such logins (said once per process). A refresh answered with no refresh_token gets no Set-Cookie for it (the browser keeps its own) and no refresh_expires_in. An access_token that is an integer and a refresh_token that is an object are refused, 502 auth_unexpected_error, with a WARNING naming the type and the WARNING of the 502 (“👤BFF IdP answer refused”), no ERROR. "expires_in": "450" gives Max-Age=450. The values "soon", 300.5 and a refresh_expires_in of false give the default, with a WARNING naming the value. "refresh_expires_in": 0 and "expires_in": 0 (a token with no expiry) give a cookie with no Max-Age. A logout with only an access_token cookie answers 200 and clears both cookies. One with no cookie (what a cross-site request carries) answers 200 with no Set-Cookie. One with only the access_token cookie from another Origin answers 403 origin_not_allowed, with no Set-Cookie, and one with a refresh_token cookie of 5000 bytes 400 token_too_large with both cookies cleared. A success whose body is empty, [1, 2], text that is not JSON labeled application/json, or text/html (the mock’s raw answer) is refused, 502 auth_empty_response, its error saying which, with the WARNING of the 502 and no ERROR. Up to 7.29.3 a success with no refresh_token wrote an empty refresh_token cookie over the browser’s, a lifetime of 0 wrote Max-Age=0 (the browser deleted the cookie on arrival), a logout with no refresh_token cookie answered 401 and cleared nothing, and a body that was not a JSON object logged two ERRORs, one with a stack.
test25_untrusted_inputWhat the BFF takes from others, 71 steps, the form the mock IdP got decoded after each. A login as user+1@x.com with the password p+a%41&client_id=evil&grant_type=x, a refresh with the cookie refresh_token=RT&scope=evil%41+y and a logout with refresh_token=RT&client_id=evil: the IdP gets ONE grant_type, ONE client_id, no scope, and each value as it was typed. A username of 300 bytes and a password of 600 reach it whole. A logout with a cookie (refresh_token, or only access_token), a refresh, a login, a callback and a /auth/token with an Origin that is another, none, null, the allowed one with more after it, the start of it, or the origin of a dev server (http://localhost:5173): 403 origin_not_allowed, its error naming the Origin received and allowed_origin, no IdP call, no Set-Cookie. An IdP token with ; Domain=evil.com, a CR LF, a byte over 0x7E, a DEL, a space, a ", a , or a \: 502 auth_unexpected_error, no Set-Cookie, a WARNING naming the token and the byte in hex. A refresh_token cookie of 4083 bytes is taken and one of 4084 is 400 token_too_large (refresh and logout). At /auth/token, an access_token cookie of 4084 is taken and one of 4085 refused. An IdP body that is the JSON string "": its error says a JSON string, not an empty body. An IdP body of 1 MB and 1 byte: the WARNING of the HTTP client, the WARNING of the 502 auth_unexpected_error, and the next login works. A 429 of the IdP passes on its Retry-After when it is delay-seconds of 1 to 10 digits or a real HTTP-date: IMF-fixdate, RFC 850 and asctime (both passed on as IMF-fixdate), blanks after it removed, a leap second. It does not pass on (a WARNING) soon, -5, 11 digits, 120, 60, a day 99, a time 99:99:99, a day-name that is not the date’s, a month Foo, a day-name Xyz, 29 Feb of 2026. Every answer carries Access-Control-Expose-Headers: Retry-After. An IdP that drops the connection without answering a login: 502 auth_service_unavailable, and the login is not sent again on the next connection. An IdP answer whose headers pass 64 KB, or that breaks the protocol after its status line: 502 auth_unexpected_error naming which (a logout with that answer: 200, both cookies cleared, a WARNING). Three requests in one write (a login the IdP answers 300 ms later, an unknown endpoint, a GET) are answered in their order: 200, 404, 405. A login and 17, 40 and 600 requests to an unknown endpoint in one write, each on its own connection: 16 answers wait, the 17th drops the connection with no answer, and what follows it is not read (no ERROR). Ports 18888/18889.
test26_same_originA BFF with no allowed_origin serves its own origin only, 64 steps on one connection. A login from http:// and https:// and the Host, and a refresh from it in capitals: 200. A login from a sibling (other.localhost), another port, another scheme, no Origin, null, or with no Host, and also a refresh, a logout with a refresh_token cookie and one with only the access_token cookie from the sibling: 403 origin_not_allowed, its error naming the Origin and the Host, no IdP call, no Set-Cookie. A logout with no cookie from the sibling: 200, no Set-Cookie. /auth/token from the own origin: 403 (no allowed_origin). Under allowed_redirect_uri http://localhost/app/, a callback with http://localhost/app/, .../app/cb?x=1 and .../app/x/...y: 200. A callback with http://localhost/app, .../apps/x, http://localhost.evil.com/app/, http://localhost@evil.com/app/, a .., a %2e%2E, a . segment, a backslash, a #, a space or an é: 400 redirect_uri_not_allowed, no IdP call. The same with what some server reads out of the prefix: ..%2F, %2e%2e%2f, ..;/, .;a/, %5c, %2F, %252e, %c0%ae, %00, %0a, %20, %7f, %3b, %3F, %23, and an escape badly written. %41, %21%7e, %4A%4a, %6f (a lower-case hex digit over e), ..a/b.., a;b=1 and any query pass. A login with two Host lines and the Origin of their join: 403. A login whose Host has a space or a tab, with the Origin of that Host: 403. Ports 18890/18891. Step 64: ONE Host line that is a list (localhost:18890,x): 403, no IdP call.
test27_rfc850_yearThe two-digit year of an RFC 850 Retry-After (RFC 9110 §5.6.7), both ways of the rule, at four dates of its own: the binary is linked with --wrap=gmtime_r, so the test does not rot and sees what today cannot (the next century, from 2051 on). In 2026 Saturday, 06-Nov-76 is 1976, not 2076, and 31-Oct-76 12:00:00 at 12:00:00 exactly is 2076. In 2060, 05 is 2105 and 11 is 2011. A day-name that fits no century is not passed on.
test28_logout_idp_cutA logout whose IdP does not answer clears both cookies all the same: the discovery fails (no endpoints, a broken answer, endpoints that are numbers, not URLs or too long, only the token_endpoint or only the end_session_endpoint not a URL, an end_session_endpoint too long, a connection cut twice: 502, each a WARNING asserted as one), the IdP cuts the first /logout (sent again, 200, 2 /logout), cuts two (502, 2 /logout, not a third), stays silent (504), or the queue has no room (503, two WARNINGs). An IdP that answers 503 to a logout: 200, the cookies cleared, a WARNING (up to 7.30.14 no log). Each step checks the idp_errors it adds. A login whose connection is cut is not sent again.
test29_tls_originA BFF that ends TLS itself, with no allowed_origin: Origin: http:// and the Host is 403, https:// is 200. A logout whose end_session_endpoint is not a URL is answered 500 auth_config_error, the cookies cleared: it used to get no answer at all.
test30_logout_boundA logout answers within idp_logout_timeout_ms (10000 by default), both cookies cleared, before a SPA gives up at 15 s, with an IdP mute, unreachable, or behind a discovery that does not end.
test31_no_idpA BFF with no IdP configured answers a logout with a cookie and a login at once, 500 auth_config_error each (the logout with its cookies cleared). Up to 7.30.14 both waited for ever.
test32_idp_failoverThe failover between the IdPs of issuers, with two mock IdPs whose tokens carry their iss, and a third IdP that cannot be reached. A login goes to the next IdP when its IdP answers 502, cannot connect within idp_failover_connect_ms, or fails its discovery. The next login goes straight to the next IdP while the first is down, and goes back after idp_down_retry_ms. A refresh goes to the IdP of its session and never to another one, also when that IdP answers 502. A login that reached an IdP (a 401, a connection cut after the send) is never sent to another IdP. Each step checks the /token requests at each IdP and idp_failovers. The first step is a login at the start, while the discovery of the unreachable IdP is in flight. It must have its answer within 2 s, because that discovery waits idp_failover_connect_ms (500 ms) and not idp_connect_timeout_ms (3000 ms). The second step is a login to a third BFF, with issuers [D, B], at its start. D accepts the connection and does not answer the discovery. The login must have its answer from B within 2.5 s, because that discovery waits idp_failover_response_ms (1500 ms) for its answer and not idp_timeout_ms (4000 ms).
test33_idp_tls_namesEach IdP of issuers is verified against its own name: two https issuers (localhost, 127.0.0.1) on ports where nobody listens. After a login tried both, the C_TCP of each carries the ssl_server_name of its own url and the BFF’s crypto none. In 7.31.6 the outbounds shared one crypto dict and the second IdP was verified as the first.
test34_idp_silentAn IdP that dies with the connection to it open (the keep-alive of an earlier request): a host that dies closes nothing, so the login gets no answer. The login goes to the next IdP after idp_failover_response_ms, well before idp_timeout_ms (until 7.31.13 it waited idp_timeout_ms and answered 504, after the SPA had given up). The next login goes straight to the next IdP. A refresh of a session of the silent IdP waits the whole idp_timeout_ms (504). With the first IdP down and the second slow, the login waits for the second and is not sent to the down IdP. After idp_down_retry_ms the login goes to the first IdP again. Each step checks the /token requests at each IdP, idp_failovers, and how long the answer takes.
test35_late_discoveryThe late answer of a discovery that timed out reaches no other request. A mock IdP on a keep-alive connection answers in order, its first answer after the discovery timed out. A refresh of U1 gets the tokens of U1, and the refresh of U2 from the next browser gets the tokens of U2. Up to 7.31.29 the connection stayed open, and each answer went to the request after its own: U1 got an error and U2 got the session of U1.
test36_early_hintsA 103 Early Hints of the IdP before its 200 is not the answer of the login: each of two logins gets the tokens of the 200. Up to 7.31.29 the 103 was published as the answer (auth_unexpected_error), and the 200 went to the next request.

Source: tests/c/c_auth_bff/ (includes c_mock_keycloak, test_helpers).

C_TASK, the engine under the two:

BinaryDescription
test_c_taskA job whose timeout fires (its own C_TIMER) ends the task with EV_END_TASK result -2, once, on the next turn, and the volatile task is gone. A task timed out from outside and answered right after does not process the late answer and still ends once with -2. A job answered ends the task with 0 on the next turn, not inside the answer. A job answered INSIDE its action (a local service) processes the answer once and ends with 0 once. A task answered and STOPPED by its owner before its end is delivered publishes no EV_END_TASK, and the volatile task is gone. A task that is not volatile, answered, stopped and STARTED again, and answered again, ends once, with the end of the second run (the end of the first is dropped). Up to 7.26.9 the timeout freed the timer under its own publication (under ASan, a read of freed memory in C_TIMER and in the kernel, and c_auth_bff/test10_kc_silence showed it too), and the answer inside the action freed the task under execute_action() (a SegFault). A job whose connection opens again every 100 ms against a timeout of 400 ms ends by timeout at its time (up to 7.30.14 each EV_ON_OPEN armed it again, and it lived as long as the connection kept breaking). A task started again by its owner inside EV_END_TASK runs, and ends with its own EV_END_TASK (up to 7.30.14 the end stopped the new run).

Source: tests/c/c_task/.

C_TASK_AUTHENTICATE (the OIDC password-grant task) against a mock IdP:

BinaryDescription
test1_discoveryOnly issuer is given: discovery, token and logout run in order.
test2_explicit_endpointstoken_endpoint and end_session_endpoint are given: discovery is skipped.
test4_discovery_failureA discovery body with no token_endpoint is refused: no ERROR (a WARNING, data of a peer), and EV_ON_TOKEN carries result=-1.
test5_form_encodingThe user user+1@x.com with the password p+a%41&client_id=evil&grant_type=x: the mock IdP finds ONE grant_type, ONE client_id, and the username and password as they are (expected_form), and EV_ON_TOKEN carries result=0. Up to 7.29.3 the form went unencoded (red: four ERRORs of the mock, one per key).
test6_idp_dropsThe mock IdP drops the connection of the first /token with no answer. C_TASK runs the job again when the connection opens again, and the password grant is not sent again: EV_ON_TOKEN with result=-1 and ONE WARNING (“task_authenticate: the IdP closed the connection before answering, the request is not sent again”). Before, the second /token got 200 and the result was 0.
test7_headers_too_largeThe mock IdP answers /token 200 with a header of 70 KB: the HTTP client refuses it (headers_too_large, no body), and the task answers result=-1 with ONE WARNING naming it (“task_authenticate: IdP answer refused”), after the WARNING of the HTTP client. Before, an ERROR “Oauth2 response without body”.
test8_protocol_errorThe same with HTTP/1.1 200 OK and then a header name with a space (protocol_error).
test9_runsThe task run three times in one yuno, stopped and started again after each EV_ON_TOKEN: each run retires its own HTTP client, and after the third no C_PROT_HTTP_CL and no C_TCP is left under it. Before, each run left its client stopped, a child for good (three of each).
test10_stop_in_on_tokenThe same, the task stopped inside its EV_ON_TOKEN, as ycli does: the run ends there (its C_TASK runs no logout with no client) and leaves no client.
test11_logout_idp_dropsThe mock IdP drops the connection of the first /logout: the end-session is idempotent, so it goes once more, with a WARNING: 2 /logout.
test12_logout_idp_goneThe mock IdP drops every /logout: 2 arrive, not a third, a WARNING for each. The token was already published (result 0).
test13_unknown_statusThe mock IdP answers /token with a status llhttp has no name for: result=-1. Up to 7.29.3 llhttp_status_name() aborted the process.
test14_long_bearerAn access_token of 2000 bytes: the Authorization of the /logout carries it whole. Up to 7.29.3 it was cut at 1024 bytes.
test15_endpoint_not_urlThe discovery answers a token_endpoint that is not a URL: result=-1 and ONE WARNING. Up to 7.29.3 the job ended with no EV_ON_TOKEN, and the caller waited for ever.
test16_minimal_answerAn answer of /token with only its tokens: result=0, no log. Up to 7.29.3 each key of the envelope that was missing was an ERROR with a stack.
test17_discovery_cutThe mock IdP drops every discovery: 2 go, result=-1, a WARNING for each. Up to 7.29.3 the task never ended.
test18_idp_keycloakC_IDP_KEYCLOAK against the same mock, 14 commands (a user_id of . or .. is refused): the admin token and a read go again when their connection is cut (3 times at most, then kc_unavailable), but a DELETE does not. It checks a token longer than the gclass keeps, and an expires_in that is a text, negative, too big for a date or 0. A search of 600 bytes reaches the url whole.
test19_endpoint_too_longThe discovery answers a token_endpoint of 4096 bytes: result=-1 and ONE WARNING.
test20_idp_muteThe IdP never answers the token request: EV_ON_TOKEN with result=-1 and a WARNING, twice. Up to 7.29.3 nothing came out.
test21_idp_unreachableThe IdP cannot be reached: the wait is bounded by the timeout of C_TASK and ends in EV_ON_TOKEN -1.
test22_unreachable_stopThe same, the owner stopping the gclass inside EV_ON_TOKEN.
test23_no_end_session, test24_no_token_endpointNo issuer and only one of the two endpoints: a run that cannot start publishes EV_ON_TOKEN -1.
test25_logout_200The end-session answered 200: result=0, no log (up to 7.30.14 an ERROR with the answer dumped: only a 204 was success).
test26_logout_400The end-session answered 400 invalid_grant: result=0 and ONE WARNING, no dump.
test27_logout_muteThe end-session is never answered: result=0 and ONE WARNING when the C_TASK times out (up to 7.30.14 no log).
test28_stop_while_waitingThe IdP cannot be reached and the owner stops the task while it waits to connect: no EV_ON_TOKEN and no WARNING after.
test29_token_not_url, test30_end_session_not_urlOne endpoint of the discovery is not a URL: result=-1, ONE WARNING.
test31_end_session_too_longAn end_session_endpoint of 4096 bytes: result=-1, ONE WARNING.
test32_token_not_object/token answers 200 with [1,2]: result=-1, ONE WARNING.

Source: tests/c/c_task_authenticate/.

MQTT

BinaryDescription
c_mqtt/test1Self-contained broker + client: subscribe, publish QoS 0, verify reception, disconnect.
c_mqtt/aclThe publish/subscribe ACL of the broker (EV_MQTT_ACL_CHECK). Also, list-queues queue=<name> of a queue that cannot be opened answers -1, not an empty queue. list-queues / clean-queues of a store whose topics cannot be listed answer -1 with a cause of their own.
c_mqtt/malformedMalformed MQTT packets from a peer.
c_mqtt/will_aclRaw MQTT clients against a broker with enable_acl on, each step waiting for the packet it depends on: a will to a topic the client’s group refuses is not published (a warning), but one to an allowed topic is. A retained PUBLISH with payload reaches a later subscriber. Its memory check caught the payloads C_NODE leaked (two wills and the retained one, and it needs CONFIG_DEBUG_TRACK_MEMORY). An MQTT 3.1 client gets SUBACK 0x80 for a filter of deny_subscribes (it was granted).
c_mqtt/queued_inA raw MQTT client: the incoming QoS 2 messages of a persistent session reloaded beyond max_inflight_messages wait queued, and each goes in flight when a PUBREL frees a slot, with its OWN packet id (PUBREC 3, PUBCOMP 1, PUBREC 4, PUBCOMP 2, PUBCOMP 3, PUBCOMP 4), as in mosquitto. Up to 7.25.4 the quota test was inverted and a NEW id was sent: the client’s PUBREL found nothing, and the message was never released.
c_mqtt/client_queuesAn MQTT CLIENT with persistent queues against a raw broker: a QoS 2 message received again with DUP=1 replaces the copy waiting for its PUBREL and is delivered once, a later message with the same packet id is delivered as itself, and no “QoS mismatch” is logged. An outgoing message that expires while queued gives its slot to the next queued one.
c_mqtt/out_flightA raw MQTT 5 client with Receive Maximum 2 against a broker with max_inflight_messages 0: two QoS 1 messages in flight, the others after the acks. list-queues qos=1 lists only the pending message. A PUBCOMP of a QoS 1 message is a WARNING “QoS mismatch”, a DISCONNECT 0x82, and the message stays pending.
c_mqtt/gate_protC_PROT_MQTT2 as the input of a gate (no broker, no queues, allow_anonymous), its upper level the driver, on a fake transport: a 3.1.1 CONNECT with credentials nobody checks is accepted. PUBLISH QoS 0, 1, 2 are delivered once each (a QoS 2 again with DUP before its PUBREL is not). PUBREL, PUBACK, PUBREC and PUBCOMP of ids never used are answered or said, with no crash. The SUBACK refuses a filter past max_topic_filter_length and past max_subscriptions_per_client (0x80, MQTT 5 0x8F / 0x97), grants QoS 0, replaces a filter held, and an UNSUBSCRIBE makes room. A QoS 1 message to the client goes in QoS 0. A QoS 2 past max_inflight_messages drops the client once its answers are written (the fake transport posts EV_TX_READY after each write). A PUBLISH with the property 127: ONE WARNING “Mqtt unknown property”, DISCONNECT 0x81, the drop (7.30.26: two ERRORs and a WARNING). Up to 7.30.25: CONNACK 5, nothing else. 9. A CONNECT of MQTT 5 with the property 0x01: one WARNING “Mqtt invalid property of command” whose command is CMD_CONNECT (7.30.26: a number).
c_mqtt/gate_limitsWhat a peer can do to C_PROT_MQTT2 as the input of a gate, on a fake transport, in 16 steps: a PUBLISH of MQTT 5 past message_size_limit with properties does not leak them, and two of them are said once (again on a new connection), nor a will QoS past max_qos. A SUBSCRIBE of 13 000 filters and an UNSUBSCRIBE of 20 000 get one code each, with no ERROR, and a filter repeated in one packet goes up once while each occurrence gets its code, with the options of its last occurrence. The server refuses EV_SEND_MESSAGE to a topic of 202 levels (its own limit of 200 separators). A code the upper level refuses is not held, and one it omits is an ERROR and 0x80. A wildcard topic is refused to EV_SEND_MESSAGE. Unknown acks are said once. The take-over gives DISCONNECT 0x8E, and the closing connection refuses a send and takes EV_DROP, which drops it once the DISCONNECT is written. A 20 KB PUBLISH cut after each byte of its fixed header. Nothing after a DISCONNECT is read. Maximum QoS in the CONNACK. A CONNECT refused by policy is not dumped. A PUBLISH to a/+ gets DISCONNECT 0x81 and the WARNING “Mqtt: invalid topic in PUBLISH, disconnecting” (it said “Mqtt will: invalid topic”). Every step was red on 7.30.26. Alarm 20 s. No port.
c_mqtt/client_noqueueC_PROT_MQTT2 as a client: without queues, a QoS 1 publish in EV_ON_OPEN is refused (it was a SIGSEGV), its SUBSCRIBE asks QoS 0, and a QoS 2 from the broker disconnects with a WARNING (its payload was released twice). With queues, a QoS 1 publish in EV_ON_OPEN goes out (it was a SIGSEGV). max_packet_size is announced in the CONNECT and a PUBLISH announced at 300 000 bytes is refused at its header, with DISCONNECT 0x95 Packet too large (0x82 up to 7.31.1). Against a hostile broker, one connection each: a second CONNACK (with queues and without) gets DISCONNECT 0x82, with no reopen and no leak. A DISCONNECT with properties and a PUBLISH behind it in the same read: not delivered, no leak. QoS 3, a wildcard topic and QoS 0 with DUP get DISCONNECT 0x81. An MQTT 5 CONNACK refusal (0x87), and a 3.1.1 CONNACK with the reserved code 6, give EV_ON_CLOSE with their code and nothing is sent. An MQTT 5 CONNACK with 0x06 and with 0x7F is a protocol error (one WARNING that says so, with a text reason, no dump, DISCONNECT 0x82) and gives EV_ON_CLOSE with the code (it gave nothing). A CONNACK in the form of 3.1.1 with the code 1 and with 4, to the MQTT 5 client, gives EV_ON_CLOSE with 0x84 and 0x86 and nothing is sent (it was DISCONNECT 0x81 and no EV_ON_CLOSE). An MQTT 5 CONNACK with the code 2 is a protocol error like 0x06 (DISCONNECT 0x82. It was a refusal “Granted QoS 2”). A 3.1.1-form CONNACK with 0 and with 6 to the MQTT 5 client gives EV_ON_CLOSE 0x81, one WARNING, nothing sent (it was DISCONNECT 0x81 and no EV_ON_CLOSE). A PUBLISH of 250 levels is delivered (it was 0x81), and its user publishes one by EV_MQTT_PUBLISH and EV_SEND_MESSAGE (each was -1) while a/#, a/+ and a/+/b stay refused. Alarm 45 s (the run is about 20 s). No port.
c_mqtt/broker_no_dbC_MQTT_BROKER with mqtt_persistent_db false and on_critical_error 0 logs ONE CRITICAL that names the attribute, does not play, and logs nothing more for 2.5 s. Its nine commands that need the treedb answer -1 “broker not playing” with no ERROR, and help answers. Red on 7.30.26 (it played, with ERRORs per tick). No port, no store.
c_mqtt/gate_cutThe cut of a gate’s MQTT 3.1.1 connection over a REAL socket (port 18115): a server C_PROT_MQTT2 behind a C_TCP_S, its upper level the driver, which posts EV_DROP on a PUBLISH cut and a SUBSCRIBE cut/#. A raw client writes each case in one write. Three QoS 1 PUBLISH and the marker get PUBACK 1-4 and then the close. SUBSCRIBE a/b + SUBSCRIBE cut/# get SUBACK 0x00, SUBACK 0x80, then the close. Three QoS 1 PUBLISH and a DISCONNECT with flags 1 get PUBACK 1-3 and the close (MQTT 5: then DISCONNECT 0x82, then the close). Three QoS 1 PUBLISH, the marker and a malformed packet get PUBACK 1-4 and the close (the marker’s EV_DROP reaches the close while it waits). One WARNING (the malformed packet). Red on 7.30.26: [PUBACK 1, close] in every case but the SUBSCRIBE one, [SUBACK 0x00, close] (the C_TCP discarded what waited behind its write in flight).
c_mqtt/gate_floodA peer that asks a gate for answers faster than it reads them, over a REAL socket (port 18116), default max_unwritten_bytes (100000), timeout_close 10 s: a client reading twenty bursts of 200 PINGREQ gets its 4000 PINGRESP and stays (what waits is bounded, not the total). 131072 PINGREQ in one write, and 40000 QoS 1 PUBLISH, the client not reading (rx_paused) for 3 s and then reading: the gate pauses its reading while the answers wait, the memory (sampled every 20 ms) grows less than 2 MB, and the client gets every PINGRESP / PUBACK, not dropped. 20000 QoS 0 PUBLISH and a PINGREQ in one write: all taken, not dropped. No WARNING. Red on 7.30.26: no bound, +39 MB for the PINGREQ, +13.6 MB for the PUBLISH. Red on the bounds that came after it (never released): the client of the floods dropped.
c_mqtt/gate_answersThe bound on the answers against many connections and big answers, over REAL sockets (port 18122): raw plain sockets that never read, SO_RCVBUF 4096 set before the connect, the gate’s side SO_SNDBUF 4096, timeout_close 500, timeout_stop_tx 3 s. 50 connections each sending exactly 10000 PINGREQ: the reading of each is paused, each dropped when nothing more is written for timeout_close (one WARNING each), the memory growing less than 12 MB (6.5-6.8 MB measured), then the transport’s own abort of each at timeout_stop_tx. One connection with 100 granted filters then SUBSCRIBEs of 16000 x a refused by the protocol (SUBACK 16 KB each): paused, dropped, growing less than 1 MB. Red on the bound in packets: no drop (176 MB, and 2.3 MB after 150 SUBSCRIBEs), and the drop said again by “Timeout waiting mqtt disconnected”.
c_mqtt/broker_answersC_MQTT_BROKER (port 18123) and raw MQTT 3.1.1 clients that read: a subscriber to fc/# publishing 30000 QoS 0 to fc/x in one write gets them all. A client with a window of 20 publishing 2000 QoS 1 and 2000 QoS 2 to a topic it subscribes gets every PUBACK, PUBCOMP and message. 3000 QoS 1 in ONE write get their 3000 PUBACKs (the reading paused and resumed). 30000 PINGREQ in ONE write get their 30000 PINGRESPs. None dropped. Red on the bound in packets: the subscriber dropped after 23 messages. Red on the cut-based bound in bytes: the client of 3000 QoS 1 dropped after 2 PUBACKs.
c_mqtt/broker_stop_drainC_MQTT_BROKER (port 18124) and four raw clients on plain sockets (SO_RCVBUF 4096, the broker’s side SO_SNDBUF 4096), none reading: 8000 PINGREQ + 0xF0 in 3.1.1 and 5 (their reading paused by the bound, the 0xF0 held), and 5 SUBSCRIBEs of 8000 x a + 0xF0 in 3.1.1 and 5 (their closes wait for 40 KB of SUBACKs). The yuno stops 1.5 s later and the driver, stopped right after the broker, resets the connections: their EV_ON_CLOSE come with the database closed (four INFOs), the reads held are released. No ERROR, no crash, no leak. Red on 7.30.26: SIGSEGV at the stop (the destroyed treedb read in ac_on_close). With only that fixed, the queues of the closing connections leaked.
c_mqtt/gate_readerThe bound on the answers against peers that pipeline AND read, over REAL sockets (port 18125): 20 raw clients with the kernel’s default buffers, each sending PINGREQ without end (up to 64 KB of them not yet answered, and 512 KB up to 2026-11-14, whose drain did not end in 300 s on a loaded riscv64 board at ctest -j8) and reading every 20 ms, for 20 s. The gate’s reading of each is paused and resumed again and again. None dropped, every PINGRESP received in order (checked byte by byte), the memory growing less than 5 MB (2.6 MB measured). Then the clients drain and close. A reader owed answers that gets no byte for 1 s (in 10 looks or more) fails it, in the run and in the drain: the gate and the readers share one loop, so a reader owed gets bytes at every look at any speed (none waited a look at a full CPU, at an eighth of one, or under ASan at a quarter of one). Red in about 1.4 s with 1 EV_RX_RESUME of every 10 lost, 1 of 4, 1 of 2, all (rescued at 3 s or at 9 s), or a reading never resumed. The drain fails too when it is not over in 300 s, the only limit that depends on the machine: about 23 s in all here (the drain about 2 s). With the old 512 KB window it was about 40 s (the drain about 17 s), 140-170 s at a quarter of a CPU, 286 s at an eighth. Under ASan it was 64-67 s, and 287-304 s at a quarter of a CPU. ASan at an eighth of a CPU failed it with no defect. Up to its first version the drain had 60 s in all (red under ASan). Up to its second it failed only when NO reader got a byte for 10 s (1 resume of 10 lost passed, in 275-296 s). Red on the first pause (never released): past 5 MB in under 2 s.
c_mqtt/broker_sessionsC_MQTT_BROKER (port 18126) and raw clients that never ack their forwards: a client that kept its session (5 QoS 1 messages queued for it) taken over with a CLEAN session, in 3.1.1 and 5: CONNACK session present 0 and nothing more. The same taken over keeping the session: session present 1 and the 5 messages. MQTT 5, the old connection dropped first (0xF0): nothing. 3.1.1, 21 QoS 2 without PUBREL: the close and one WARNING “Mqtt: QoS 2 PUBLISH past max_inflight_messages (Receive Maximum), disconnecting”. 7 and 8 (3.1.1): the old connection stalled (receive buffer 4 KB, the broker’s side 4 KB, reading nothing, 5 SUBSCRIBEs of 8000 a and 0xF0: the broker’s close waits for 40 KB of SUBACKs), taken over while it is still closing: with a clean session nothing, keeping it the 5 messages. 9-18 (B acks what it gets and stays 2.5 s, so the queue backup runs on its queues, and A is MQTT 5, Clean Start 1, Session Expiry 300 unless said): A taken over while connected by B keeping the session, MQTT 5 (9) and 3.1.1 (10): session present 1, the 5, no ERROR. 25 messages, DISCONNECT and close, 5 more published, B back keeping it (11): the 30. A stalled with 30 messages, B keeping it while A closes (12): the 30. A’s DISCONNECT with Session Expiry 0 and A still open, with no keepalive (13) or a keepalive of 1 s (14): closed by the server at timeout_close (one WARNING “Client did not close after its DISCONNECT, closed by the server” each, no keepalive WARNING), the session ended with it, and B keeping one: session present 0 and nothing (up to 7.31.1 A waited to be closed by its keepalive, and B got the session A had expired). What is not kept is still deleted at the close, B keeping: 3.1.1 clean (15), MQTT 5 with no Session Expiry (16), Session Expiry 300 and a DISCONNECT with 0 (17), Session Expiry 1 and B 3 s later (18): session present 0, nothing. About 42 s. Red on 7.30.26: the clean session got the 5 old messages (1, 2 and 7), the close of the QoS 2 had no log, the close of A deleted the topics B had open (9, 10, 13, 14: “Cannot open topic” and “kw must be list or dict” every second, and 12: SIGSEGV), and 11 got 5 of 30.
c_mqtt/broker_session_subsC_MQTT_BROKER (port 18133, max_subscriptions_per_client 5) and raw clients: 20 SUBSCRIBEs of a filter that a persistent session holds, with the same QoS, do not write the session (its i_rowid does not move), and one with another QoS writes it once. A session that connects again and subscribes a sixth filter gets 0x80 (MQTT 3.1.1) or 0x97 (MQTT 5), with one WARNING every 10 s. A client in two share groups of a topic gets a message once per group, and its UNSUBSCRIBE and its close remove the groups. An UNSUBSCRIBE lowers the count of the session, and the next filter is granted. A session restored above the limit (7 filters, limit 5) refuses a new filter and grants a filter that it holds. Under the limit after three UNSUBSCRIBEs, it grants the new filter. Red on 7.31.29: 20 writes, and the sixth filter granted.
c_mqtt/broker_stop_droppedC_MQTT_BROKER (port 18127) stopped 3 s after four raw clients that keep their sockets open through the stop: two dropped by the bound on the answers (SUBACKs of 16 KB, never read, timeout_close 500), their C_TCP waiting timeout_stop_tx. A subscriber to s/# QoS 1 that never reads while a publisher sends 20000 messages in QoS 0 and 1 in turn. No EV_ON_CLOSE comes, and the protocol frees the queues at its destroy: no ERROR, no leak, exit 0. Red on 7.30.26: “system memory not free” (21452 blocks), exit 255.
c_mqtt/broker_treedb_srcC_MQTT_BROKER with a C_AUTHZ master and no port. The driver forges the broker’s treedb events in-process from four sources that are not the broker’s treedb: itself (EV_TREEDB_NODE_DELETED of admin), the broker’s __top_side__ (_UPDATED of carol with enabled true), another C_NODE (the treedb of authz, _CREATED of mallory) and a C_IEVENT_SRV (_CREATED of trudy). Each is refused (-1), ONE braked WARNING “treedb event not published by the treedb of the broker, refused” (suppressed 0), and authz does not change. The same changes made in the broker’s own treedb still reach authz. Past the 10 s window, two more forged events: the WARNING of the first says the three held back (suppressed 3), and the second is held back. Past the next window, one more says only that one (suppressed 1: the count goes back to 0 at each WARNING). About 24 s. Red on 7.30.26: admin disabled, carol enabled, mallory created.
c_mqtt/broker_takeoverC_MQTT_BROKER (port 18120, timeout_close 1000) and two raw MQTT 5 clients of one client id: A connects, B takes it over (A gets DISCONNECT 0x8E, its session not kept, and does not close), B disconnects and closes (its session deleted), A is dropped at timeout_close (“Timeout waiting mqtt disconnected”) and its late EV_ON_CLOSE finds no session. No ERROR. Red on 7.30.26: “session NULL”, and 0x00 for the DISCONNECT.
c_mqtt/broker_no_playC_MQTT_BROKER started and never played (service autoplay false). The yuno ends 0.5 s later. No ERROR at the stop. Red on 7.30.26: “gobj NULL” with a stack (broadcast_tranger_queues() from close_database()). Port 18121, never opened.

Source: tests/c/c_mqtt/

BinaryDescription
c_subscriptions/test1–3GObj event subscribe / unsubscribe lifecycle. test3: a repeated HARD subscription is one (the second gobj_subscribe_event() returns the one there with a warning, and each event arrives once), gobj_unsubscribe_event() leaves it with a warning, gobj_unsubscribe_list() with force removes it. A repeated __own_event__ subscription, and a repeated __rename_event_name__ one with a __global__, are overridden (one subscription, each event once), and gobj_unsubscribe_event() with the same kw removes them. A renamed subscription over a plain one, and two renames of one event, are two subscriptions (each event arrives once under each name), and each kw withdraws only its own (7.25.5 replaced one with the other). gobj_unsubscribe_list() removes the subscription it is given, so a stale plain one removes no live filtered one, and a top-level renamed_event in a find kw filters nothing. In the other order, a plain subscription over a renamed one replaces it, and a plain unsubscribe removes both. One withdrawn by the mt_subscription_deleted of an entry before it is not taken for a hard one kept. A subscription the publisher refuses leaks nothing (up to 7.25.20 each refusal leaked it).
test_c_node_link_eventsEV_TREEDB_NODE_LINKED / UNLINKED events at the C_NODE GClass level, and an update-node with autolink: the links it repeats publish nothing, a moved link is one unlink and one link, and a ref that cannot be linked (missing parent, or a hook that links into another column) is logged while the record is still saved. It also checks set-link-events switching a live treedb from the parent’s UPDATED to LINKED/UNLINKED and back. Last, delete-node of a key with pkey2 instances, reopened: a lookup of the primary’s value is the primary, a refused delete leaves every instance.
test_c_node_commandsWhat the read commands of C_NODE answer: treedb-info, node (and one not there), instances, pkey2s, jtree (rename_hook), parents / children with and without options (without them they logged an ERROR per option up to 7.25.22), hooks, links, print-tranger, and the snaps on the data (activated, the treedb opened again shows the node as it was, and deactivated, as it is). What a command names is the peer’s data, refused with a WARNING (never the treedb’s ERROR): an unknown topic or one that breaks the name rule, a link or hook that is not a column with that flag (departments^top^name), a hook that does not link the child’s topic (link-nodes / unlink-nodes by departments^top^users of a department: up to 7.26.9 “Topic child not defined in hook desc links”, an ERROR), an update-node of a node that does not exist, without create (up to 7.26.9 an ERROR with a stack and the whole kw dumped), a record whose id is not a string or a content64 that is not an object, a content64 that is not json (an ERROR with a stack and, up to 7.26.9, the decoded text in clear), a record with a NUL in its id or down it ("dx\u0000evil" took the key dx, up to 7.26.9), create_only of a node that exists, and instances by a pkey2 that is not a secondary index (id walked the primary index as instances, 9 errors per node). Every refusal is asserted as a WARNING (__priority__), and the create of a subscriber inside a peer’s create as an ERROR: the treedb publishes outside the peer’s window. Also checked: instances with no node_id and no filter, import-db of wrong records and an unknown topic (counted), and an id with a /. What only the treedb can judge (a link that closes a cycle, a node linked to itself, an unlink of a child that does not hang there, a create without a required field) is said by the treedb as a WARNING, the record marked as a peer’s (treedb_set_peer_data()). A parameter of the wrong type (node_id given a number) is refused by the command parser, a WARNING. An rt list of the topic (tranger2_open_rt_mem()) is fed outside the peer’s window, like the subscribers. It checks treedb_node_children() / treedb_parent_refs() with no options. An import-db of a record with no fkey logs nothing. A peer’s create-node with content64 holding a json with "gbuffer" writes the node without the key (up to 7.30.16 SIGSEGV in kw_twin). A kw with a gbuffer through snaps, a FILTER released with JSON_DECREF, goes in with json_incref() (up to 7.30.17 with kw_incref(), and the gbuffer of every call leaked: the leak check of main.c). The node API where its method is not reached (a NULL gobj for get_node, list_snaps, topic_jtree, node_tree, delete_node, and a topic that is not there for delete_node), each kw carrying a gbuffer: released as the method releases it (up to 7.30.17 a leak for get_node, “BAD gbuf_decref()” for the rest). A content64 that is not base64 (@@@notbase64@@@) to create-node, update-node and import-db: -1 “Invalid base64 in content64” and one WARNING “base64 of a peer not decodable, refused” each (7.30.26: an ERROR “b64_decode() FAILED” with a stack). print-tranger not expanded (the default) answers the keys of the value, with each dict under them collapsed. Up to 7.31.29 it answered the whole value, and with no path the whole tranger. The callback of the treedb shows as <pointer>, in a dict and at the end of a path. A cycle of two hooks (a.subteams holds b, and b.leads holds a) is collapsed where it comes again under itself, at three paths and two limits. Up to 7.31.29 the walk did not end, and the yuno aborted out of memory.
test_c_yuno_publish_statspublish-stats of C_YUNO at a timeout_periodic of 100 ms: (A) its own ttl ends it, (C) the attribute publish_stats_ttl does, (B) ttl=-1 never does and stop=1 does, nothing after. Each publication is an EV_MT_STATS_ANSWER with the stats, the mark of the request and the route reversed. Refused: (D) a service that does not exist, (E) a requester that is not a service, (F) a stats_service longer than NAME_MAX. (G) The stats of a C_IEVENT_CLI service that never had a session end at the first tick (“its service is a link out of session”), nothing published and no WARNING: such a link answers -1 “not in session” with a WARNING, and without the check that was published and logged every period, for ever with ttl=-1 (red: 4 in 500 ms).
c_yuno_info_machine/test1info-machine of C_YUNO. Its ifs has one entry for each interface name, in the order that getifaddrs() first gives that name, with the IPv4 and IPv6 addresses that getifaddrs() gives for it. For one call the test returns a hostname that is not UTF-8 (-Wl,--wrap=get_hostname). The answer is then -1 with one ERROR, “info-machine: cannot build the answer”. Up to 7.31.29 the answer was 0 with no data and no log, after a read of the os info that json_pack() had freed (red: “json refcount 0” at pretty_name).
yuno_skeleton/templatesThe templates of yuno-skeleton instantiated (answers on stdin) and built against outputs/ with no warning: yuno_standalone with a gclass_child and a gclass_service in it, run so that each one’s timer (a pure child) reaches its ac_timeout, and yuno_citizen. The register_yuno_and_more() of both templates hands back what its registrations answer (result += register_c_<name>()), so a gclass refused stops the yuno (7.27.0+). Red with a template timer that is a plain child, or with MSGSET_INTERNAL_ERROR. Since 7.28.7 it also checks the following. The root gclass of both yuno templates carries the SERVICE subscription block. c_project builds. js_gclass and js_gclass_service load in node against this tree’s gobj-js and their timers fire. project and project_commercial build from their root with a citizen yuno in yunos/, with the right LICENSE and a gui/ whose package.json is json, whose .js parse and which keeps only i18next’s {{name}}/{{n}}. No template leaves a marker without a value. An input that runs out is an error. It tests the tree it is in (its YUNETAS_BASE is its own source dir), never another tree or the installed yuno-skeleton.
yuno_skeleton/clonersyclone-gclass, yclone-project and ymake-skeleton (one engine, utils/c/yclone-project/clone_tree_dir.c) on a yuno made by yuno-skeleton (7.28.7+): a key is replaced as a whole word (time -> clock leaves C_TIMER, set_timeout, EV_TIMEOUT) and in one pass (sktcln -> sktcln_two is never sktcln_two_two). A binary is copied byte for byte, modes and symlinks are kept, .git and build are not cloned, and a destination inside the source is refused. Each clone builds and says its new role, and a template made by ymake-skeleton goes back through yuno-skeleton and builds. 21 of its checks fail against the 7.28.6 binaries.
test_c_node_initial_loadThe initial_load seed of C_NODE: records first and links second whatever the topic order, every seed immutable, a declared link refused to unlink-nodes, to an autolink update that omits it and to a force delete of its parent, and a second start that creates nothing. print-tranger walks any path (kw_find_path() in a loop): a segment longer than 255 bytes and a segment under a string are answered -1 “path not found”, with no log (they were ERRORs of kw_find_path(), then WARNINGs of a walker of its own), and a string at the end of the path is answered as it is.
test_tr_treedb_link_eventsLow-level link/unlink callback mechanism in tr_treedb.
test_tr_treedb_failed_saveA write whose save fails is taken back in memory: with the files of a key read-only, a failed update, link, replace of a single fkey, treedb_replace_links(), treedb_autolink() and unlink each answer a refusal, leave the nodes and hooks as the disk says, and tell no event. With the files writable the same writes work, and a reload says what memory said. Also checked: the update with its links (treedb_update_node_and_links(), with and without fields). A failed clean, where a stale ref (its hook no longer exists, or fills another column since a schema re-pointed it) goes back into its field and is never linked. Refused forced deletes (a child that cannot be saved, a key that cannot be deleted) that change nothing, in memory or on disk. A take-back that puts every child back in its place in the hooks of its parents (a list hook and a dict hook keep the order they had). treedb_autolink() refusing a ref whose hook fills another column, with nothing moved. A refused forced delete whose put-back of a child fails too (the child stays unlinked, in memory as on disk, the ERROR says so, and the events of its unlink are told. The test fails the writes of that key in its own __wrap_write()). A forced delete that tells its unlinks after the node left the indexes, with a subscriber that cannot find the node nor save it, and a reload that does not bring it back. A write that cannot be taken back whole says so. Two active snaps at open (a deactivation that cannot be saved leaves the snap active, and a replica does not repair).
test_c_node_failed_saveAn update-node with autolink of C_NODE whose save fails (the writes of the key fail in the test’s own __wrap_write()): the method answers NULL and the command -1, memory is what the disk has, and no EV_TREEDB_NODE_LINKED / UPDATED is published. A create with autolink whose links cannot be saved leaves the node without them, in memory as on disk, and logs “Node created, but its links cannot be saved (autolink): the node stays without them”. A reload from disk agrees, and the retry works.
test_c_subscription_authzThe subscription authorization gate (enable_subscription_authz): three C_IEVENT_CLI connect over websocket to a C_IEVENT_SRV of the same yuno and subscribe to the EV_TREEDB_NODE_* feed of a real C_NODE. Gate off: every peer is subscribed. Gate on: a peer without read is refused and it is logged, a reader is subscribed (the checker is asked read), an event not flagged EVF_AUTHZ_SUBSCRIBE needs nothing. A node update reaches only the accepted subscriptions. The realtime feed of a real C_TRANGER (EV_TRANGER_RECORD_ADDED) is guarded the same way (open to any user up to 7.25.4). The six channel commands of C_IOGATE with a channel_name that matches nothing answer with no channel (up to 7.25.4 they looped for ever). The authzs trace prints the kw it checked (up to 7.25.4 a kw already freed). A peer that asks __hard_subscription__, __own_event__ and __rename_event_name__ gets a plain subscription (only __first_shot__ is kept), which goes with its session and reaches neither a later subscriber’s loop nor the next user of the channel. Every channel disabled and enabled again serves a new session. The gate stops orderly (no “Destroying a RUNNING gobj”).
test_c_node_authzThe permission every C_NODE command asks for, reads and writes, with a checker that refuses one principal: a refused command answers -403 and does nothing.
test_c_ievent_srv_peer_subsWhat a remote peer can put in a subscription, and hold, through C_IEVENT_SRV: one peer writes its frames by hand, with a __global__ that forges keys of the event and sets framework keys and a gbuffer, a __local__ and a stray key. A plain client subscribes with a __filter__ and a __global__. Two local subscribers, one with a __local__ and a __global__. Each gets what IT asked and nobody else’s (up to 7.25.4 the publish shared one kw: the plain client got nothing, the later local subscriber got the forgery without the secret and the peer’s __md_iev__, and the gbuffer crashed the yuno), and the publisher’s kw returns as it went. max_subscriptions and max_subscription_size refuse. The dropped keys, the caps, a withdrawal of nothing (repeated, with a 2 KB key: one line, capped) and a repeated authz refusal are each logged once. A client withdraws a subscription with a __global__. A __username__ and routing stamps (input_channel, input_service) that the peer puts in a command, a stats request, an event or a subscription are overwritten by the gate’s (up to 7.25.4 the peer’s __username__ reached the service). An event that carries a gbuffer reaches two remote subscribers (each on a twin with its own reference) and a local one, and when the publish returns the publisher holds the only reference, with no “BAD gbuf_decref()”. The stored subscription holds only the reversed hop of the peer’s frame, not a 4 KB key of the peer’s own in its __md_iev__ (up to 7.25.4 the whole __md_iev__, not measured), and a routing bigger than max_subscription_size is refused, logged once. A subscription repeated 3 times is kept as it is (the publisher’s mt_subscription_added is not called again), one warning. 3 commands to a service the channel is not allowed to reach and 2 that name no command get negative answers and one warning each. A frame with no __md_iev__ (50 KB) is one capped warning and closes the channel. And the server sends the plain client (an anonymous yuno) two events of its own through the gate of his channel (gobj_send_event(<C_IEVENT_SRV>, EV_X, kw)): with no __service__ it reaches the subscribers of his transport, with __service__ the service named. Up to 7.26.9 both closed his channel (“It’s not my name”: the gate addressed them to its own label for an anonymous yuno, ^peer-sock). A command routed to her own service whose service is __yuno__: a negative answer (up to 7.30.14 it reached __yuno__). The transport of bob’s channel says EV_ON_OPEN to its gate in the session: ONE error, and bob gets nothing (up to 7.30.14 it went to bob as a frame). The subscription refusal is a WARNING. Alice’s __global__ {gbuffer: 1} is dropped when the frame is parsed, with its own WARNING.
test_c_ievent_srv_identity_cardThe identity cards a raw websocket peer sends to C_IEVENT_SRV before its session: a card without __md_iev__, one for another dst_role (with a 4 KB key) or dst_yuno, one without src_role or src_service, one for a dst_service that does not exist, one whose jwt is not a string, and a command before any card that carries credentials (a password key, keys named like secrets down its kw, token=... in its command line), and an event no gclass has as public, carrying credentials and a JWT under a plain key, a secret in its NAME and 64 KB of kw (“Frame of an event that is not public, refused”, said once by iev_create_from_gbuffer(), the name masked, and a frame_size of what was received. Up to 7.26.9 its kw was traced raw, its name was written in clear and the size was the masked copy’s), a frame of json that is not an inter-event (“Frame is not an inter-event ...”, masked) and a frame that is not json (“frame is not json”, its dump masked), both with a JWT that a window of 256 bytes cuts after its header (up to 7.26.9 both were “Bad json” and a raw dump that showed the JWT’s payload). Each is ONE warning (MSGSET_PROTOCOL, the kw capped, no stack, the jwt and every credential never in the log) and closes the channel. The last, good card is answered EV_IDENTITY_CARD_ACK and opens the only session. Up to 7.25.20 each was an error with the whole kw, and a second error, “event UNKNOWN in not-session state”, and the card with a non-string jwt was accepted. 13: in the session, a good card of another user: refused, a negative ACK and ONE warning. The session keeps its user and its channel, and no second EV_ON_OPEN (up to 7.30.14 the card replaced the user). Card 3 also carries a serialized gbuffer with no data, and a card refused by the authentication carries one whose data is not base64, and another a valid one: each gives ONE WARNING and no ERROR, and the refused one is not released twice (up to 7.30.14 “BAD gbuf_decref()”, up to 7.30.15 an ERROR with a stack). The good card carries a serialized gbuffer too: the card the gate keeps, and the one it publishes in EV_ON_OPEN, have no "gbuffer".
test_c_ievent_cli_peer_faultsThe other side: what C_IEVENT_CLI does with the faults of its server. A raw websocket server (no C_IEVENT_SRV) answers each identity card of a real C_IEVENT_CLI with the next fault: a session event (EV_MT_STATS) before the session, then, after a good EV_IDENTITY_CARD_ACK, a frame for another dst_role, one for another dst_yuno, a subscription (__subscribing__) and an unsubscription (__unsubscribing__), the names the server writes carrying a credential (password=...). The last card is answered with the ACK alone. Each fault is ONE warning (MSGSET_PROTOCOL, no stack, the names masked and capped, never the credential) and closes the channel. The client connects again. Up to 7.26.9 each was an ERROR with the names in clear, both subscriptions said “subscription event ignored”, and the session event before the session went to mt_inject_event() (“Not in session”, an ERROR) before its own. In the last session the server then sends EV_ON_OPEN and EV_ON_CLOSE (events of the transport itself, which C_PROT_HTTP_SR declares public) and the ACK again: each is refused with ONE warning (“event of the transport itself, or out of its place, refused”), the channel stays, and the app hears none of them (up to 7.26.9 the first two reached it as the client’s own open and close, and the ACK was sent back to the server). And EV_TREEDB_NODE_UPDATED five times: with a dst_service that is no service, and with a service that does not have it as public, each dropped with ONE warning (“service of the event not found, event dropped”, its name masked, and “event not public in its service, event dropped”). With the client’s own name (what its identity card gave the server), with that name in capitals, and with none, the three published to the client’s subscribers, with no log (since 7.27.0. Up to 7.26.9 all of them were published, an empty or unknown name with an ERROR and a stack and the name in clear, the not-public one silently). Built twice: test_c_ievent_cli_peer_faults_child makes the client a child with no as_service, which gobj_find_service() does not find, so the client compares its own name itself, case-blind as the lookup is (a case-sensitive comparison dropped the name in capitals there only). Each trace of a fault carries its msg (up to 7.30.14 an uninitialized prefix).
test_c_ievent_cli_operatorA raw server sends thirteen commands to a C_IEVENT_CLI with verify_operator, each claiming __username__ liar@example.com. Good operator assertions (ES256, aud = the node uuid, from assertion_jwks) run as their sub: one of alice, one of alice expired within the clock leeway, and one of the local user yuneta. No assertion, and the __operator_jwt__ of 7.30.6, run as service_principal. These are refused, each answered with the reason and ONE warning: another key, expired past the leeway, for another node, not a string, a disabled user, a LOGIN token, living longer than max_assertion_lifetime, and no sub. _unverified (verify_operator off): all thirteen run as liar. In both, no command sees either field and no log line carries a token.
test_c_ievent_cli_play_pauseA link configured to reach a central (whose server claims to be an agent) refuses EV_PAUSE_YUNO twice and EV_PLAY_YUNO: the acks are -1 with a comment, the yuno keeps playing, ONE WARNING “play/pause of the yuno refused: only the link to its agent plays or pauses it”. The link configured to reach a yuneta_agent pauses the yuno and plays it again (up to 7.30.26 any link’s server was able to pause it). A second session of the other link refuses again, with a second WARNING.
test_c_ievent_srv_transport_eventsA session sends the six events of the transport (EV_ON_OPEN with a forged card and certificate, EV_ON_CLOSE, EV_ON_MESSAGE, EV_ON_ID, EV_ON_ID_NAK, EV_ON_IEV_MESSAGE) to a C_IEVENT_SRV under a C_IOGATE: the gate publishes none of them, ONE WARNING “event of the transport itself sent by a peer, refused”, the channel stays. The five events a treedb publishes (EV_TREEDB_NODE_CREATED ... _UNLINKED): none published, ONE WARNING “event of a treedb sent by a peer, refused”. 50 frames of an event the tester does not take: ONE WARNING “event of a peer the yuno does not take now, refused”, "not_said": 49 at the gate’s stop, no “Event NOT DEFINED in state”. An event of the service still goes (up to 7.30.26 the gate published each as its own, with the kw the peer wrote).
test_c_node_paged_nodesThe paging of C_NODE’s nodes: no limit answers the plain list. A limit answers {total_rows, pages, data}. from is 1-based. A page past the end is empty with the right total. from / limit given as strings work.
test_c_trangerC_TRANGER commands: topics, list-keys (counts and time spans), open-iterator and its pages by t and by tm. add-record appends (a dict or its json text, write, master-only. Before, it was a stub). The pushes of a live list carry its list_id as rt_id. A handle of one session is refused to another (close-rt, close-iterator, close-list, get-page, get-list-data answer -403), and through the agent’s one link (a C_IEVENT_CLI) a handle of one user is refused to another user and to a relayed command of no user, and not to the same user. add-record asks write and answers -403 on a refusal (a counting authz checker). What a peer hands is refused BEFORE the tranger, a WARNING each (__priority__), and the same from C code an ERROR: an unknown topic or a name with / or .., a system topic to delete, a create-topic of a wrong shape (an unknown system_flag, two key types, no pkey, a name longer than NAME_MAX, a FILE of the database, a new topic_version over a system topic, over a treedb’s topic or without jn_cols, and jn_cols={} taken for a topic with no columns), a new topic named as what a store keeps (.hidden, __x, x.json, x.bak), a jn_var of what the tranger keeps or types, a record without its pkey or with a pkey that is a path, a record with a NUL in a string of it or in its json text (the pkey "K\u0000evil" was appended under K, up to 7.26.9), a __t__ or a tkey time past 44 bits (an integer, or a DATE: "@99999999999999 +0000", and "@20000000000 +0000" on an sf_tm_ms topic, but a date the row keeps is appended), a key that is a path, a time bound that is a dict. A print-tranger path that is not there is answered -1 with no log, whatever its length. A peer’s write into a treedb’s topic or a new topic in its store. check-json asks read and answers what it finds, logging nothing (with max_refcount=1, a 0: -1 is a fault). A replica answers READ-ONLY to delete-key, delete-topic and the create-topic of a new topic, with no ERROR. delete-key-files by date, by an integer and of every key, its purged in list-keys, and its refusals (a before in the future, a text that is no date, none, a key not there). A multi-key page across a purge keeps its positions, and a filtered one is closed saying so. See its README.md. add-record of a __t__ in a purged period is refused before the tranger, with the cause in the answer, also for a key flagged unlisted (its .purged unreadable at the open). delete-key-files of a treedb’s topic and of a mask that does not sort is refused from C code too. archive-key-files is refused with no archive_directory attribute, and with one makes a batch. A record on disk with a top-level "gbuffer" key (4096): an open-list with fields trims it, and print-tranger prints it whole from a live list (both SIGSEGV up to 7.30.17). A "gbuffer" key in a topic’s topic_var: topics expanded=1 answers (tranger2_topic_desc() crashed up to 7.30.17). A peer’s list-keys with rkey=^(a+)+$ over a key of 30 a and a ! is refused in a moment, -1 with a WARNING (“rkey regex too costly, refused”), and a cheap rkey over the same keys answers. Up to 7.31.29 it answered 0 without that key. A live open-list with that rkey over 51 costly keys loads in less than 1 s, with one WARNING, and its answer and get-list-data say the 51 keys. Two appends of a costly key do not add to them. A list-keys with `(*NO_JIT)(?:\w
test_c_tranger_replicaC_TRANGER as a REPLICA of a store a master in the same process purges, with no loop: a filtered multi-key iterator purged after its open closes the part the purge was applied in before it says the iterator was closed. An unfiltered one over a key the replica numbered short (a md2 it was not able to read) keeps its positions when the purge renumbers the key (renumbered). delete-key-files answers READ-ONLY. One-key and multi-key iterators with absolute rowid bounds (from_rowid=3, to_rowid=4) page the same rows, under their new g_rowids, after a purge that renumbers the key and closes no part.
test_c_agent_find_new_yunosThe rows of the agent’s find-new-yunos, against a real C_NODE with the agent’s schema: a yuno already registered at the new release (a single one, and a yuno_multiple one) is marked “already registered, pending promotion (deactivate-snap)”, not listed as new.
test_c_agent_sandboxThe real agent (its build dir) run in namespaces of its own (unshare -rmn --pid --fork --mount-proc: a tmpfs on /yuneta, a passwd where uid 0 is yuneta, its own loopback and /proc), driven on its 1991 by a python peer whose frames are written by hand. A write-tty of a console that is not there, and check-realm/dir-logs/dir-local-data/update-binary of an id that is not there, each kw carrying a __gbuffer___: no “BAD gbuf_decref()” (up to 7.30.17 one per request). list-yunos and command-yuno with a gbuffer of 200 KB: nothing left at the gbmem audit of the orderly end (up to 7.30.17, 18 blocks). Then a logcenter installed and run by the agent, and identity cards it refuses: an unknown yuno or a second instance of the running one with the pid of a decoy (the decoy lives), the second instance with the pid of the yuno (killed: its own process), and pid -1 (nothing killed. Up to 7.30.17 every process of the user died, the peer too). Three WARNINGs “identity card refused: its pid is not a process of that yuno, not killed”. kill-yuno of the running logcenter (killed with SIGKILL, it stays down: its watcher does not relaunch a yuno killed that way, and it is run again. The agent’s boot run of its yunos, timerStBoot 0.1 s, passes before the yuno is created) ends it. A card the agent ACCEPTS for a second logcenter, registered and not run, with pid: -1 and watcher_pid: -1: neither is recorded (one WARNING “identity card accepted: its pid is not a process of that yuno, not recorded”), and its kill-yuno is refused. Up to 7.30.17 that kill-yuno sent SIGQUIT to every process of the user, the peer too. Skipped (77) without unprivileged namespaces, ip, python websockets, or the binaries. Case 6: trace-on-yuno without level, or with one that is not global, answers -1 with the global levels listed and sets nothing. level=machine,ev_kw, then level=commands on the traced yuno: the yuno’s own get-global-trace says the three, and traced is true. trace-off-yuno: it says none, and traced is false. Each answer of the yuno goes to the agent (no “a command of the agent to a yuno failed”), and nothing leaks (421 blocks in 7.30.18). Up to 7.30.21 the pair set the user levels of the yuno’s root gobj, which has none: nothing was traced. Case 7: a SIGSEGV of the running yuno is relaunched by its watcher. A run-yuno asked during the watcher’s wait launches nothing (“alive but not connected”). The relaunched yuno is registered with its new pid and the same watcher, two processes live, and the agent log has exactly two “yuno ALREADY living” (the second cards of case 4), none from the relaunch. The sandbox runs with ulimit -c 0. It also takes outputs/yunos/emailsender (skipped without it). Case 8: trace-on-yuno / trace-off-yuno of the logcenter killed after a trace-on answer -1 “… not connected to the agent (stopped, starting or stopping): its trace not changed” and leave traced true. Run again, the yuno has its saved levels, and trace-off-yuno then resets them (0, traced false). Up to 7.30.22 the trace-off answered 0, set traced false, and the yuno came back traced. Case 9: an emailsender (logcenter’s domain_dir is fixed in its binary) traced with machine, killed and deleted with whole=1: its data/C_YUNO-z-persistent-attrs.json is removed, and created again with the same id it traces nothing, traced false. Up to 7.30.22 the file stayed and the new yuno traced machine. Case 10: the same emailsender, traced with machine again, killed and deleted with yuno_release=<its only release>: the yuno is gone, its data/C_YUNO-z-persistent-attrs.json is removed, and created again with the same id it traces nothing. In 7.30.23 only whole=1 removed the file, and the new yuno traced machine. Case 11: a run-yuno that plays keeps its requester for the play of that launch only: run-yuno (must_play false), play-yuno, a SIGSEGV and the watcher’s relaunch. Neither the session that ran it nor one that took its channel gets another answer (7.30.26: the relaunch answered that run-yuno again). Case 12: a run-yuno of a yuno with must_play true: its session gets the run answer and the play answer once each, and the watcher’s relaunch answers nothing more. A session that leaves before the yuno reaches the agent (held with SIGSTOP) gets nothing, nor does the one that takes its channel. Every kill waits for the yuno AND its watcher (a run-yuno is refused while the watcher lives), and the saved trace is waited for (trace-on-yuno answers when it sent the order). Case 13: the certificate sync, with a copy command whose exit code the test chooses. Exit 75 (the lock of copy-certs.sh taken) is busy, not copy-script-failed: no failure counted, busy_ticks in cert-sync-status, one WARNING at the third busy tick in a row and one INFO when the lock is free again. Exit 1 is still copy-script-failed.
test_c_agent_command_loopThe real agent (its build dir) in the namespaces of test_c_agent_sandbox, with ulimit -v 4000000 (none for an ASan build) and no core. command-agent lines whose forwarded command is command-agent in a text that is not the bare name (‘command-agent’ quoted, with service=agent, with a trailing blank, in capitals, double-quoted with more words, bare, and in kw): each answers -1 “Loop command” (7.30.26: SIGSEGV on the first one, after 34 856 audit records). A forwarded help still answers. The agent ends in order (exit 0) with no “system memory not free”, and its audit file holds 8 to 20 command-agent records. Skipped (77) without unprivileged namespaces, ip, python websockets or the agent binary. Then four lines in the kw with two levels of quotes (“‘command-agent’”, ‘“COMMAND-AGENT” x=1’, a blank and a tab before “‘command-agent’”, and ‘“‘command-agent’”’): the guard and the parser read the first word once each, and each answers -1 “command not available: ‘<...>’” (7.30.26 and the previous guard: SIGSEGV on the first one, after 34 863 audit records). And command-agent service=controlcenter command=list-yunos, the control center’s link being down in the sandbox: -1 “service ‘controlcenter’ not in session” at once, and the agent log holds one WARNING “Not in session” and no ERROR (7.30.26: no answer, an ERROR with a stack). And stats-agent service=controlcenter: -1 “not in session” at once (two WARNINGs “Not in session” in all, no ERROR. 7.30.26: no answer and an ERROR with a stack). And create-config, update-config and install-binary with content64=@@@notbase64@@@: -1 naming it, three WARNINGs “base64 of a peer not decodable, refused”, no “b64_decode() FAILED” (7.30.26: an ERROR with a stack each). And create-config and update-config with content64=’ ’ (nothing) and with a config that is not json (a private key under ssl_certificate_key): -1 “Bad json in content64”, two WARNINGs “content64 of a config is empty, refused” and two “... is not json, refused”, no ERROR and no line of the content in the log (7.30.26: “len is ZERO” and “json_loads() FAILED”, ERRORs with a stack, and a dump of the whole config). Five lines whose secret’s key the shell’s quotes split: none of the secrets in the audit file (7.30.26 wrote the five). write-tty name=yuno and name=agent: EV_TTY_CLOSE naming it and a WARNING “not a console” each, and a write-tty without content64 one WARNING “content64 required”, no ERROR (7.30.26: “Event NOT DEFINED in state” with a stack, the agent writing to itself, an ERROR). And three create-config with a gbuffer key, written whole, split by a line and split by a #^^ comment: no stored config holds one, three WARNINGs (7.30.26 stored the two the comment cut makes). A config that its comment cut breaks: one WARNING “...not json once its comments are removed, refused” with the place of the mark. And create-config and update-config of [1, 2], {“version”: 5} and {“version”: “1”, “description”: 7}: -1 “Bad json in content64”, two + four WARNINGs and no “path MUST BE a json str” (7.30.26: an ERROR with a stack each).
test_c_agent_peer_closeThe real agent (its build dir) in the namespaces of test_c_agent_sandbox, with ulimit -v 4000000 (none for an ASan build) and no core, and outputs/yunos/logcenter is a yuno registered and never run, whose cards the test sends. The peer stops the agent (SIGSTOP) while it writes and continues it, so the Close of a peer and the orders to it are read in one turn of the loop. Two peers write, one connected before and one after, one before the Close and one after, so one always lands in the window. A yuno closes (a Close, a Close and FIN, a continuation frame with no message, a Ping of 126 bytes) while two operators send stats-yuno and command-yuno: the yuno’s channel refuses the pair read after the Close (-1 “not in session”), and each closing yuno answers both orders -1 “...: yuno runs but is not connected to the agent (starting or stopping): nothing sent”. Two operators close while the answers to their command-yuno return: the first answer is dropped. Three cycles of each. The order in which the kernel lets the agent read its sockets decides where each order lands, so the counts are not fixed: every answer an operator gets is -1. The client counts the answers “not connected to the agent” (a help after them on the same operator is answered after them), and the log holds as many WARNINGs “Not in session”, at least one, and at most 6 answers to an operator dropped (“Transport closing, nothing sent” or “requester gone before its answer”). There is no “Event NOT DEFINED in state”, and the agent ends in order with no “system memory not free” (7.30.26: 27 x “Event NOT DEFINED in state”, nothing answered). Skipped (77) without the agent or logcenter binary, unprivileged namespaces or ip.
test_c_agent_controlcenter_linkThe real agent (its build dir) in the namespaces of test_c_agent_sandbox, with ulimit -v 4000000 (none for an ASan build) and no core, linked to a control center written in python: TLS with throwaway certificates (certs/controlcenter.crt pinned), tcp4h frames holding ievents, node_owner sandbox and output_url cc.test:19898 sent to the loopback by an /etc/hosts of the sandbox. The operators are websocket clients written by hand. With the link in session, command-agent service=controlcenter command=list-yunos and stats-agent service=controlcenter are each answered with what the control center said (the request goes up with src_service “agent”, the operator in md_iev.agent_requester) and the log holds no “service of the event not found” (7.30.26: the link dropped both answers). Then bob, a user with a password and a role for the service agent only, sends an EV_MT_COMMAND_ANSWER and an EV_MT_STATS_ANSWER to agent naming the link in agent_requester: the control center gets neither, one WARNING “answer naming a requester of a link, not from a link: dropped” (as first shipped the agent sent both on). The first of bob’s answers of each kind carries “temp”: [1094795585], and two go to an empty dst_service (no “name NULL”). The control center sends play/pause acks (no temp, failed, with temp) and a reading and a publication with a temp: the agent lives, one WARNING “ack not from a yuno: dropped”, no “gobj NULL” / “hs_yuno NULL” (7.30.26: SIGSEGV, or ERRORs with a stack). Bob answers its own input-N with a single hop: one WARNING “answer with no route back to its requester: dropped” (7.30.26: a WARNING and six ERRORs each). Three answers to dst_service nosuch and the control center’s one to agent_requester nosuch: one WARNING “requester of the answer not found: dropped” and no “child not found” (7.30.26: an ERROR each). And a session that leaves while the control center holds its answer, another taking its input-N: the second gets only its own answer, and the log holds “requester gone before its answer” (the same with stats-agent stats=hold-me). A help is still answered. The control center sends EV_PLAY_YUNO, then in one write an order, EV_PAUSE_YUNO and the first two bytes of the next order, then the rest and 40 orders more: both acks are -1, the 42 orders are answered with 0, the 1991 takes a session, the link stays, one WARNING “play/pause of the yuno refused: only the link to its agent plays or pauses it”, no “No channel FOUND to send” or “hgobj NULL or DESTROYED” (7.30.26: SIGSEGV, or an agent with its 1991 and its link closed). Last, the control center sends 300 list-yunos: 150 one by one, each answered with 0, then a SIGINT to the agent and the other 150 at once: the agent ends with 0, no “system memory not free” (7.30.26: SIGSEGV, the order read the treedb the pause freed). The agent ends in order with no “system memory not free”. Skipped (77) without the agent binary, openssl, ip or unprivileged namespaces. A console opened through the link (open, write-tty, close) and a read-file by the link: open, output, close and EV_READ_FILE go up the link (the principal controlcenter is a root user in agent.json). The control center opens a console that floods (yes) and stops reading: agent growth < 160 MB, the console pauses for the link and is closed at its pause deadline (3 s in its agent.json, ONE WARNING), its backlog ending with EV_TTY_CLOSE (7.30.26: it grew until it aborted). A console writes while the link is down: ONE INFO “requester gone” and no “Not in session” (7.30.26: one per chunk). The link reconnects and the console writes up the new connection. Round 94 (needs tc, and the sandbox loopback has mtu 1500 and small send buffers): the control center away 9 s (3 deadlines) keeps its yes console, memory flat, and it goes on when it reads. A 1991 session that joins and does not read is taken off (1 WARNING). A TLS link slowed to 100 KB/s beside a reading joiner keeps both routes for 12 s (before: cut at its first deadline, txMsgs was not counted on TLS). A yes console paused when the link drops is released at the drop, lives the 10 s the link is down, writes up the new connection, and close-console finds it. Round 95: the control center joins the console of a 1991 session that does not read, 1 s before its link drops. The console lives the 10 s the link is down, and writes up the new connection when the session reads (before: closed within console_pause_timeout of the join). The python control center takes console events by event name: they no longer echo its marker.
test_c_agent_answer_routingThe real agent (its build dir) in the namespaces of test_c_agent_sandbox, with ulimit -v 4000000 (none for an ASan build) and no core, and outputs/yunos/logcenter is two yunos registered and never run, whose cards a websocket client written by hand sends, answering the agent’s stats and publish-stats. A watcher (watch-yuno-stats, relays EV_YUNO_STATS) gets the yuno’s readings. Another session sends a reading of that yuno (md_iev.agent_watch) and a refusal of its publication (agent_publish): the watcher gets no forged reading, the log holds no “publish-stats refused” and one WARNING “answer for the agent, not from the yuno it names: dropped” (7.30.26: the reading reached the watcher and the yuno was taken as refusing). The link of the other yuno sends the same two for the first one: dropped too. A session sends a reading and a publication with a temp of its own ([1094795585], {“channel_gobj”: 1094795585}) and EV_PLAY_YUNO_ACK / EV_PAUSE_YUNO_ACK with those, with none and failed: the agent lives, one WARNING “ack not from a yuno: dropped”, no “hs_yuno NULL” or “gobj NULL” (7.30.26: SIGSEGV). A session sends command-yuno, and then stats-yuno and authzs-yuno, and leaves before the yuno answers. Another takes its input-N and sends it too: it gets only its own answer, and the log holds “requester gone before its answer” three times (7.30.26: it got both). The yuno answers to authz, a service that is no requester: one WARNING “requester of the answer not found: dropped”. Last, a session watches the yuno again, and with the watch armed the client sends the agent a SIGINT: the yuno gets publish-stats with stop, no ERROR “hgobj NULL or DESTROYED” (7.30.26: that ERROR with a stack, and the yuno was told nothing). A session sends 60 console events (EV_TTY_*) and the agent’s 9 requests as events (EV_EDIT_CONFIG, EV_READ_FILE...): one WARNING of each kind, no “named dict not found”, no “path MUST BE a json str”, no “Event NOT DEFINED” (7.30.26: an ERROR per frame). No “Event NOT DEFINED”, and the agent ends in order with no “system memory not free”. Skipped (77) without the agent or logcenter binary, ip or unprivileged namespaces. The agent’s requests by their commands (read-file, read-json, running-keys, running-bin) are answered with their own event. A real console (cat) opened by one session and joined by another: both get its open, its output and its close (7.30.26: neither, an ERROR “Event NOT DEFINED in state” per frame). A console goes with the session that opened it (7.30.26: never closed).
test_c_agent_consolesThe real agent (its build dir) in the namespaces of test_c_agent_sandbox, with ulimit -v 4000000 (none for an ASan build) and no core. The clients are websocket clients written by hand on 1991, and outputs/yunos/logcenter is a yuno registered and never run. 1: a session opens yes and does not read: the console pauses for it and the route is taken off at console_pause_timeout (5 s in its agent.json). The agent’s VmRSS grows less than 160 MB, and it lives (7.30.26: about 50 MB/s until “REACHED MAX_SYSTEM_MEMORY”). 2: a reading opener and a joiner that does not read. The console prints 3,000,000 numbered lines (30 MB): the joiner is taken off within its deadline, and the reader gets all of them in order. 3: a joiner leaves: the console lives and the opener gets its output. The opener leaves: the joined session gets EV_TTY_CLOSE (7.30.26: the joiner closed it, telling nobody). 4: a session with the card of the registered yuno opens a console that writes and watches the yuno, and drops its connection: the console is gone, and the next session, holding the same channel, gets neither its output nor the watch’s readings (7.30.26: it got the output, and an INFO per chunk). 5: a reader with a 64 KB window at ~1 MB/s gets all 11 MB of a fast seq and is not taken off. No “Event NOT DEFINED”, and the agent ends in order with no “system memory not free”. Skipped (77) without the agent or logcenter binary, ip or unprivileged namespaces. Round 94: case 1’s opener alone does not read for 12 s, past two console_pause_timeout of 5 s: the console stays paused (memory flat), goes on when it reads (>20 MB, no close), and goes when the session leaves. Case 6: an opener that does not read beside a joiner that reads is taken off and the console closed. The joiner gets EV_TTY_CLOSE. Round 95: 7: a session joins the console of a reader away 2.5-3 s before that reader’s deadline. The console lives past the deadline, and the reader is taken off ~5 s after the join, not at the deadline (before: at it, ~3 s). 8: a request padded with 1 MB (a key of its own in __md_iev__, and the host of its hop), not read for 6 s: the agent grows < 25 MB, and with the key of its own the frames are ~2 KB (before: +120 MB, 1 MB frames).
test_c_ycommand_request_answersycommand (its build dir) against a python peer on 127.0.0.1:1991, in namespaces of its own (user, mount, network, with uid 0 = yuneta), with HOME in a work dir. An EV_READ_BINARY_FILE, an EV_READ_FILE and an EV_EDIT_CONFIG nobody asked are not written in ~/.yuneta/configs/, three WARNINGs “answer of a request this ycommand did not make, ignored” (7.30.26: written). The answer of read-binary-file is written, mode 0600 (7.30.26: 0700), and so is the answer of a command-agent cmd2agent='read-binary-file …'. A second answer after it is not. A refused request leaves nothing pending. Skipped (77) without the binary, ip or namespaces. The peer answers a request sent straight to it only with the request’s event, as the agent does (through a control center, “Command sent to 1 nodes” first). Case 5: -c "read-binary-file …; help" writes the file, runs help and ends by itself, and so does the request alone (7.30.26: neither). help cmd=read-file; help is no request. A link in ~/.yuneta/configs/ is not followed. Interactive (-i, in a pty), a request refused with no data while the warm-up (list-gobj-commands) is pending still spends its slot. A binary file that cannot be written gives an exit code that is not 0 and stops the line. A request the agent refuses after a control center sent it leaves nothing pending. A content64 not base64 or not a string is a WARNING, exit code not 0. A text and a json are written 0600, not through a link, and a failed write does not open the editor (exit code not 0).
test_c_ycli_request_answersycli (its build dir) in a pty, without ncurses, against a peer in python, in namespaces of its own (as test_c_ycommand_request_answers): three answers of the agent’s own requests sent unasked are not written (three WARNINGs). An asked read-binary-file is written 0600, one answer per request, also through command-agent. A request refused at once, or whose connection ends, leaves nothing pending. A request refused with an answer without data while the connection’s warm-up (list-gobj-commands) is pending still spends its slot. Up to 7.30.26 ycli wrote any of them (0700). help cmd=read-file is no request (an unasked answer with the next help is not written). A link left in ~/.yuneta/configs/ under the file’s name is not followed, and the failure is logged. A content64 not base64 or not a string is a WARNING and nothing is saved. A text and a json are written 0600, not through a link, and a failed write does not open the editor.
test_c_agent22_write_ttyThe real agent22 (its build dir) in namespaces of its own (tmpfs /yuneta with throwaway certificates, an /etc/hosts for the control center’s name, ulimit -v 4000000 (none for an ASan build), no core), linked to a control center written in python (TLS pinned to certs/controlcenter.crt, tcp4h, ievents). The control center sends write-tty name=nosuch content64=YQ==, name=yuno, name=agent22, write-tty name=nosuch without content64, then help: the first three are answered EV_TTY_CLOSE with their name, the link stays (help answered), and the log holds one WARNING “console not found”, two “not a console”, one “content64 required” and no ERROR (7.30.26: an ERROR and EV_DROP of the link at the first line). The agent ends in order (exit 0) with no “system memory not free”. About 11 s. Skipped (77) without the agent22 binary, unprivileged namespaces, ip or openssl. A console of yes with the link not read for 8 s keeps agent22 flat (7.30.26: +300 MB) and goes on when the link is read, and close-console closes it. The link’s principal controlcenter is root in the test’s json. FLOODPAD md / FLOODPAD hop (the request padded with 1 MB): agent22 grows < 25 MB, and frames are ~2 KB without the padding of its own (before: +250 MB, 1 MB frames). Timeout 240 s.
test_c_agent22_install_packageThe real agent22 in the sandbox of test_c_agent22_write_tty, with a tmpfs on /var/lib, a directory of the test on /usr/libexec/yuneta, and stubs on sudo, systemd-run, systemctl and journalctl. The root program is the real packages/templates/install-package. With no program, install-package is refused, says that the package has no /usr/libexec/yuneta/install-package, and writes nothing. With it, agent22 writes only url and sha256, the unit runs /usr/libexec/yuneta/install-package run with no URL on its command line, and the data is in /var/lib/yuneta/install-package (0755, root). An http:// URL, and one with a curl pattern ([1-1000000000]), are refused by agent22 itself. install-package-status reads the result of root’s directory, and the one that an older agent22 left. Up to 7.31.29 agent22 wrote the script that root ran into /yuneta. About 15 s. Skipped (77) without the binary, namespaces, ip, openssl, curl, or a package manager. Timeout 150 s.
test_c_controlcenter_scenariosThe control center’s scenarios, on its own source (c_controlcenter.c), between a __top_side__ of fake web clients and an __input_side__ with one agent connected (a real C_IEVENT_SRV in session, answered as the agent does). Freed memory is poisoned and held in a quarantine, so a read after a free reads the poison: save-scenario with the scenario as a string answers with its id (up to 7.25.20 the id was read from the parsed json after it was freed). A step parameter that starts with __ (__md_iev__, __username__) is refused by the save, and a scenario written without the step checks (as 7.25.14 saved it) is refused by run-scenario naming the step, with nothing sent to the agent. A step’s answer counts only from the agent of the step: the marks of a step (cc_run, cc_step) that another client puts in a command-agent do not reach the agent, and an answer a client injects is dropped with a warning (up to 7.25.20 the answer through command-agent ended the run). What an agent sends back (the answers of command-agent and stats-agent, the PTY of open-console) reaches a channel only while it holds the connection that asked (up to 7.25.20 all of it reached the next client of a closed channel’s name), and the agent’s close drops the client of its console mirror only if it is still that connection. A web client that injects any of those events itself, routed to another client, reaches nobody (up to 7.25.20 all six kinds were delivered). Several consoles mirrored through one agent’s channel each drop their client when the agent goes, a console opened again belongs to its last client, and closing one console forgets only it (up to 7.25.20 one slot per agent channel). The switch of a yuno (7.28.6): a switch without its off is refused, on is refused while the scenario does not run, runs its steps, in order, to its own yuno, off sends them at once, and neither changes the state of the scenario. Each request for the agent carries an operator assertion (operator_assertion_key), verified with the public key for its node, its sub and its 60 s, and none when nobody asks. The key of a node: a node never seen is recorded pending, accept-node pins its key, and with enforce_node_keys another key, a pending node and a refused node are dropped, while an agent with no key is let in. Cases 23-31: a node is reached by its uuid, and by a hostname only when one node record has it (an agent that gives another node’s hostname, or its uuid as hostname, takes neither its commands nor its keyboard. write-tty goes to one agent, and to none without agent_id). One key, one node. The card of an agent not authenticated yet is checked. A refused node is said refused. An open with nothing changed writes nothing. A decision drops the sessions it no longer lets in. logout-user asks its permission and passes disabled only when given. A hostname cannot be planted, nor taken by a card id that is another node’s hostname. drop-agent names a node as command-agent does. All red on 7.30.14. Cases 32-36 (7.30.16): a refused or keyless open leaves no name behind and a pending node’s name is not taken through its record. The key login wins over a token impostor and a token session’s card is checked (id, host, knows_operator_assertion by type). A scenario on an ambiguous name is refused at start and its stop does what it reaches. The max_run stop on an ambiguous name is tried again in a minute. Case 22b (7.31.15): the node enrollment: open-enrollment/close-enrollment need manage-nodes and refuse minutes out of 1-60 and max_nodes out of 1-256. While it is open, a node that knocked with the same key and a node never seen are accepted by themselves (decided_by: enrollment:alice) and log in by the key. A node accepted with another key, a node let in with no key, a uuid that knocked with two keys (also after a flood of knocks: a full table evicts it last, while such uuids are half the table at most. One evicted all the same closes an open enrollment, and none opens for an hour) and a key accepted for another node are not. It closes at its max_nodes, with close-enrollment and when its timer fires. list-nodes says it is open. Case 27: a reopen from a new port writes nothing. Case 37: accept-node of a node that was not accepted empties the hostname and address a session of a token wrote. Case 38: a max_run stop that did some steps tries only the rest again until each is done. Case 39: commands and stats with a peer’s __gbuffer___, with and without permission, release nothing twice (up to 7.30.16 the gbuffer was freed while held). Cases 40-44: a refused write-tty frees its kw once and is answered EV_MT_COMMAND_ANSWER. A write-tty, a command-agent and a stats-agent (no assertion key) with a gbuffer keep only the caller’s reference. A writer without run-scenarios cannot save or delete a scenario whose max_run stop is due. The rest of a stop runs only the steps that the scenario still has. A stop step answered “Yuno not found” is done. The stop is not tried again after 10 fruitless tries in a row (9 of them written into the treedb by the test). Case 45: gobj_command() and gobj_stats() on a C_IEVENT_SRV and on a C_IEVENT_CLI in session, given a kw_incref() of a caller’s kw with a gbuffer, leave that kw as it was: its refcount is 1, its gbuffer is held only by it, and the audit finds no leak. Case 46: a max_run stop that cannot start counts its attempts towards the same 10 tries, then stops with one warning. The test takes about 35 s. Case 42: a max_run stop answered Yuno not found is tried again in a minute (it was done in 7.30.18). Case 43: scenarios says stop_given_up. The writer cannot save it. A save by a user who is allowed to run tries the stop again. Case 4’s injected answer is a frame written by hand with "__temp__": [0x41414141], decoded as __top_side__ decodes it (up to 7.30.26: SIGSEGV in is_from_agent_side()). Case 47: the agent’s link closing (its transport in ST_DISCONNECTED): command-agent and stats-agent -1 “…not in session: Command sent to 0 nodes”, the start (in order) and the stop (at once) of a scenario of two yunos end at once with each step -1 naming the link, write-tty answered EV_MT_COMMAND_ANSWER -1, nothing reaches the agent, six WARNINGs “Not in session” (7.30.26: “Command sent to 1 nodes”, a run in flight until run_step_timeout, keystrokes lost). Case 15: the source of the store events is a treedb_authzs service. The same EV_TREEDB_NODE_UPDATED of roles sent three times by another gobj publishes nothing, ONE WARNING “event of the users store not sent by the store, ignored” (7.30.26: every client asked my-permissions again). Case 48: the answers of the agent’s own requests (EV_READ_FILE, EV_READ_JSON, EV_READ_BINARY_FILE, EV_EDIT_CONFIG, EV_VIEW_CONFIG, EV_EDIT_YUNO_CONFIG, EV_VIEW_YUNO_CONFIG) are public and reach the client that asked by command-agent (7.30.26: refused at the agent’s channel). Case 6 injects EV_READ_FILE from a web client too, dropped as the other events of an agent. Case 49: the answers of an agent (the seven above, EV_MT_COMMAND_ANSWER, EV_MT_STATS_ANSWER) reach only a client that asked THAT agent in its current connection with that stamp. 27 forged (to another client with its own stamp, with none, and to the asker with none) reach nobody: one WARNING, 26 counted at window end. The legit answer still arrives (7.30.26: relayed to any web client). Case 50: a client at client_max_tx_queue is dropped once (one WARNING), gets nothing more, and gets the output once it reconnects. Round 94: case 49 also covers EV_TTY_OPEN/DATA/CLOSE and EV_YUNO_STATS (39 forged, 38 counted). 51: a client holding 4 MB (client_max_tx_bytes set from its 32 MB default) gets 4 answers of 1 MB, then one EV_DROP and nothing more. 52: an answer for a client that left is an INFO “requester gone”, not the WARNING of 49. 53: an EV_TTY_OPEN for a client that left records no mirror, and the agent’s close does not drop the next client of the channel. Round 95: case 49’s window ends with 43. 54: what an agent streams reaches a client only for what it asked THAT agent. A second agent, asked only help, sends with that route and stamp the output and the close of the first agent’s console, the open of a console nobody opened and a reading of no watch: none reaches the client, no mirror is recorded, and its close drops nobody. Consoles on two nodes from one client, a console opened by its name in the line, a watch, and a console opened again after the client reconnects still work (7.30.26: the forged output and close reached the other console, the open planted a mirror and its close dropped the client). Round 96: case 49’s window ends with 46. 55: what a client asks an agent to open lives only while it can be used: 80 opens not answered, 64 go and the rest are refused by the control center. Refused by the agent, closed, or the client gone, none is kept. 2000 opens refused one by one keep the memory flat. A name longer than NAME_MAX is refused. A reading reaches the client with the monitor_node it wrote in its watch of that agent. A link gets that agent’s answer and no stream (7.30.26: every name kept until the agent’s channel closed, the agent’s monitor_node relayed, any stream to a link).

Source: tests/c/c_subscriptions/, tests/c/c_node_link_events/, tests/c/c_node_initial_load/, tests/c/tr_treedb_link_events/, tests/c/tr_treedb_failed_save/, tests/c/c_node_failed_save/, tests/c/c_subscription_authz/, tests/c/c_ievent_srv_peer_subs/, tests/c/c_ievent_srv_identity_card/, tests/c/c_ievent_cli_peer_faults/, tests/c/c_ievent_cli_operator/, tests/c/c_ievent_cli_play_pause/, tests/c/c_ievent_srv_transport_events/, tests/c/c_agent_find_new_yunos/, tests/c/c_agent_sandbox/, tests/c/c_agent_command_loop/, tests/c/c_agent_peer_close/, tests/c/c_agent_controlcenter_link/, tests/c/c_agent_answer_routing/, tests/c/c_agent22_write_tty/, tests/c/c_agent22_install_package/, tests/c/c_controlcenter_scenarios/, tests/c/c_node_authz/, tests/c/c_node_paged_nodes/, tests/c/c_tranger/

Timeranger2 persistence

BinaryDescription
test_tranger_startupDatabase initialization and startup. A master that finds __timeranger2__.json empty (0 bytes) makes it again, with a WARNING (up to 7.30.18: bad json at every open). The empty case runs in mode 0660 and in mode 0440 (up to 7.30.19 the 0440 one failed with EACCES).
test_topic_pkey_integerOpen topic as master, manage runtime lists, append records with integer keys.
test_topic_pkey_integer_iteratorIterator without callbacks over integer-key data.
test_topic_pkey_integer_iterator2Iterator with per-key callbacks and time-based matching.
test_topic_pkey_integer_iterator3Absolute-position searches.
test_topic_pkey_integer_iterator4Relative-position searches.
test_topic_pkey_integer_iterator5Paginated searches.
test_topic_pkey_integer_iterator6Master/client iterator mode with realtime record additions.
test_testingTesting utilities (event counters, assertions).
test_delete_instancetranger2_delete_instance(): iterators skip a dead row, also after a cold reload. It also checks the zero wipe of the content.
test_delete_key_propagationtranger2_delete_key() and who hears it (rt_mem and rt_disk feeds, a real follower). A key directory that cannot be moved out of keys/ is not deleted nor announced, keeps its rows and its filtered iterators. One moved out that cannot be emptied is deleted all the same, announced once, and the directory left is swept at the master’s next open. A key directory whose stat() fails with EIO is not “not found”: -1, nothing deleted or announced. A disks/ whose opendir() or readdir() fails is logged (by --wrap=stat,opendir,readdir). A feed opened after another heard a delete, and a second delete of a key heard first by a feed opened in flight, are each told once, by the delete sequence in the signal’s name (.d<seq>.<key>). A key too long for the name (.h<seq>.<sha256>) is told to each of two feeds. After every feed heard, nothing of the deletes is kept. The record delete_seq.json: made at the master’s open, the sequence written before the key leaves keys/ (read from inside the rename() that moves it out), kept taken by a delete that fails (never given back), a record that cannot be written refusing the delete, a signal left by the master heard at its next open (an older one removed unheard), an unreadable record refusing the delete, a follower with no record saying so.
test_rt_disk_multi_feedSeveral rt_disk feeds on one key of a follower: each wake-up serves only the feed whose directory fired. Callbacks that close their feed, with two records of a new key in one batch: the feed that fired is fed once (up to 7.31.29 the next record read it freed: SIGSEGV), and a mem list after one closed in its callback gets both records (up to 7.31.29 it missed the first). A mem list that closes the feed that fired stops it too. A list opened by a callback at the second record of a batch of two gets both records (up to 7.31.29 only the second). 2000 mem lists and a batch of 300 records take less than 400 ms.
test_rt_disk_emfileA follower that runs out of descriptors (EMFILE) while it reads new key directories: the reads that fail are owed, and the next batch of events of the feed (a record of another key) reads them. Every key ends level with the master (up to 7.27.6 they stayed behind for good).
test_out_of_order_appendAn append whose __t__ belongs to an earlier file of the key goes into that file’s cell. Every record is served once.
test_pkey_path_traversalA string primary key is one directory component: a key with / or a leading . is refused.
test_topic_path_traversalA topic name is one directory component: ., .., a / or a ` is refused, and a replica cannot delete or back up a topic.
test_read_never_exitsA failed READ never ends the process, whatever on_critical_error says.
test_iterator_indexThe id index of a topic’s iterators: found by (id, creator), a closed one is not, a duplicate is refused.
test_date_bound_unitsA date in from_t/to_t is taken to milliseconds on an sf_t_ms topic, and one in from_tm/to_tm on an sf_tm_ms topic. A day by t and by tm selects that day on a topic with t in ms and tm in seconds, and on the reverse. Up to 7.27.4 the t bounds asked sf_tm_ms. An end bound takes its whole second (23:59:59.500 is in the day). tr2list -m table -f, tr2list --filter and tr2search -f list a record with a top-level "gbuffer" key (up to 7.30.17 each tool crashed). tr2list --rkey='a(*COMMIT)b' prints why and exits 1, on a topic and with -r over the database. tr2keys --rkey is judged as tr2list’s: ^dev- lists dev-1 and dev-2, a(*COMMIT)b and (*UTF)dev print why and exit 1, and --key looks up the key.
test_delete_key_filesRetention, the master: tranger2_delete_key_files() deletes the old files of a key and the records left keep their g_rowid. The next append gets the next one, and a reopen says the same. The rowid bounds of a match_cond (0, a rowid of the purged rows, the base, -1, more rows back than the key has, past the end) and the positions of a page count from the base. Iterators opened before the purge, filtered or not, page what is left. An append into a purged period is refused. A cut in the future and a mask with no year ("queue", %m-%d) are refused. The hard link a dead feed left goes with its file, and one that cannot be removed keeps the files of the period until the next open of the master removes both. A key purged whole keeps its base and goes on numbering. A purge cut by a crash (a .purged written by hand over the files) is skipped by a replica and finished by the master’s open. A .purged.new left is removed. A .purged that is not json flags the key unlisted (load_failed, purge and append refused) until it is put right. tranger2_delete_key() takes the base with the key (a failed delete of a key purged whole, or of a key whose directory cannot be moved out of keys/, keeps it). Pages across a purge keep their positions, filtered or not, and the size counts them (a key purged whole too). tranger2_mask_sorts_as_time() on 38 masks, and a treedb topic refused. A delete of a key with a base that cannot move its directory keeps the key, and a good one leaves no directory aside. A filtered iterator opened with a negative rowid bound (from_rowid -4, -5..-2) keeps its rows when the key grows and its old files are then purged.
test_archive_key_filesRetention that keeps what it takes: tranger2_archive_key_files() hard-links the files a purge takes into a batch with the schema of the topic and a manifest (rows, first_g_rowid, last_g_rowid). The topic is numbered as after a delete. A second purge makes a second batch that starts after the first. The guards (no directory, relative, missing, a file, inside the tranger or holding it, another filesystem, a batch name taken) delete nothing. Each batch has its ready mark. A base that cannot be written removes the batch and leaves no mark. A .new-* left by a crash is removed. A replica and a reopened master read the base.
test_delete_key_files_followerRetention, the followers: a follower with an rt_disk feed hears .p.<key> and drops the cells of the files purged, takes the base, and its feed goes on with the master’s g_rowid. A key too long for the name is signaled .q.<sha256>. A follower with no feed hears nothing and finds the purge before its next load or page, also for an iterator opened before it. A file the follower flagged unreadable and the master purged is no flag for ever. A signal left in a feed directory does not stop the next one. A feed callback reading its key while a purge waits does not apply it under the cell of the new records. A filtered pager opened over a flag pages the master’s numbering once the purge drops it. A base the follower cannot read while the master appends: the feed gets the master’s g_rowid, the live rows are read while it waits, and the base is applied when it can be read. A filtered pager of the follower with a negative rowid bound keeps its rows across appends and a purge. The purge that renumbers a flagged follower says so with a WARNING, and its filtered pagers with rowid bounds, negative (-3..-1) and positive (4..6), keep the same rows, renumbered.
test_purge_replica_readsRetention, a replica that reads at a bad moment (--wrap=fopen,--wrap=open): a base it fails to read with EMFILE is read again at the next load, one it fails to read with EACCES is not read again at every load. The master purges a key between the replica’s listing and its open of a md2 file, and the replica numbers the key as the master, with no flag.
test_late_recordA record whose __t__ is below the times of its md2 file is served by a time-range query.
test_stop_reopenA tranger stopped and used again: no fd closed twice, a topic opened again revives it.
test_append_md_contracttranger2_append_record() drops a __md_tranger__ the record carries in, and returns the new metadata in the out-param.
test_str2system_flagEvery name of tranger2_str2system_flag() maps to its own bit.
test_tm_orderA __tm__ that does not grow with __t__: a tm condition filters every row (no file left out, no early end). Negative bounds, relative to the key’s last record (its tm, not the highest one) and to each key’s own in a list of several keys. A store with the old tm markers (7.25.5..7.25.22) answers the same.
test_lost_lockA master that lost its lock while stopped writes nothing. It takes the lock again or goes on as a replica.
test_topic_var_replacetopic_var.json is replaced through a .new file and a rename, never truncated.
test_key_reborn_pagesAn iterator open while its key is deleted and written again forgets the old segments.
test_open_list_historyA keyless tranger2_open_list() names a key that does not load in load_failed_keys and goes on. A cheap rkey (.) over a history that takes 2.1 s to read (21 keys, 100 ms a record in the callback) loads every key: the 2 s of the load count the judgements only.
test_unreadable_at_openA store damaged before the start: the key is flagged at the cache build, and every load says load_failed.
test_uncommitted_appendAn append whose md2 row is never written: ignored with a warning, cut back, a short write logged as such.
test_torn_md2_tailAn md2 that ends in a part of a row: cut back by a master, read whole by a replica. The shape 7.25.4 left after a torn row is flagged, not cut.
test_md2_short_writeAn md2 row written short whose cut back fails: the append is refused, and the next one cuts and goes in.
test_md2_read_errorA read of the first or last md2 row fails at the cache build: the file is flagged until it reads again.
test_nul_escape_recordA record whose string holds NUL characters is read back, also after a restart.
test_torn_tail_check_failsA check of a torn tail that cannot RUN refuses the append and does not flag the file. Records larger than the reader’s memory block are flagged, not cut.
test_cmp_file_idscmp_file_ids() orders two md2 file ids as their names sort, for fixed cases and 2 000 000 random pairs.
test_unlistable_dirsA key directory or keys/ that cannot be listed: the key is flagged, the topic does not open, and both recover once the directory can be listed.
test_unlisted_relist_onceA key directory whose readdir() fails is flagged once, and listed again only when it changes.
test_tr_dt_unknownA topic on a filesystem whose readdir() gives no d_type: the keys are found with lstat() in keys/, and the cache is whole. A key whose lstat() fails with EIO fails the listing, and the topic does not open (by --wrap=lstat). A symbolic link in keys/ is not a key, with d_type or without it. A key directory of mode r-- is flagged unreadable the same way without d_type as with it (up to 7.25.4, without d_type, it loaded EMPTY, with no log).

| test_archive_shipping | The archive of tranger2_archive_key_files() shipped by the yunos archive_sender and archive_keeper, in one process. Native, over tcp://127.0.0.1:7755: two batches found by the scan when the sender plays, a third told by its ready mark, and a fourth the keeper already has (shipped again, and answered stored at its end: the keeper hashes the batch it has, and the content is the same). rsync, to a local directory, with max_archive_bytes of one batch and two waiting: the oldest is removed unshipped (a WARNING), the other arrives with its manifest. Every batch that arrives is whole, and no batch nor mark is left in the archives. A batch of the same name planted in the backup first, with the same files and sizes and other bytes, is refused (its sha256 are not of the batch that arrived) and kept untouched, and the sender keeps its own. The link is mutual TLS (tcps://, a CA and certificates made by the test with openssl): a sender with the client certificate of another node, and one without a certificate, both naming the node, are refused, and keep their batch. | | test_archive_shipping2 | archive_keeper against a fake archive_sender: the driver writes the frames of the native transport by hand over tcp://127.0.0.1:7758 and checks each answer in order. Refused: an end whose sha256 is not of the bytes that arrived, one with fewer sha256 than files, one not in lowercase hex, data of a file before the files before it are whole (a frame of that batch already on its way is answered, and not counted again), an empty batch, and a batch of the name of one kept with the same files and sizes, other bytes and their own right sha256 (the kept batch untouched). Stored: a good batch, and the same again as already here. Over a second link: a batch in flight on the first is refused to it and stored with the first link’s bytes (up to 7.29.1 the first link was answered stored with an empty file), and a batch whose link went silent for stale_session_timeout is taken over by the other link. A link silent for stale_session_timeout whose batch declared 3/4 of the free space is dropped at the begin of another batch, and its reserved space is free again (up to 7.29.2 it was reserved for ever, and every begin was “does not fit”). A refused batch leaves nothing in the backup, nor its copy aside. The test fails without the check of the sha256. |

Source: tests/c/timeranger2/, tests/c/tr_dt_unknown/, tests/c/archive_shipping/. Each case of the timeranger2 tests is described in tests/c/timeranger2/README.md.

TR_MSG & TR_QUEUE

BinaryDescription
test_tr_msg1Message topics: iteration, key matching, instance retrieval.
test_tr_msg2Stress variant: 1 000 devices × 100 traces.
test_tr_queue1Queue topic: enqueue / dequeue with time-based keys over a multi-day period.
test_tr_queue_backup_failedA backup that fails (the backup name taken by a file): trq_check_backup() / tr2q_check_backup() answer -1, the queue keeps its topic, and appends, reads and acks work after it. Nothing leaks. And a backup whose new topic cannot be created after the move (its mkdir fails, ENOSPC): the backup is moved back, the queue keeps its topic whole, and the next call backs it up. A create that fails only at the mkdir of its keys/ answers NULL and leaves nothing, and a backup that meets it keeps the queue’s topic. A backup that fails and cannot open the topic again (topic_desc.json of mode 0 for a moment): the queue has no topic, a read and an ack fail (said once), and the queue takes its topic again by name as soon as it can be opened, and backs up at the next call (tr_queue and tr2q). While the topic still cannot be opened, the next calls log nothing. The same when what stopped the open is outside topic_desc.json (keys/ of mode 0): said once, and the topic is taken again once keys/ can be listed, or as the tranger has it open again. And a tranger with on_critical_error LOG_OPT_EXIT_ZERO (the broker’s queues): a backup whose create fails does not exit, and moves the backup back. A plain create whose keys/ cannot be made exits (in a child process) only after it removed what it made, and the next create makes the topic whole. The CRITICAL “Cannot create TimeRanger subdir. mkrdir() FAILED” names the real cause (“No space left on device”, not “Success”).
test_tr_queue_load_failedA queue (tr_queue and the mqtt tr2q) whose load cannot read every pending message: the load returns -1, first_rowid is kept, and the backup is refused until a load reads them all.
test_tr2q_queuedThe queued messages of an mqtt queue: one whose content cannot be read stays queued (tr2q_move_from_queued_to_inflight() answers -1), and tr2q_check_backup() does not back up while a message is queued. A row with a top-level "gbuffer" key, in flight and queued, is dropped with a WARNING and rebuilt from its "payload", the rows loaded with verbose on (up to 7.30.17 the queued load crashed, and the one in flight carried the integer as its gbuffer).
test_pkey2_emptymsg2db_append_message() refuses a record whose pkey2 is empty and writes nothing.
test_msg2db_load_failedAn id whose history did not load whole: reloaded newest first up to the damage. A pkey2 whose newest message is in the damage is absent (msg2db_id_incomplete()), never an older message.
test_msg2db_topics_left_outA topic msg2db_open_db() leaves out (a name that breaks the name rule, no pkey2) is said once and gets no list and no index, also when the tranger had it open before (up to 7.26.9 it got both, without a word).
test_msg2db_column_defaultA message does not spend the default of a column: twenty messages carrying every field log nothing and leave the schema’s defaults (a string, an integer, a boolean, persistent and volatile) unchanged. A message without the volatile fields gets their defaults, also at the reload (up to 7.28.7 the first message that carried a field freed its default, and every one after it logged “BAD json_decref()”).

Source: tests/c/tr_msg/, tests/c/tr_queue/, tests/c/tr_msg2db/

The emailsender and webstats yunos

The gclasses of these two yunos are compiled into their tests. Each directory’s README.md describes every binary. The rows here are the ones about a json that the yuno reads back from its store.

BinaryDescription
emailsender/queued_gbuffer_keyAn email of a queue written before 7.4.4, with the pointer of its body kept under "gbuffer", waits at the start: it is delivered and released as a json, no ERROR (SIGSEGV at the first send up to 7.30.17).
webstats/report_readyThe report a run publishes is the report of the day: with the access log emptied, a second run reads nothing, keeps the stored day and publishes it (up to 7.25.20 it published the empty one it had read). Between the two runs the day is stored again with a top-level "gbuffer": the second run drops it with a WARNING and publishes the day (SIGSEGV up to 7.30.17).

Source: tests/c/emailsender/, tests/c/webstats/

The sgateway yuno

The real binary (outputs/yunos/sgateway, built by yunetas build), run by a python driver that is the peer of both of its sides.

BinaryDescription
test_sgatewayTwo runs of the real binary. A listener of the driver is the output target and a client of the driver connects to the input port. First run (C_SGATEWAY connections trace on): bytes both ways. One output connection per client (the client goes away and its output connection is closed, and a second client gets an output connection of its own and nothing of the first). The output peer drops and its client is dropped. 8 MB each way against a peer that reads slowly arrive whole and in order. Against an output peer that never reads, the gateway does not grow (its RSS) and, when that peer goes, the client is dropped. Second run (default traces, a TLS output with crypto): 20 clients relay through TLS, each with its own output connection, and the log does not grow with them. Each run ends with SIGINT, exit code 0, and a log with no ERROR, no WARNING, no “Event NOT DEFINED” and no “system memory not free”. Up to 7.30.17 the gateway ran nothing. In 7.30.18 it relayed the read buffer itself (the 8 MB arrived short or corrupted, one ERROR per message), shared its output connection between clients, refused a TLS output (“TLS client refused”, once a second) and logged every connection. Skipped (77) when the binary is not there. Three more steps: a client that leaves while its output cannot connect (what it sent is delivered when the output opens, then the output is closed), an orderly stop with a client that does not read (no output connection opens, the log is clean, red on 7.30.19), and the TLS run has a tcps:// input (input_crypto) as well as its TLS output (red on 7.30.19: the yuno exited before listening).

Source: tests/c/sgateway/

TreeDB

BinaryDescription
test_tr_treedbSchema creation, user/department/compound structures, node CRUD, and state snapshots (foto files).
test_tr_treedb_delete_instanceInstances of a pkey2 key, each scenario in its own database with a reopen: treedb_delete_instance() and a tombstone that fails. A delete of a parent sees the children of every instance, a delete of a child unhooks every instance, a deleted instance leaves the hooks of its parents (the primary takes its place) and hands its children to the primary, a refused forced delete puts every instance back, a save of a node no index holds is refused, and after a reopen the instance of the primary IS the primary node (an update through it lands, and survives the next save of the primary). A save of a node whose pkey2 value changed in place is refused, and a create indexes a defaulted pkey2 by the value its record holds. The instances of a CHILD: an unlink clears the ref in every instance of the child key, a delete of a parent sees (without force) and clears (with it) the instances that name it and no hook holds, a forced delete leaves no ref in any instance, what those did is put back when the write does not go, and a relink of an instance its parent does not hold logs nothing. With a snap active, a key created after it (instances and no primary) is deleted quietly, and its create takes the slot. With two pkey2s, a save keeps the primary in its slot. The gc holds the asset an instance names. A forced delete, and a delete taken back, keep the newest record of each key they save on the instance that wrote it, so the primary of the next reload does not change. A relink through a dict hook over a string fkey leaves the sibling instance in the old parent’s hook. A snap shot that clones a tagged record writes the newest record of the key again after the clone.
test_tr_treedb_load_failedA topic whose keys cannot all be read: treedb loads the other keys, remembers the ones that failed, and refuses a create of such an id, and snapshot operations when __snaps__ did not load whole. The recovery, after the key is deleted, needs no reopen.
test_tr_treedb_failed_saveSee Subscriptions & link events.
test_tr_treedb_filesThe file column and __assets__: the bytes are not in the record, the id is the hash of the bytes (a client that lies is refused), and the index is in memory. A file column that is not fkey, or whose id holds a ^ (it is in the hook the column derives, as_<topic>_<col>: every link of a file failed), is refused before the topic exists.
test_tr_treedb_hook_hygieneHooks of a versioned (pkey2) parent: an unlink through the reverse hook, a link made twice kept once, a forced delete of a parent with many children.
test_tr_treedb_hook_renameA hook renamed in the parent’s schema: the child’s fkey mark is derived, never read from disk, so the links load under the new name. A ref that names the old hook, in an array or a STRING fkey column, is removed by a clean or a forced delete.
test_tr_treedb_immutableImmutable topics and records: a delete is refused, also with force, and the mark survives updates and a reload.
test_tr_treedb_relinkA link into a single-valued fkey replaces the old one, and the old parent’s hook forgets the child.
test_tr_treedb_rowidThe id a rowid topic hands out is never one that exists, also after deletes and updates.
test_tr_treedb_schema_parseparse_schema() of a column with no flag (it crashed), and the columns and keys treedb_create_topic() refuses before the topic exists: a column both hook and fkey, no id column, no columns, bad pkey2s (named twice, id, a backtick, the tkey: an ERROR, a WARNING inside the window of a peer’s data), a list id longer than NAME_MAX (an ERROR always, no directory on disk), a ^ in the name of the topic or of a hook and a pkey2 of no column, and a node id that is not a string. A column named gbuffer, the name of a kw’s binary field, is refused.
test_c_resource2_namesA persistent C_RESOURCE2 store refuses a name with /, a leading ., .. anywhere in it, or too long, with ONE warning and no file written (up to 7.30.16 three ERRORs per MQTT connect, and .hidden wrote clients/.hidden.json). A reload brings x, x.jsonz, victim and victim.json back as their own records, and loads no other.json.bak (up to 7.30.17 the name was cut at its first .json). A record with a top-level "gbuffer" key is saved, less its private keys, and returns from a reload as it was (SIGSEGV at the save up to 7.30.17). A .json of a subdirectory is no resource (loaded under its bare name up to 7.30.17).
test_tr_treedb_snaptreedb_shoot_snap(), treedb_activate_snap() and __clear__, and the primary promoted at the next reload.
test_tr_treedb_snap_cloneA record already tagged by a snap gets a clone for the new snap, and memory agrees with a reload.
test_tr_treedb_update_instanceAn update is seen through the pkey2 index at once (treedb_get_instance(), treedb_list_instances()). A NUL in the id or in a pkey2 value is refused by a create and by an update from C, with an ERROR, and nothing is written (“Invalid id or pkey2 value: it holds a NUL”). So is a NUL in an fkey reference, at the start or after its three parts, by a create and by treedb_update_node_and_links() (“Invalid fkey reference: it holds a NUL”. Up to 7.26.9 the create saved the part with no parent, or linked it to the parent C read).
test_c_assetsC_ASSETS: the asset id is the sha256 of its bytes, the same bytes are one asset, get-asset inline or as a signed url, orphans, import-assets, gc-assets and its refusal while a snap is active, the -403 of the authz gate. The bytes of the gbuffer door go into a record of the command’s own, and the sender’s record keeps no gbuffer.
test_c_treedb_system_schema__system__, the meta-treedb of C_TREEDB: the projection of a schema at open, save-schema, apply-schema, delete-treedb, and the warnings of a store that runs a topic ahead of its file. What a peer hands C_TREEDB is refused before anything is made, a WARNING each, and the same from C code an ERROR (Tests 13d2 to 13d7): a treedb_name of the wrong type, a treedb not open here, unknown and system topics to delete, topics of a wrong shape (no columns, a FILE of the store, .blobs, pkey2s, names too long for the lists of the indexes or for __system__, two file columns of one __assets__ hook), a filename_mask that is a path, names of the system (__system__), a peer’s treedb name that is hidden or a file of a store (.x, ..x, __x, x.json, x.bak), a peer’s schema whose id is not the name of its treedb, exit_on_error, import_root and impose_c_schema from a peer, one name per topic, values and versions of a wrong type, seeds without a string id, a store that is not the treedb’s or is held, delete-treedb of x/../<T>, and save-schema and apply-schema of a topic that the treedb itself refuses. A C caller’s open-treedb opens as before, a topic already on disk with bad pkey2s or a list id past NAME_MAX included (each fault an ERROR), and so does its create-topic. close-treedb force=1 from a peer only for a treedb that same user opened, and never, playing or paused (a real gobj_pause() that keeps the treedbs, as mqtt_broker does), for a treedb the C code opened. A peer’s open-treedb of a treedb the code opened and closed is refused. A peer’s topic that a msg2db of the store holds or names in its schema file is refused to create-topic, delete-topic and open-treedb, while a topic the treedb dropped returns with its records. Two main_topic marks, or one on a topic not hooked to itself. A peer’s save-schema past version 2147483647. A tkey date past 44 bits refused to create-node and update-node (and to C code), and appended cut, with an ERROR, by tranger2_append_record(). The seeds of an external open are WARNINGs at every start of their C_NODE. See its README.md.
test_treedb_schema_fidelityEvery real schema of the tree through __system__ and back: each attribute the literal declares returns with the same value.
test_c_treedb_literal_winsC_TREEDB: a schema from C newer than the schema file in use wins whole. __system__ is projected from it whole. The operator work it discards is reported once (withdrawn_at_open). An unfinished projection is recorded and completed at a later open, also after the process is killed at any write, once or twice. save-schema of a node of two parents (its place not written, places_not_written. Unshared again by an edit of the other parent, it is no draft of the parent that remains), of two topics of one name (refused, data.twins), and of a draft that shifts its siblings (one save publishes them all, and saved-schema’s draft_changed names them first). An open that installs a newer literal and does not open keeps the saved schema. A save after an edit of a topic an older release left publishes it whole, its id column included. The scenarios are listed in its README.md. ctest runs them in seven groups, each a test of its own in a store of its own (test_c_treedb_literal_wins/early, /late1, /late2, /dcd, /dcn, /o4, /o4xa, with --group=<name>), so ctest -j runs them at the same time.

Source: tests/c/tr_treedb/, tests/c/tr_treedb_delete_instance/, tests/c/tr_treedb_load_failed/, tests/c/c_treedb_literal_wins/, tests/c/tr_treedb_*/, tests/c/c_assets/, tests/c/c_treedb_system_schema/, tests/c/treedb_schema_fidelity/

gobj-c helpers and commands

BinaryDescription
test_helpersString, file and directory helpers: split2(), save_json_to_file(), rmrdir() / mkrdir() with links, deep trees and entries that vanish during the walk.
test_rotatoryrotatory_remove_old_files() and the rotatory log writer: size rotation, a full disk, a clock set back, a write that fails and the file opened again (no newfile callback for the same file), a keep_all size rotation whose rename fails (tried once, every record kept), a fixed name never emptied, an MM mask judged by its month. A new file whose open fails keeps its newfile callback for the next open that works (on a full disk too), the file of the day before is never size-rotated at a new name, and the keep_all rename retry runs on the monotonic clock (a wall clock set back or forward does not move it). The size limit is in bytes: a file of exactly the limit is not rotated, one 2 bytes over it is at the next record. exit_on_fail is for rotatory_open() only: with TRUE, a later open that fails (a new day, a removed file, the reopen after a failed write, a truncate) prints one line, is tried again at the next record and never exits (each case in a child process). The open itself still exits with TRUE, and returns NULL with FALSE.
test_audit_recordThe audit record builder of yuneta_agent: secrets redacted, content64 never written, the command word read as the parser reads it (COMMAND=list-yunos with a kw command=delete-yuno gets the full record), a secret inside a JSON text inside a JSON text redacted (up to 8 levels of escapes, and deeper is written as its size and sha256), whatever quotes come before it or cut it (x="{\"password\":…}", '{\"password\":…}', password=\"two words\"), and the credentials after Basic . Also handled: an escaped key with a blank or a slash (\"secret key\":), a quote inside a quoted secret (password="a\" S", the shell’s '\''), a JWT before a ., a write-attr whose names carry \u escapes or that comes as JSON text in a kw string. A deterministic fuzz of 20 000 generated commands (the secret in 24 quoting shapes among 17 kinds of noise, keys with blanks, slashes and \u escapes, write-attrs) writes no secret. What mask_secrets_inline() masks, the record does not write. It is the same function, mark_secrets_inline() (7.27.0+, and its own JWT was three parts exactly): a JWE, a JWT of two parts, a name: value, every word of a password with blanks, and 20 000 random texts. A masked run that ends a text of any length modulo 8 (the map of masked bytes is not read past its end, which AddressSanitizer caught). Hard shapes stay linear, under ASan too (up to 7.26.9 the search for attribute was quadratic there, see below). The routing of a peer (user, each hop of source, console_purpose, the console name of write-tty) is redacted like any other string, and a field of it longer than 1024 bytes is written as its size and sha256. A word with no key in a command line nested in another one (the command of command-yuno / command-agent, quoted or not, in the text or in kw.command, and the command the agent forwards, recognized by the wrapper’s line in its kw.__command__) is written <...>: 19 shapes (quotes, the shell’s '\'', \", base64 ending in = or ==, set-kc-config kc_realm=r <secret>, a wrapper in a wrapper) keep username=bob and lose the secret (7.30.26 wrote it). kill-yuno 3 nested is kill-yuno <...>, a keys-only nested line is written as it came, and a command that is not nested keeps its words. The command name of a nested line in its own quotes (command="'set-user-pwd username=bob <s>'", "'unlock'<s>", a backslash-escaped line), in the text, kw.command (full and read-only record) and the forwarded record, is <...> (7.30.26 wrote the secret), but "'list-yunos'" stays. (d4) a nested line its parser cuts otherwise than the shell (x=‘’'’ , x=‘’\‘’ y=6’ , "COMMAND-AGENT" command=‘kill-yuno ’, x=a’ ‘, x=‘a , x=‘a’, x=a\ ): from that word on the line is <...>, and the level above goes on after the value’s closing quote (7.30.26 wrote the secret). (d5) a word is judged by where the two cut it: a json without quotes of its own (record={“id”:“item1”} options={“force”:1}, filter={...}, with an id= after it, in a nested quoted line too) is written whole, its password redacted inside, and x=a’b too. A quoted piece with a blank in a json value (record={“note”:“a ”}, {‘note’:‘a ’}, a tab) makes the rest <...>. (d6) a word with the shell’s '\'' fails closed: update-node record='{'\''password'\'':'\''<s>'\''}' is update-node record=<...> (7.30.26 wrote ...:'<redacted>'<s>'\''}), the rest of the line with it (a word after it can be a secret by what it follows: note='it'\''s' Basic <s>), twelve shapes top level and nested lose the secret. password='it'\''s <s>' n=1 stays password='<redacted>' n=1, an escaped json (\" only) and a json without its own quotes (id= after it) are still written. (d7) the shell’s other ways to quote a quote, with no backslash, fail closed like '\'': a quoted piece closed and another opened right after it ('"'"', "'"'", '"'<s>'"', 'a''b') and a piece holding only a quote between unquoted bytes ({'"'password'"':'"'<s>'"'}): nineteen shapes, top level and nested, lose the secret, and update-node record='{'"'"'password'"'"':...}' is update-node record=<...> (7.30.26 wrote ...'<redacted>'"'<s>'"'"'}'). note="it's", {"id":"a'b"}, note="'", empty pieces and escaped quotes are written, and {"id":"'"} without quotes around the json is <...> (the cost). (d8) a secret’s key split by quotes, which the shell reads without them: p’a’ssword=, ‘p’assword=, p"a"ssword=, P"assw"o"rd"=‘a ’, j’w’t=, ‘{“p’a’ssword”:“”}’, ‘{“'p’assword”:"’’"}’, the json bare, a json key glued to its bytes ({“‘api_k"e"y’”:...}, “pa"ss"word”), nested, and content’64’=: the secret is not written (7.30.26 wrote it). p’a’ssword= is create-realm <...>, and the json key’s value is . a’b’=c, a json key “a’b’”, note=“it’s”, {“id”:“a’b”} and {“note”:“a=b”} are written. (d9) a key with quotes longer than 128 bytes fails closed: the big blocks the audit asks for, counted through gbmem’s allocators, are no more for x ‘<1 MiB>=1 and x a’<1 MiB>'=1 than for x <1 MiB>=1 (7.30.26: two more, a copy of the key, and 2.4 times the time). A plain key with quotes of 128 bytes is written, one of 129 bytes is <...>, and a json key of 203 bytes with a quote has its value . <200 a>p’a’ssword=, p’a’ssword<200 a>= and their json twins never write the secret.
test_sha256sha256_digest() / sha256_hex() and the incremental sha256_init() / sha256_update() / sha256_final() / sha256_final_hex(): the vectors of FIPS 180-4 (the empty input, "abc", the two messages of 56 and 112 bytes, a million a in parts of 1000), given whole and a byte at a time. Every length from 0 to 300 bytes cut in two at every place and in parts of 1 to 70 bytes gives the digest of the whole. A context initialized again starts from nothing. A buffer of 64 bytes is refused (logged), and a refused sha256_final_hex() leaves the context to a final that works.
test_os_infoget_os_info() with an /etc/os-release of the test (--wrap=fopen): each value is 64 bytes at most, cut at a whole UTF-8 character (a PRETTY_NAME of 70 bytes with a 2-byte character at byte 64 becomes 63 bytes). Up to 7.31.29 the values came whole.
test_build_pathbuild_path(): segments joined with one /, and a .. clamped at the root (no path escapes the base).
test_gbuffer_guardsA NULL gbuffer given to its pointer accessors answers NULL, not a crash, and so does config_gbuffer2json() of one (the agent’s create-config of a content64 that is not base64 was a SIGSEGV up to 7.26.9). Bytes from a peer that are not json are a warning (gbuf2json_from_peer(), anystring2json_from_peer()), never logged as they came (json_error_for_log() drops the bytes jansson quotes near the error). A json2gbuf() that cannot dump the json whole (a cycle, with or without a gbuffer of the caller, or a gbuffer too small) logs an ERROR and hands back the start (up to 7.28.7 it said nothing). drop_binary_keys() drops the keys and logs nothing (its count returned), next to drop_peer_binary_keys(), which warns.
test_glogger_utf8The logger never writes a record that is not valid UTF-8 JSON: an invalid byte is escaped as \u00XX, valid multibyte text stays readable.
test_trace_tabtab(), the indentation of a machine trace line, at a REAL depth (an action that sends the same event to its own gobj, 12 levels down): four spaces per level, one at depth 0, never more than bflen - 2, only spaces. A buffer of 1 or 0 bytes or NULL logs an error and is not written past its size (up to 7.28.7 it was overrun, and NULL crashed). trace_machine() at depth 12 carries the 48 spaces: it took the indentation through a 40-byte buffer, which capped it at 38.
test_command_authzThe per-command authz gate (SDF_AUTHZ_X): off by default, a command without the permission is refused -403 when on, a command to itself and a granted one run. The permission is asked BEFORE the parameters (a bad parameter without it is -403, with it -1), and the checker is asked for the command’s name, not its line.
test_authz_token_ageThe age of a login token (C_AUTHZ max_token_age, one hour). Logins with gobj_authenticate() from a peer of their own: alice issued a minute ago and bob 59 minutes ago open a session. Alice issued two hours ago (“The token is too old”) and alice with no iat (“The token has no iat”) are refused, ONE warning each. A user of token_age_exempt_users with a token of ten years opens a session. verify_jwt with no audience refuses the old token, without a log. _unlimited (max_token_age 0, the default): all good, no warning. In both, no log line carries a token.
test_authz_login / test_authz_login_no_peer_ipWho C_AUTHZ lets in at a login (gobj_authenticate() from a peer of its own address). With trust_peer_ip true (the default): yuneta with no token from 127.0.0.1 is in, a superuser. From 10.1.2.3 refused (“only localhost”). From an address of allowed_ips in. _no_peer_ip (trust_peer_ip false): the three refused, “Without JWT/passw the peer address is not trusted”, ONE warning each. In both: alice with a good token from 127.0.0.1 in. A token of another key refused, ONE warning. A good token with no email / no email_verified refused with a warning and no error. A token with no iss refused by the issuer’s key (“Invalid ‘iss’ claim”) with a warning. A jwks key of kid * (first in the config) refused at start up with ONE error, the only one, while the key after it still logs alice in. add-jwk kid=* answers -1 saying why, with no log. An expired token refused, and one expired and not valid yet names both claims (“Failed claims: exp, nbf”). No log line carries a token of the test nor the claims of the expired one (up to 7.30.14 the warning carried the token, the reader logged ERRORs and libjwt traced the claims). Case 13: remove-jwk kid=* answers -1 with no ERROR. Case 14: remove-jwk of a rotation of two keys removes both. Case 15: bob, created by create-user with a password, logs in by password: EV_AUTHZ_USER_LOGIN carries username, dst_service, user, session and services_roles and no jwt_payload (a token login, case 4, carries its payload), and the close’s EV_AUTHZ_USER_LOGOUT carries its session. Case 16: with max_sessions 1 a second login drops the first session (ONE EV_DROP, ONE warning) and the close of the dropped peer publishes LOGOUT with username and user and no session. Up to 7.30.26 both events had an EMPTY kw.
test_authz_store_full / test_authz_store_full_exitC_AUTHZ whose store refuses to write (a full disk, by RLIMIT_FSIZE): with on_critical_error 0 the logins go on, with ONE ERROR “Login history cannot be saved” and ONE INFO when it saves again. With the default, the yuno exits 0 at the login.
test_authz_store_corrupt / test_authz_store_empty_replica / test_authz_store_missing_replica (+ _exit of each) / test_authz_store_no_directoryAn authz store that is there and does not open at start up: a corrupt __timeranger2__.json in a master, an empty or missing one in a replica, and no store directory at all. With on_critical_error 0 (and without the directory) the yuno stays up in local access only mode, with ONE line that says so:
- yuneta logs in from 127.0.0.1 with no token, and a good JWT is refused.
- a C_TREEDB opens its treedb with an internal open-treedb, as the agent does.
- yuneta and the yuno itself have every permission, and alice has none, with ONE “Authz only to local access” each.
- an operator assertion of assertion_jwks verifies, and a login token at verify_jwt does not.
With the default the yuno exits with code 0 at start up (for the missing replica, with C_AUTHZ’s own line). Up to 7.30.19 the yuno exited (“tranger NULL”). In 7.30.20 every permission was refused (the agent exited at its open-treedb) and assertions were not verified.
test_command_delete_userdelete-user of C_AUTHZ: a user with roles needs force, an immutable seed user is never deleted.
test_command_shutdownshutdown answers first and stops the yuno after the answer left.
test_register_refused_gclassA gclass of the yuno that gclass_create() refuses (a SDF_SECRET attribute named vault) stops the yuno before it runs: the test forks the yuno and checks it exited with -1 (255), the exit(-1) of yuneta_entry_point() after its ERROR. Up to 7.26.9 the yuno ran (its driver played and the child answered 7).
test_jwt_alg_confusionThe JWT algorithm-confusion forgery: an HS* token verified with the bytes of an RSA/EC public key is refused. The jwks_* keyring API accepts a NULL set, jwks_item_count, jwks_find_bykid (and a NULL kid), jwks_item_add and jwks_item_free_bad included (not guarded upstream either). A key in error (an RSA JWK with no n, an oct JWK whose "alg" is not a string) is refused by jwt_checker_setkey() and jwt_builder_setkey() with “Key is in error and cannot be used” (upstream GHSA-4jp4, and up to 7.31.3 the second one verified tokens).
test_gbmem_realloc_refusedA gbmem_realloc() refused because the new size is larger than the largest block leaves the old block valid and tracked: the later free logs nothing and the memory counter stays right.
test_command_parameter_typesWhat a command parameter takes, whatever gives it (the command line, kw or its default, command_parser()): a string, an object, an array of that shape. An integer, a real, a boolean as a number or a boolean, never an object or an array, and text read as one (yes, off, 1, but not maybe). A DTP_JSON anything, text that is not json a string unless it starts as json and breaks. A null is no value, and so is an empty text in kw for a number (absent with no default). The line has the last word over a refused kw value. The handler gets the EXACT type (1 to a boolean is true, true to an integer 1, 2.0 is 2, 2.7 refused), and a number as text is one of the JSON grammar, the whole text, and in its range (nan, inf, .5, 5., +5, 007, past 64 bits refused, but -0, 1E5 taken), read in the "C" locale whatever LC_NUMERIC is (2.5 with the LC_NUMERIC of es_ES, when that locale is installed). command_parameter_from_text(). Each refusal before the handler, -1 naming the parameter: an ERROR from C code, a WARNING from a peer (__username__). help cmd="unlock <pin>" echoes unlock ********, a required SDF_SECRET given without its key. A json parameter given as text has no "gbuffer" key, at any depth. A required parameter given as key=value on the line (alone, in any order, after a positional one, with the other in kw) is taken (it was “required parameter not found”). A missing one is “is required”. In that mode a refused kw value of a required parameter loses to the line. login user=bob <pin> does not echo the pin in “extra parameters”. Trailing blanks (typed s=a , required 1 x \t) are no parameter. An optional secret or a wild command (opt user=bob <pw>, wild x=login bob <pw>) never echoes a leftover word, in the answer, the ev_kw trace or the mask, while typed s=a stray-word still does. A secret known by its NAME only (no SDF_SECRET: named user=bob <pw>, named bob <pw>) does not echo a leftover word either. An unknown option of a command with a secret is not named (answer, commands/ev_kw traces, mask of the line): opt user=bob <base64>==, opt user=bob <word>=, named user=bob <base64>==, opt user=bob <word>='x answer '<...>' (7.30.26 named it). typed s=a zzz=1 and typed s=a zzq='x still name it. A SDF_WILD_CMD command does not name the key of a value with no closing quote (wild x=1 <word>='x). A word with a = in the place of a required positional (opt <word>=, opt <base64>== user=bob, opt '<word>=', named <word>=x) is refused and is <...> in the mask and the commands trace (7.30.26 showed it). required stray=x still shows it. With no table (command_mask_secret_line(NULL, ...)) a word ending in = or ==, or starting with =, is <...>. key=value and note='' stay. A first word with a blank, a quote or a backslash (‘login bob ’ note=x, “login bob ”, log\in s=a) is <...> in command_mask_secret_line(), with the table and with NULL, and in the commands trace. The line is refused with the pin in no answer, log or trace (7.30.26 showed it whole). ‘typed’ s=a stays typed s=a. The first word is read once: “‘typed’” s=a is no command (refused, the answer ‘<...>’, command_get_cmd_desc() NULL, and 7.30.26 ran typed), ‘typed’ s=a still runs, and ‘login bob ’ note=x is refused without echoing the pin. The help of “‘typed’” and of ‘login bob ’ x answers “command ‘<...>’ not available”. The cmd of help is a command line: five help lines with the commands trace on carry the secret in no answer, log or trace, and mask to help cmd=‘login bob ’ (with the table) / help cmd=‘login <...>’ (without one). The line help cmd=typed level=2 stays (7.30.26 traced help cmd=login bob ). The cmd of help is masked with the table of the gobj where help finds it: a child of the yuno whose store has an SDF_SECRET content64 (no secret’s name), with level=2 on the line (after or before cmd), in the kw, and level=1 where help does not find it: the secret in no answer, log or trace, and the mask help cmd='store id=x content64=’ (with the yuno’s table the child’s secret was traced). A cmd nothing mentions is answered by its first word only: “command ‘nosuch’ not available” for nosuch bob (7.30.26 echoed the whole cmd). A help whose cmd is a command with six values of 900 bytes, and a help of a search word of 70 KB, log no ERROR (up to 7.31.29: 1355 ERRORs with a stack, and one). A help of a help line with 40000 cmd= takes at most 16 times the time of 5000 (up to 7.31.29: 37 s against 0.6 s).
test_command_binary_kwA command, and build_stats(), whose kw carries a gbuffer: the handler’s kw holds a reference of its own, and the caller’s references are intact after the command (no “BAD gbuf_decref()”).
test_dir_array_nomemA directory listing that cannot keep an entry (no memory), or whose root cannot be opened, answers -1 with the listing empty, and logs it: find_files_with_suffix_array(), walk_dir_array(), get_ordered_filename_array().
test_dir_listingThe answer of the agent’s dir-* commands: a tree that cannot be listed answers -1 with a comment that names the directory and sends to the log (it does not read the process-global last message), never an empty list.
test_dir_read_errorA directory that opens and cannot be READ (readdir() fails, EIO, by a --wrap=readdir) fails the listing: find_files_with_suffix_array(), walk_dir_array() (root or subdirectory) and walk_dir_tree() answer -1, empty, logged. re/pattern NULL lists every entry. A root of mode 0 given to walk_dir_tree() is logged. A SUBdirectory whose opendir() fails with EMFILE (a transient cause, by a --wrap=opendir) fails the walk, but one with EACCES is skipped with a warning. A callback that returns FALSE in a subdirectory stops the WHOLE walk. Paths longer than PATH_MAX fail the walk (“Path too long”, and up to 7.25.4 a crash), also in find_files_with_suffix_array() without d_type (the readdir() wrap hides it). A tree of 1100 levels fails it too. An entry whose lstat() fails with EIO fails the walk and find_files_with_suffix_array() without d_type (by a --wrap=lstat). One whose lstat() fails with EACCES is listed by find_files_with_suffix_array() without d_type, as with it. A subdirectory whose opendir() fails with ENOTDIR or ELOOP is skipped with a warning. rmrcontentdir() and rmrdir() of a directory whose readdir() fails answer -1 and log “readdir() FAILED”. A failed mkrdir() leaves the cause in errno after its own log (ENOTDIR, ENAMETOOLONG).
test_secret_attrsA SDF_SECRET attribute is read, written and saved as usual and SHOWN masked, wherever it is shown: view-gobj (C_IEVENT_SRV’s http_cookie), view-config (a service’s kw, a child’s, a global key, the __json_config_variables__ that feed one), the create_delete2 trace, the commands trace with ev_kw (a key=value, a positional and a kw secret, the kw the parser expands, the command that command-yuno carries), a secret by its VALUE under any name (a JWT, the token after Bearer ), the first word of a line out of session, a peer’s remote log line (capped, masked), the frame of an event that is not public (one WARNING). A json that does not parse is never logged as it came (anystring2json(), string2json(), json_config_string2json(), an attribute written as text): not its bytes, not the bytes jansson quotes near the error. An HTTP json body that breaks and an inter-event without its routing are the peer’s, a WARNING, masked (7.27.0+). A capped log line masks the password of a URL whose @ lies past the bytes it judges, at every cap (7.27.0+). The masking is linear, by its slope: each shape at 16, 64 and 256 KB, the ratio of the times under 16^1.15 (a quadratic one gives 256). And the persistent-attrs file (dbsimple.c): made 0600 when it is loaded. A planted symlink or hard link not read nor written through. A file of another user not loaded (root’s only if nobody else can write it, the chain of directories closed from /). A save that stops half way writes the old content back. A word left over on a line is echoed in “extra parameters” only by a command without secrets (set-note-pos x stray-word). set-password note=x stray-word does not echo it. An unknown key of a command with a secret is <...> in the mask (set-password password=x note=y aHVudGVyMg== gives set-password password=******** note=y <...>). A command without secrets shows it (set-note-pos x zzz=1). (set-password-pos gained an optional note parameter in the test table.) The ievents and ievents2 traces of a command frame built as the emitters build it (the line in __command__ and in the command_stack of __md_iev__, msg_iev_push_stack()): a positional secret and a content64 (store-blob, SDF_SECRET without a secret’s name) masked by the destination’s table. In the answer (msg_iev_build_response(), src_service the gate’s channel) and in an EV_TTY_CLOSE echo, the line is its first word, store-blob <...> (7.30.26 showed the stack masked by names only). And a command or a stats to a C_IEVENT_SRV or C_IEVENT_CLI out of session is answered -1 “not in session” with no ERROR, and an event to a C_IEVENT_CLI out of session returns -1 with no ERROR (7.30.26: NULL, and an ERROR with a stack). And a C_IEVENT_SRV and a C_IEVENT_CLI in session whose C_WEBSOCKET is closing (ST_DISCONNECTED, as a peer’s Close leaves it before EV_ON_CLOSE): a command and a stats answered -1 “not in session”, an answer, an injected event and an EV_SEND_IEV return -1, one WARNING “Transport closing, nothing sent” per channel, no ERROR (7.30.26: “Event NOT DEFINED in state” in the transport, an ERROR with a stack each, and the command and the stats never answered). The same for a C_IEVENT_CLI above C_IOGATE -> C_CHANNEL (opened) -> C_PROT_TCP4H in ST_DISCONNECTED, the agent’s link to the control center (7.30.26: 4 x “Event NOT DEFINED in state” in the tcp4h, the command and the stats never answered). A command line whose masked form passes 64 KB, with a Basic credential where the 64 KB fall, goes into the command stack with 64 KB at most, ends in <...>, does not show the credential, and logs no ERROR (up to 7.31.29: 21 ERRORs with a stack). When a write-attr’s attribute= of a secret does not fit in the 64 KB, its value= does not show either, and the line ends in one <...>.
test_secret_trafficThe C_TCP traffic trace of a frame sent with "__secret__": true (an SMTP AUTH line) prints <N bytes hidden>, never its bytes, whether the frame was written at once or queued while the client connected. A normal frame is still dumped. A RECEIVED frame’s dump masks what can be told in its bytes, the password of a URL whose authority reaches the end of the bytes included (7.27.0+: the @ can come in the next read).
test_command_secret_positionalgclass_create() refuses a command table where a required secret (SDF_SECRET, or a secret’s name) is followed by another required parameter. Otherwise, a secret written with blanks spills into it and is shown in the traces. A required secret as the last required parameter is accepted. A SDF_SECRET attribute must have a secret’s name (vault refused, vault_secret accepted).
test_attr_typesA value written to an attribute (gobj_create() from the config, gobj_write_attr()) is read as its declared type by the grammar of the command parser (command_parameter_from_json()): a json string given to a boolean, an integer, a real, a list or a dict is read from its text ("yes" true, "42" 42, "2.5", "[1, 2]"). A number is read as the exact type (an integer to a real is its real, true to an integer 1, 2.0 2). What does not read as one (12abc, 2.7 to an integer, an object to an integer, nan, maybe, a dict to a list, an empty text, a null) is refused with one ERROR naming the attribute, its type and why, the value masked and capped (a SDF_SECRET one never shown), and the attribute keeps its value. Up to 7.26.9 a string was read from its JSON dump, quotes included: "42" was 0, "true" false. And every case of kernel/js/gobj-js/tests/fixtures/attr_types_parity.json, which gobj-js’s tests/attr_types.test.js reads too: C and JS read an attribute value the same way. The table is read from the kernel/js/gobj-js submodule of the source tree the test was built from (its path is compiled in, YUNETAS_BASE is not read): a tree without it (a tarball of yunetas alone) runs the other checks, says so on its output (“SKIP the parity table of gobj-js: ... not found”), and exits 77, which ctest reports as Skipped (SKIP_RETURN_CODE), not as Passed.
test_date_textThe date reader (approxidate_careful(), parse_date_basic()), gmtime2timezone() and the ranges (get_hours_range() and the rest) against a faked clock, with the tzset()/localtime_r() calls counted. Its zones part writes TZif files in a directory of each run (mkdtemp(), removed at the end): a file is a zone when its RFC 9636 headers are whole, a version 2 needs its footer and is read with every count in both blocks (transitions, leap seconds, indicators: 4-byte times in the first, 8-byte in the second), a POSIX TZ when all of it can be read, and a name too long for a path is no zone even when its first PATH_MAX - 1 bytes under TZDIR name a zone file.
test_time_clitime2date and time2range, built from their sources in tests/c/time_cli and run by a script (ctest time_cli/test_time_cli): the answer and the exit code for good input, a date that is no date (2026-10-01Tgarbage), a number that is no JSON integer (abc, 007, 0x10) or out of range, a time before the epoch (also in milliseconds), an unknown zone (its ERROR printed once, no answer, exit 255), a -r that is no JSON integer (" 5", +5, 05, 5.0) or out of the range of an int (each with its own message), -r 0 on the first day of the epoch (a range) and times no calendar holds (refused).

Source: tests/c/helpers/, tests/c/time_cli/, tests/c/gbuffer/, tests/c/command_binary_kw/, tests/c/command_parameter_types/, tests/c/build_path/, tests/c/glogger_utf8/, tests/c/gobj_trace_tab/, tests/c/command_authz/, tests/c/authz_login/, tests/c/command_delete_user/, tests/c/command_shutdown/, tests/c/register_refused_gclass/, tests/c/libjwt/, tests/c/secret_attrs/, tests/c/command_secret_positional/, tests/c/attr_types/

Keyword matching

BinaryDescription
test_kw1kw_match_simple() with strings, booleans, integers, and floats. It also checks the formats of the logger: the precision caps a value, the length modifiers (%zu, %llu, %jd, %hhd), a % with no conversion, and %m, which takes no argument (up to 7.26.9 it took one, and the key after it crashed the process). utf8_prefix_len(), and a cap of the logger and of a json_sprintf() comment that never cuts a UTF-8 character. utf8_columns() and utf8_prefix_columns(), and a table cell padded by characters that is as wide as an ASCII one. kw_find_path() of a path of 100 segments and of a 300-byte segment (found, nothing logged), and json_refcounts_report() of a shared node, a cycle, and a cycle whose refcounts are corrupted below the truth (it ends, each json counted once, not truncated, and REPORTED as corrupted at the path of the reach too many), a dict and a string json_object_set_new()'d into two places (corrupted, each), and a sound json held by the caller and two hooks (none). A list of a million integers walked whole under the default MAX_BLOCK (up to 7.26.9 a frame was reserved for every child, 32 MB for the root: truncated, one json counted), and 40 000 records, more frames than one chunk holds. json_nul_fault() of a NUL down a record, of a clean one, and of a json 3000 levels deep. kw_collapse() of a json that holds itself: the dict met again under itself answers collapsed (up to 7.31.29 the walk did not end). kw_collapse() of lists in a list: each one walked with lists_limit, none of them the original (up to 7.31.29 they came whole and shared), and two lists that hold each other answer collapsed.
test_json_flatjson2flat() / flat2json(): one row per leaf, keys with ` and [, empty containers as leaves, and the ids refused when one is a leaf and a container at once.
test_kw_set_dict_valuekw_set_dict_value(): the value REPLACES what the path holds (a leaf, a dict, an item of a list), the dicts of the path are created, and nothing is written (-1, the kw as it was) when a segment is a scalar or null, an index is out of its list, or the path is empty. The value is owned in every case.
test_kw_binary_depthA binary field (gbuffer) counts only at the top level of a kw: kw_duplicate(), kw_filter_metadata() and kw_filter_private() take no reference of a gbuffer nested in a dict or a list, and still take one of the top-level gbuffer. A top-level gbuffer of 0 is not increfed. gbuf2json_from_peer(), anystring2json_from_peer() and iev_create_from_gbuffer() leave no "gbuffer" key at any depth, spelled with \u escapes too (all 127 ways, beside a \u00e9, and the pre-check walks only a text with gbuffer, \u006 or \u007), with one warning. Up to 7.30.16 a peer’s {"x":{"gbuffer":4096}} crashed in gbuffer_incref(). The __temp__ frontier: iev_create_from_gbuffer() drops a peer’s __temp__ (a list, a dict with channel_gobj, an integer, with verbose 0 and 1), with no log, and iev_create_to_gbuffer() writes no __temp__ in a frame, while the other holder of a shared kw keeps its own and its gbuffer (up to 7.30.26 both kept it).

Source: tests/c/kw/

Generic message interchange

A JSON-driven test runner that executes scripted test sequences and validates event traces and error logs.

Test scenarioDescription
test_mqtt_qos0MQTT QoS 0 publish/subscribe interchange.
test_tcp_connectTCP connection establishment.
test_tcp_reconnectTCP reconnection and recovery.

Source: tests/c/msg_interchange/

Which library a test runs

A test binary links the installed archives in outputs/lib, not the ones in the build tree. So a change in kernel source reaches a test only after the library is installed, and then the next build relinks the test:

# 1. change kernel/c/timeranger2/src/timeranger2.c, then install the library
cd kernel/c/timeranger2/build && make install
#   -- Installing: .../outputs/lib/libtimeranger2.a

# 2. the next build of the test relinks it against the new archive
cmake --build build --target test_tr_treedb_rowid
#   [  0%] Linking C executable test_tr_treedb_rowid

cmake --build build --target <test> alone, without step 1, links the test against the OLD installed copy: the root build/ does not build the library (unless it was configured with -DENABLE_SDK=ON). Step 2 holds only because the test names the archive by its full path (${YUNETAS_KERNEL_LIBS}, or ${LIB_DEST_DIR}/libfoo.a): a bare libfoo.a is a -l search, and the test is not relinked at all. Up to 7.26.3 this very test, and 17 others, named them bare. scripts/check_test_links.py fails on one.

Before 7.25.5, step 2 sometimes also printed only “Built target” and kept the old library. install() keeps the mtime of the file it copies, in whole seconds, which is the time the archive was BUILT: a test linked between that moment and the install looked newer than the archive. tools/cmake/project.cmake now stamps an archive that changed with the time of its install, rounded up to the next whole second. An archive that did not change is not copied (“Up-to-date”) and relinks nothing.

A test that opens more than 1024 files

systemd starts what it launches, a desktop terminal included, with a soft limit of 1024 open files, whatever the hard limit is. A test run from that terminal fails with “TOO MANY OPEN FILES”, "current soft limit": 1024, while the same test passes from another shell. A process can raise its own soft limit up to the hard one without privileges, so a test that opens many files (a topic with more than 1024 keys, many treedbs) calls raise_open_files_limit() first:

int result = raise_open_files_limit();
result += do_test();

test_iterator_index, test_c_treedb_literal_wins and perf_c_treedb do. To give every program started from the desktop a higher soft limit, set it for the systemd user manager, then log in again:

sudo mkdir -p /etc/systemd/user.conf.d
printf '[Manager]\nDefaultLimitNOFILE=1048576:4000000\n' | \
    sudo tee /etc/systemd/user.conf.d/nofile.conf

Debugging a test that corrupts the heap

A test that dies with “corrupted double-linked list” or “free(): chunks in smallbin corrupted” is reporting heap corruption that happened earlier: the abort lands at the next malloc/free, not at the write that caused it. The backtrace at that point names the detector, not the culprit.

AddressSanitizer finds it, but not by building with it. The test tree links the installed libraries from outputs/lib, not the ones in the build tree, so configuring a build with -fsanitize=address instruments the test’s own .c files and nothing else, and ASan reports nothing while the plain build keeps aborting, which reads as “it is not a real bug” and is only “you did not look at it”.

What works, and what it costs:

# 1. a non-static build, because -static and -fsanitize=address are exclusive
cp .config .config.bak && sed -i 's/^CONFIG_FULLY_STATIC=y/CONFIG_FULLY_STATIC=n/' .config

# 2. configure a separate tree WITH the sanitiser, and with the SDK in it
#    (ENABLE_SDK: the root tree builds only the tests by default)
cmake -S . -B build_asan -DCMAKE_BUILD_TYPE=Debug -DENABLE_SDK=ON \
    -DCMAKE_C_FLAGS="-fsanitize=address -g -fno-omit-frame-pointer" \
    -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"

# 3. build the LIBRARIES too, not only the test
cmake --build build_asan --target yunetas-gobj timeranger2 yev_loop ytls \
    yunetas-core-linux <the test> -j8

# 4. relink the test by hand against those libraries: take its link.txt and
#    replace every /outputs/lib/lib*.a with the build_asan path

And instrument jansson as well when the corruption is around json: it lives in outputs_ext/lib and is not part of the build. Compile kernel/c/linux-ext-libs/build/jansson/src/*.c with the sanitiser and with its own generated headers (-DHAVE_CONFIG_H -I<jansson>/build/private_include -I<jansson>/build/include), or it builds but parses nothing and every test fails with “Cannot load json file, bad json”, which looks like a different bug entirely.

With all of it instrumented, ASan names the two lines that matter (where the memory was freed and where it was used afterwards), and a hunt that had taken hours takes a minute.

A time limit fails under ASan that is not a slow algorithm. ASan’s interceptor of strstr() / strcasestr() measures the WHOLE haystack at every call (its StrstrCheck), so a scan that calls one per match turns quadratic under ASan only. Up to 7.26.9 the agent’s audit record looked for attribute with strcasestr(), and helpers/test_audit_record’s 1 MB shapes took 20 s against 0.24 s for 100 KB and failed their limits, while the plain build took 0.04 s. It now searches within the length it was given (0.06 s for 1 MB under ASan). If another test shows it, ASAN_OPTIONS=intercept_strstr=0 tells the two apart (the scan is linear again and every other check of ASan stays on), and the fix is a search bounded by the length, not the option. A test of speed is better written as a SLOPE than as a limit: secret_attrs/test_secret_attrs masks each text at 16, 64 and 256 KB and asks the ratio of the times, which a load or a sanitizer leaves alone (it took 1 MB in under 500 ms up to 7.26.9, and failed under ASan with the machine loaded).

Restore .config afterwards.

The mistake it usually is

Three bench tests died this way on 2026-08-28, and all three were the same thing: a borrowed pointer handed to a function that owns what it is given.

json_array_get(), kw_get_dict(), treedb_get_node() and friends answer a pointer they still own, but test_json() frees what it receives. Passing one to the other spends a reference that was never given, and the next json_decref() of the container frees the same block twice. Incref it at the call:

result += test_json(json_incref(record));   // record is borrowed

The scripts of the packages

Not run by ctest: the shell tests under packages/tests/ check the scripts of the .deb and .rpm in a private directory, and run from anywhere.

packages/tests/test-yuneta-agent-cert.sh
packages/tests/test-install-package.sh
packages/tests/test-copy-certs.sh
ScriptDescription
packages/tests/test-yuneta-agent-cert.shThe agent’s own pair (yuneta-agent-cert), and the scripts that put the agent into its unit, in a fake root with stubs for systemctl, pgrep and su. It gives every agent it fakes a /proc/<pid>/cmdline. The service helper (.deb/.rpm), both postinsts’ _agent_into_its_unit, the .rpm’s %pre and both SysV scripts’ _agent_outside_unit must find an agent started as /yuneta/agent/<name> in four cases: its executable replaced (“(deleted)”), behind a symlinked /yuneta, renamed, or unreadable. They must leave alone a process of that name whose argv[0] is a shell or another interpreter. 175 checks. Up to 7.30.17 the agent was found by /proc/<pid>/exe alone, and the last three cases were missed.
packages/tests/test-install-package.shThe root program of install-package (install-package), run as a normal user in a fake root, with stubs for curl, systemd-run, systemctl, apt-get, dpkg-deb, dnf, rpm and journalctl, and a PATH with only the tools it needs. start refuses a link in place of url, sha256 or the data directory (and never shows what the link points to), each bad URL (http://, a blank, a quote, a backslash, one of [ ] { }, a control or non-ASCII character, two lines, more than 2048 characters, no .deb/.rpm name), each bad sha256, a node without curl, dpkg-deb or dnf, a second install, a systemctl that fails (closed, with its message), and a state directory that is a link or writable by the group. run downloads with --globoff --proto =https --proto-redir =https --max-filesize 1073741824 --speed-limit 1024 --speed-time 120, stops a download over its bound (ulimit -f), refuses another sha256 or a package that is not yuneta-agent (with the error of dpkg-deb in the output when it cannot read the file), runs apt-get update before apt-get install and goes on when the update fails, and removes the download. 164 checks.
packages/tests/test-copy-certs.shcopy-certs.sh and the certbot hook reload-certs, run as a normal user in a fake root, with a stub of setpriv that writes down the user and the options it runs a command with (--reset-env). copy-certs.sh copies every live certificate (.crt and .chain 0644, .key 0600): the owner makes the directories and, in one call for each certificate, compares each file (cmp) and writes it, with no temporary file left. When a write of a certificate fails, none of its files changes (the old key stays with the old .crt), and the moves put the key first and the .crt last. When a move fails (a stub mv), the files already moved are put back and no temporary or .old file stays. When putting them back fails too, it says so (rc 3) and names the kept old file. An old file that cannot be hard-linked (a stub ln) is kept as a copy (cp -p), said, and the certificate is copied. When a later move fails, the copies are put back. When the old file can be neither linked nor copied and the undo fails, it gives rc 3, never “nothing changed”. Two runs with --wait at once never interleave their parts (flock). The lock is in a directory of its own under /run, mode 0700. When another process holds the lock, a run without an option copies nothing, says so and exits 75 at once (the agent reads busy), and a run with --wait waits and then copies. When logger fails, a line goes to /var/log/yuneta/copy-certs.log with its time, and only once when the output goes to that file already (the hook). An unknown option is refused. On a node with no certificate it says so to the journal once in three runs, and again after a certificate came and went. Every line it says also goes to logger -t copy-certs. An unchanged certificate is not written (mtime kept, no Copied, no check-certs-validity.sh), a mode that changed is set again, and a changed file is the only one written. A certs.list that the owner cannot read gives exit 1 and copies nothing. A TMPDIR that nobody can enter changes nothing. A write that fails gives exit 1, and the other certificates are written. In certs.list, a bad name (../../../etc, .hidden, a/b, x..y, bad*name) is skipped with a line, the blanks around a name are trimmed, and a line with two names gives both. A .pem that resolves out of /etc/letsencrypt is skipped. A symbolic link in place of certs/ or private/ is refused (exit 1, nothing written there), and a destination file that is a link skips its certificate. The hook runs copy-certs.sh --wait (FAILED when it fails) and the reload of the web server, and runs ycommand as the owner. It starts restart-yuneta as the owner in a transient unit (systemd-run -p Type=exec --uid=<owner>, no --no-block), or in the background without systemd. When that unit does not start, it says so and starts nothing in the background. It says when it cannot write its stamp. restart-yuneta, as both packagers write it: with a unit file of the agent it restarts the agent in its unit (sudo -n systemctl restart, no systemctl cat), also from logcenter under the agent’s unit. Without one, from logcenter it runs yshutdown and --start, and from the transient unit of the hook (its /proc/self/cgroup) it refuses: no yunos stopped, no agent started. The SELinux part of the .rpm’s %post, with stubs. With the rules in place, it runs one matchpathcon and no semanage. With one rule missing, it imports only that rule. Without matchpathcon, it reads the local rules, as before.

Source: packages/tests/

Benchmarks run by ctest

ctest also runs the benchmarks of performance/c/, with small sizes, so a benchmark that breaks is seen: perf_c_tcp/test4, perf_c_tcp/test5, perf_c_tcps/test4, perf_c_tcps/test5, perf_yev_ping_pong, perf_yev_ping_pong2, perf_auth_bff, perf_timeranger2, perf_tr_treedb, perf_c_treedb and perf_rotatory. Their figures are in performance/c/README.md.

ctest -R '^perf_' --output-on-failure --test-dir build

Build flag

Tests are enabled by default via .config (CONFIG_MODULE_TEST=y). Toggle with menuconfig or pass -DENABLE_TESTS=OFF to CMake.