Test for early putenv use.
authordrepper <drepper>
Tue, 4 Jan 2005 07:46:46 +0000 (07:46 +0000)
committerdrepper <drepper>
Tue, 4 Jan 2005 07:46:46 +0000 (07:46 +0000)
stdlib/tst-putenv.c [new file with mode: 0644]
stdlib/tst-putenvmod.c [new file with mode: 0644]

diff --git a/stdlib/tst-putenv.c b/stdlib/tst-putenv.c
new file mode 100644 (file)
index 0000000..47513ea
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+  char *p = getenv ("SOMETHING_NOBODY_USES");
+  if (p == NULL)
+    {
+      puts ("envvar not defined");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/stdlib/tst-putenvmod.c b/stdlib/tst-putenvmod.c
new file mode 100644 (file)
index 0000000..7c0c337
--- /dev/null
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+void
+__attribute ((constructor))
+init (void)
+{
+  puts ("init DSO");
+
+  static char str[] = "SOMETHING_NOBODY_USES=something_else";
+  if (putenv (str) != 0)
+    {
+      puts ("putenv failed");
+      _exit (1);
+    }
+}