From ff2ff2fbca75352ff027a90d6341645f1dea4e50 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 24 Apr 2024 14:30:00 +1000 Subject: [PATCH] test: Make log truncation test more robust test/pasta_options/log_to_file checks that pasta truncates its log file when started. It does that by starting pasta with a log file once, then starting it again and checking that after the second round, the log file has only one line: the startup banner from the second invocation. However, this test will break if the second invocation logs any additional messages at startup. This can easily happen on a host with multiple network interfaces due to the "Multiple default route" informational messages added in 639fdf06e ("netlink: Fix selection of template interface"). I believe it could also happen on a host without IPv6 connectivity due to the "Couldn't pick external interface" messages, though I haven't confirmed this. Make the log file test more robust, by not testing for a single line, but instead explicitly testing for the PID of the second pasta invocation in the banner line. Link: https://bugs.passt.top/show_bug.cgi?id=88 Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- test/pasta_options/log_to_file | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/pasta_options/log_to_file b/test/pasta_options/log_to_file index f100216..fe50e50 100644 --- a/test/pasta_options/log_to_file +++ b/test/pasta_options/log_to_file @@ -37,8 +37,9 @@ passt ./pasta -l __LOG_FILE__ -- /bin/true check [ -s __LOG_FILE__ ] test Log truncated on creation -passt ./pasta -l __LOG_FILE__ -- /bin/true -check [ $(cat __LOG_FILE__ | wc -l) -eq 1 ] +passt ./pasta -l __LOG_FILE__ -- /bin/true & wait +pout PID2 echo $! +check head -1 __LOG_FILE__ | grep '^pasta .* [(]__PID2__[)]$' test Maximum log size passtb ./pasta --config-net -d -f -l __LOG_FILE__ --log-size $((100 * 1024)) -- sh -c 'while true; do tcp_crr --nolog -P 10001 -C 10002 -6; done'