2 # SPDX-License-Identifier: LGPL-2.1-or-later
6 # test-journal-append corrupts the journal file by flipping a bit at a given offset and
7 # following it by a write to check if we handle appending messages to corrupted journals
10 TEST_JOURNAL_APPEND
=/usr
/lib
/systemd
/tests
/unit-tests
/manual
/test-journal-append
12 [[ -x "$TEST_JOURNAL_APPEND" ]]
14 # Corrupt the first ~1024 bytes, this should be pretty quick
15 "$TEST_JOURNAL_APPEND" --sequential --start-offset=0 --iterations=350 --iteration-step=3
17 # Skip most of the test when running without acceleration, as it's excruciatingly slow
18 # (this shouldn't be an issue, as it should run in nspawn as well)
19 if ! [[ "$(systemd-detect-virt -v)" == "qemu" ]]; then
20 # Corrupt the beginning of every 1K block between 1K - 32K
21 for ((i
= 1024; i
<= (32 * 1024); i
+= 1024)); do
22 "$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
25 # Corrupt the beginning of every 16K block between 32K - 128K
26 for ((i
= (32 * 1024); i
<= (256 * 1024); i
+= (16 * 1024))); do
27 "$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
30 # Corrupt the beginning of every 128K block between 128K - 1M
31 for ((i
= (128 * 1024); i
<= (1 * 1024 * 1024); i
+= (128 * 1024))); do
32 "$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
35 # And finally the beginning of every 1M block between 1M and 8M
36 for ((i
= (1 * 1024 * 1024); i
< (8 * 1024 * 1024); i
+= (1 * 1024 * 1024))); do
37 "$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
40 if [[ "$(nproc)" -ge 2 ]]; then
41 # Try to corrupt random bytes throughout the journal
42 "$TEST_JOURNAL_APPEND" --iterations=25
45 "$TEST_JOURNAL_APPEND" --iterations=10