2023-08-15 Bruno Haible <bruno@clisp.org>
+ readutmp tests: Add test against today's bug.
+ * tests/test-readutmp.c (main): Verify that there is exactly one
+ BOOT_TIME entry.
+
readutmp: Fix for platforms without ut_type (regression 2023-08-08).
* lib/readutmp.h (UT_TYPE_BOOT_TIME, UT_TYPE_USER_PROCESS): Don't use
UT_TYPE_EQ macro.
merge_sort_inplace (entries, num_entries,
XNMALLOC (num_entries, STRUCT_UTMP));
+ idx_t boot_time_count = 0;
idx_t i;
for (i = 0; i < num_entries; i++)
{
UT_TYPE_BOOT_TIME (entry) ? 'X' : ' ',
UT_TYPE_USER_PROCESS (entry) ? 'X' : ' ',
host);
+
+ if (UT_TYPE_BOOT_TIME (entry))
+ boot_time_count++;
}
fflush (stdout);
time_t now = time (NULL);
ASSERT (first >= now - 157680000);
ASSERT (last <= now + 604800);
+
+ /* read_utmp should not produce multiple BOOT_TIME entries. */
+ ASSERT (boot_time_count <= 1);
+
+ /* read_utmp should fake a BOOT_TIME entry if needed.
+ Platform specific hacks go into lib/boot-time-aux.h. */
+ ASSERT (boot_time_count >= 1);
}
free (entries);