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.
This commit is contained in:
Yu Watanabe
2026-09-03 06:45:43 +09:00
parent 2451b1a9c4
commit 65a967fc46
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -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 + {
+5 -5
View File
@@ -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);