check_PROGRAMS += \
test_sysfs \
test_loopdev \
+ test_consoles \
test_pager
endif
test_loopdev_SOURCES = lib/loopdev.c
test_loopdev_CFLAGS = -DTEST_PROGRAM_LOOPDEV
test_loopdev_LDADD = libcommon.la
+
+test_consoles_SOURCES = lib/consoles.c
+test_consoles_CFLAGS = -DTEST_PROGRAM
+test_consoles_LDADD = libcommon.la
endif
test_fileutils_SOURCES = lib/fileutils.c
return ret;
}
+
+#ifdef TEST_PROGRAM
+int main(int argc, char *argv[])
+{
+ char *name = NULL;
+ int fd, re;
+ struct console *p, *consoles = NULL;
+
+ if (argc == 2) {
+ name = argv[1];
+ fd = open(name, O_RDWR);
+ } else {
+ name = ttyname(STDIN_FILENO);
+ fd = STDIN_FILENO;
+ }
+
+ if (!name)
+ errx(EXIT_FAILURE, "usage: %s [<tty>]\n", program_invocation_short_name);
+
+ re = detect_consoles(name, fd, &consoles);
+
+ for (p = consoles; p; p = p->next)
+ printf("%s: id=%d %s\n", p->tty, p->id, re ? "(reconnect) " : "");
+
+ return 0;
+}
+#endif