]> err.no Git - util-linux/commitdiff
tests: add test for include/pathnames.h
authorKarel Zak <kzak@redhat.com>
Wed, 28 Nov 2007 11:52:59 +0000 (12:52 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 28 Nov 2007 11:52:59 +0000 (12:52 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/commands.sh.in
tests/expected/ts-include-pathnames [new file with mode: 0644]
tests/helpers/Makefile.am
tests/helpers/test_pathnames.c [new file with mode: 0644]
tests/ts-include-pathnames [new file with mode: 0755]

index 4963f103caeddc06ed026453d20e3e59d72c931b..6035547a34ca6d6a4e56f273ceda06ae739d5f24 100644 (file)
@@ -8,6 +8,7 @@ TS_TESTUSER=${TS_TESTUSER:-"test"}
 
 # helpers
 TS_HELPER_SYSINFO="$TS_TOPDIR/helpers/test_sysinfo"
+TS_HELPER_PATHS="$TS_TOPDIR/helpers/test_pathnames"
 
 # external commands
 TS_ECMD_BLKID="@BLKID@"
diff --git a/tests/expected/ts-include-pathnames b/tests/expected/ts-include-pathnames
new file mode 100644 (file)
index 0000000..55b6f17
--- /dev/null
@@ -0,0 +1,34 @@
+       _PATH_DEFPATH /usr/local/bin:/bin:/usr/bin
+  _PATH_DEFPATH_ROOT /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+           _PATH_TTY /dev/tty
+           SECURETTY /etc/securetty
+      _PATH_WTMPLOCK /etc/wtmplock
+     _PATH_HUSHLOGIN .hushlogin
+       _PATH_MAILDIR /var/mail
+      _PATH_MOTDFILE /etc/motd
+       _PATH_NOLOGIN /etc/nologin
+         _PATH_LOGIN /bin/login
+       _PATH_INITTAB /etc/inittab
+            _PATH_RC /etc/rc
+        _PATH_REBOOT /sbin/reboot
+        _PATH_SINGLE /etc/singleboot
+ _PATH_SHUTDOWN_CONF /etc/shutdown.conf
+        _PATH_SECURE /etc/securesingle
+       _PATH_USERTTY /etc/usertty
+          _PATH_MTAB /etc/mtab
+        _PATH_UMOUNT /bin/umount
+        _PATH_PASSWD /etc/passwd
+       _PATH_GSHADOW /etc/gshadow
+          _PATH_PTMP /etc/ptmp
+       _PATH_PTMPTMP /etc/ptmptmp
+         _PATH_GROUP /etc/group
+          _PATH_GTMP /etc/gtmp
+       _PATH_GTMPTMP /etc/gtmptmp
+ _PATH_SHADOW_PASSWD /etc/shadow
+   _PATH_SHADOW_PTMP /etc/sptmp
+_PATH_SHADOW_PTMPTMP /etc/sptmptmp
+  _PATH_SHADOW_GROUP /etc/gshadow
+   _PATH_SHADOW_GTMP /etc/sgtmp
+_PATH_SHADOW_GTMPTMP /etc/sgtmptmp
+         _PATH_WORDS /usr/share/dict/words
+     _PATH_WORDS_ALT /usr/share/dict/web2
index 933a6d5ec7ed230ec52177c0136ee492c4682df8..24dcd2afa70d1a515fadd8056d4af8b6fbbf7cf6 100644 (file)
@@ -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 (file)
index 0000000..b44a602
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#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 <option>\n", argv[0]);
+                       fputs("options:\n", stdout);
+                       for (p = paths; p->name; p++)
+                               printf("\t%s\n", p->name);
+                       exit(EXIT_SUCCESS);
+               }
+
+               for (p = paths; p->name; p++) {
+                       if (strcmp(p->name, argv[1]) == 0) {
+                               printf("%s\n", p->path);
+                               exit(EXIT_SUCCESS);
+                       }
+               }
+       }
+
+       exit(EXIT_FAILURE);
+}
+
diff --git a/tests/ts-include-pathnames b/tests/ts-include-pathnames
new file mode 100755 (executable)
index 0000000..fbf1fda
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# 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.
+#
+. ./commands.sh
+. ./functions.sh
+
+TS_COMPONENT="include"
+TS_DESC="basic paths"
+
+ts_init "$*"
+
+$TS_HELPER_PATHS &> $TS_OUTPUT
+
+ts_finalize
+