From 1f5641f97958c0e04ed5ddf2b0d84fe38f5d325f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 28 Nov 2007 12:52:59 +0100 Subject: tests: add test for include/pathnames.h Signed-off-by: Karel Zak --- tests/helpers/Makefile.am | 2 +- tests/helpers/test_pathnames.c | 99 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 tests/helpers/test_pathnames.c (limited to 'tests/helpers') diff --git a/tests/helpers/Makefile.am b/tests/helpers/Makefile.am index 933a6d5ec..24dcd2afa 100644 --- a/tests/helpers/Makefile.am +++ b/tests/helpers/Makefile.am @@ -1,4 +1,4 @@ include $(top_srcdir)/config/include-Makefile.am -noinst_PROGRAMS = test_sysinfo +noinst_PROGRAMS = test_sysinfo test_pathnames diff --git a/tests/helpers/test_pathnames.c b/tests/helpers/test_pathnames.c new file mode 100644 index 000000000..b44a60278 --- /dev/null +++ b/tests/helpers/test_pathnames.c @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2007 Karel Zak + * + * This file is part of util-linux-ng. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include + +#include "pathnames.h" + +struct hlpPath +{ + const char *name; + const char *path; +}; + +#define DEF_HLPPATH(_p) { #_p, _p } + +struct hlpPath paths[] = +{ + DEF_HLPPATH(_PATH_DEFPATH), + DEF_HLPPATH(_PATH_DEFPATH_ROOT), + DEF_HLPPATH(_PATH_TTY), + DEF_HLPPATH(SECURETTY), + DEF_HLPPATH(_PATH_WTMPLOCK), + DEF_HLPPATH(_PATH_HUSHLOGIN), + DEF_HLPPATH(_PATH_MAILDIR), + DEF_HLPPATH(_PATH_MOTDFILE), + DEF_HLPPATH(_PATH_NOLOGIN), + DEF_HLPPATH(_PATH_LOGIN), + DEF_HLPPATH(_PATH_INITTAB), + DEF_HLPPATH(_PATH_RC), + DEF_HLPPATH(_PATH_REBOOT), + DEF_HLPPATH(_PATH_SINGLE), + DEF_HLPPATH(_PATH_SHUTDOWN_CONF), + DEF_HLPPATH(_PATH_SECURE), + DEF_HLPPATH(_PATH_USERTTY), + DEF_HLPPATH(_PATH_MTAB), + DEF_HLPPATH(_PATH_UMOUNT), + DEF_HLPPATH(_PATH_PASSWD), + DEF_HLPPATH(_PATH_GSHADOW), + DEF_HLPPATH(_PATH_PTMP), + DEF_HLPPATH(_PATH_PTMPTMP), + DEF_HLPPATH(_PATH_GROUP), + DEF_HLPPATH(_PATH_GTMP), + DEF_HLPPATH(_PATH_GTMPTMP), + DEF_HLPPATH(_PATH_SHADOW_PASSWD), + DEF_HLPPATH(_PATH_SHADOW_PTMP), + DEF_HLPPATH(_PATH_SHADOW_PTMPTMP), + DEF_HLPPATH(_PATH_SHADOW_GROUP), + DEF_HLPPATH(_PATH_SHADOW_GTMP), + DEF_HLPPATH(_PATH_SHADOW_GTMPTMP), + DEF_HLPPATH(_PATH_WORDS), + DEF_HLPPATH(_PATH_WORDS_ALT), + { NULL, NULL } +}; + +int +main(int argc, char **argv) +{ + struct hlpPath *p; + + if (argc == 1) { + for (p = paths; p->name; p++) + printf("%20s %s\n", p->name, p->path); + exit(EXIT_SUCCESS); + } else { + if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) { + printf("%s