From 65a967fc46a72e7e7bdee541ba6cb11f51bc3306 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 3 Sep 2026 06:45:29 +0900 Subject: [PATCH] test: several follow-ups for test-hostname-pick-word 'pos' must be >= 1, otherwise triggers assertion in hostname_pick_word(). 'c' should be >= 1, otherwise nothing tested. --- src/test/meson.build | 2 +- src/test/test-hostname-pick-word.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/meson.build b/src/test/meson.build index ebdd46788a..81ff491b50 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -400,7 +400,7 @@ executables += [ 'timeout' : 180, }, test_template + { - 'sources': files('test-hostname-pick-word.c'), + 'sources' : files('test-hostname-pick-word.c'), 'type' : 'manual', }, test_template + { diff --git a/src/test/test-hostname-pick-word.c b/src/test/test-hostname-pick-word.c index 3021c6e6ef..5093c0267d 100644 --- a/src/test/test-hostname-pick-word.c +++ b/src/test/test-hostname-pick-word.c @@ -12,20 +12,20 @@ static int run(int argc, char **argv) { int r; - log_parse_environment(); + log_setup(); unsigned c = 100, pos = 1; if (argc > 1) { - r = safe_atou(argv[1], &pos); + r = safe_atou_bounded(argv[1], /* min= */ 1, /* max= */ UINT_MAX, &pos); if (r < 0) - return log_error_errno(r, "Cannot parse uint %s: %m", argv[1]); + return log_error_errno(r, "Cannot parse uint '%s': %m", argv[1]); } if (argc > 2) { - r = safe_atou(argv[2], &c); + r = safe_atou_bounded(argv[2], /* min= */ 1, /* max= */ UINT_MAX, &c); if (r < 0) - return log_error_errno(r, "Cannot parse uint %s: %m", argv[2]); + return log_error_errno(r, "Cannot parse uint '%s': %m", argv[2]); } sd_id128_t mid = SD_ID128_ARRAY(aa,bb,cc,ee,33,21,42,31,89,ba,a4,91,33,22,11,00);