summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am11
-rw-r--r--lib/fileutils.c10
-rw-r--r--lib/nsutils.c15
-rw-r--r--lib/strutils.c14
-rw-r--r--lib/test_fileutils.c10
-rw-r--r--lib/test_nsutils.c15
-rw-r--r--lib/test_strutils.c38
7 files changed, 68 insertions, 45 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index f09cb8c..d88e750 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,12 +1,11 @@
AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
-I$(top_srcdir) \
- -I$(top_srcdir)/include
-
-AM_CPPFLAGS += -DTEST_PROGRAM
+ -I$(top_srcdir)/include \
+ -DLOCALEDIR=\"$(localedir)\"
noinst_PROGRAMS = test_strutils test_fileutils test_nsutils
-test_strutils_SOURCES = strutils.c
-test_fileutils_SOURCES = fileutils.c
-test_nsutils_SOURCES = nsutils.c
+test_strutils_SOURCES = test_strutils.c strutils.c
+test_fileutils_SOURCES = test_fileutils.c fileutils.c
+test_nsutils_SOURCES = test_nsutils.c nsutils.c
diff --git a/lib/fileutils.c b/lib/fileutils.c
index 1ade3d8..14c7452 100644
--- a/lib/fileutils.c
+++ b/lib/fileutils.c
@@ -43,13 +43,3 @@ void close_stdout(void)
if (close_stream(stderr) != 0)
_exit(EXIT_FAILURE);
}
-
-#ifdef TEST_PROGRAM
-#include <stdio.h>
-int main(int argc, char *argv[])
-{
- atexit(close_stdout);
- printf("Hello, World!\n");
- return EXIT_SUCCESS;
-}
-#endif /* TEST_PROGRAM */
diff --git a/lib/nsutils.c b/lib/nsutils.c
index d1cc6c9..673258e 100644
--- a/lib/nsutils.c
+++ b/lib/nsutils.c
@@ -8,13 +8,6 @@
#include "proc/readproc.h"
#include "nsutils.h"
-#ifdef TEST_PROGRAM
-const char *get_ns_name(int id)
-{
- return NULL;
-}
-#endif /* TEST_PROGRAM */
-
/* we need to fill in only namespace information */
int ns_read(pid_t pid, proc_t *ns_task)
{
@@ -35,11 +28,3 @@ int ns_read(pid_t pid, proc_t *ns_task)
}
return rc;
}
-
-#ifdef TEST_PROGRAM
-int main(int argc, char *argv[])
-{
- printf("Hello, World!\n");
- return EXIT_SUCCESS;
-}
-#endif /* TEST_PROGRAM */
diff --git a/lib/strutils.c b/lib/strutils.c
index 1b84f8a..0fd3cf7 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -60,17 +60,3 @@ double strtod_or_err(const char *str, const char *errmesg)
error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str);
return 0;
}
-
-#ifdef TEST_PROGRAM
-int main(int argc, char *argv[])
-{
- if (argc < 2) {
- error(EXIT_FAILURE, 0, "no arguments");
- } else if (argc < 3) {
- printf("%ld\n", strtol_or_err(argv[1], "strtol_or_err"));
- } else {
- printf("%lf\n", strtod_or_err(argv[2], "strtod_or_err"));
- }
- return EXIT_SUCCESS;
-}
-#endif /* TEST_PROGRAM */
diff --git a/lib/test_fileutils.c b/lib/test_fileutils.c
new file mode 100644
index 0000000..ebfc5e2
--- /dev/null
+++ b/lib/test_fileutils.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "fileutils.h"
+
+int main(int argc, char *argv[])
+{
+ atexit(close_stdout);
+ printf("Hello, World!\n");
+ return EXIT_SUCCESS;
+}
diff --git a/lib/test_nsutils.c b/lib/test_nsutils.c
new file mode 100644
index 0000000..d8f3d2c
--- /dev/null
+++ b/lib/test_nsutils.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "nsutils.h"
+
+const char *get_ns_name(int id)
+{
+ return NULL;
+}
+
+int main(int argc, char *argv[])
+{
+ printf("Hello, World!\n");
+ return EXIT_SUCCESS;
+}
diff --git a/lib/test_strutils.c b/lib/test_strutils.c
new file mode 100644
index 0000000..4a7c7aa
--- /dev/null
+++ b/lib/test_strutils.c
@@ -0,0 +1,38 @@
+/*
+ * test_strutils.c - tests for strutils.c routines
+ * This file was copied from util-linux at fall 2011.
+ *
+ * Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+ * Copyright (C) 2010 Davidlohr Bueso <dave@gnu.org>
+ *
+ * This program 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 program 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <stdlib.h>
+
+#include "c.h"
+#include "strutils.h"
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2) {
+ error(EXIT_FAILURE, 0, "no arguments");
+ } else if (argc < 3) {
+ printf("%ld\n", strtol_or_err(argv[1], "strtol_or_err"));
+ } else {
+ printf("%lf\n", strtod_or_err(argv[2], "strtod_or_err"));
+ }
+ return EXIT_SUCCESS;
+}