aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-05-31 09:16:06 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2013-06-01 01:10:43 +0300
commit64e785dd033ca86bd9c501bbe87ce18ea964fc5b (patch)
tree68321e3e5ab4e0ad71be5820aaeacd0611b7e72f
parented9dc5e5432f58826265013b1c5f085fae0bfa37 (diff)
downloaddirevent-64e785dd033ca86bd9c501bbe87ce18ea964fc5b.tar.gz
direvent-64e785dd033ca86bd9c501bbe87ce18ea964fc5b.tar.bz2
Add tests directory.
* Makefile.am (SUBDIRS): Add tests * configure.ac: Build tests/Makefile. * tests/.gitignore: New file * tests/Makefile.am: New file. * tests/envdump.c: New file.
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac3
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/envdump.c49
5 files changed, 54 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 6588ee9..e9211a3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I grecs/am
-SUBDIRS=grecs src doc
+SUBDIRS=grecs src tests doc
.PHONY: ChangeLog
ChangeLog:
diff --git a/configure.ac b/configure.ac
index d046c5d..f93489d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,5 +74,6 @@ iface=$iface
AC_CONFIG_FILES([Makefile
src/Makefile
- doc/Makefile])
+ doc/Makefile
+ tests/Makefile])
AC_OUTPUT
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..52fb945
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
+envdump
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..a1a518f
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS=envdump
diff --git a/tests/envdump.c b/tests/envdump.c
new file mode 100644
index 0000000..a3eed08
--- /dev/null
+++ b/tests/envdump.c
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+extern char **environ;
+
+int
+main(int argc, char **argv)
+{
+ int i;
+ char *buf = NULL;
+ size_t bufsize = 128;
+
+ for (;;) {
+ char *cwd;
+
+ errno = 0;
+ buf = malloc(bufsize);
+ if (!buf) {
+ fprintf(stderr, "%s: not enough memory\n", argv[0]);
+ break;
+ }
+ if (getcwd(buf, bufsize))
+ break;
+ free(buf);
+ if (errno != ERANGE) {
+ fprintf(stderr, "%s: ", argv[0]);
+ perror("getcwd");
+ buf = NULL;
+ break;
+ }
+
+ bufsize += bufsize / 16;
+ bufsize += 32;
+ }
+ printf("# Dump of execution environment\n");
+ if (buf)
+ printf("cwd is %s\n", buf);
+ printf("# Arguments\n");
+ for (i = 0; i < argc; i++)
+ printf("argv[%d]=%s\n", i, argv[i]);
+ printf("# Environment\n");
+ for (i = 0; environ[i]; i++)
+ printf("%s\n", environ[i]);
+ printf("# End\n");
+ return 0;
+}
+

Return to:

Send suggestions and report system problems to the System administrator.