about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-01-04 07:48:13 +0000
committerUlrich Drepper <drepper@redhat.com>2005-01-04 07:48:13 +0000
commit574b268e7f7a76fe3bcfe389509d9ff91227a860 (patch)
treeee213b8410cd034b34d72858e2488125359dc88f /stdlib
parent3fb2606af3b1ab6e6bef7065c65eaca197d73a89 (diff)
downloadglibc-574b268e7f7a76fe3bcfe389509d9ff91227a860.tar.gz
glibc-574b268e7f7a76fe3bcfe389509d9ff91227a860.tar.xz
glibc-574b268e7f7a76fe3bcfe389509d9ff91227a860.zip
Update.
	* stdlib/Makefile: Add rules to build and run tst-putenv.
	* stdlib/tst-putenv.c: New file.
	* stdlib/tst-putenvmod.c: New file.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/Makefile23
-rw-r--r--stdlib/tst-putenv.c18
-rw-r--r--stdlib/tst-putenvmod.c17
3 files changed, 53 insertions, 5 deletions
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 5f4675033e..b766fb8656 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -65,6 +65,11 @@ tests		:= tst-strtol tst-strtod testmb testrand testsort testdiv   \
 		   tst-rand48 bug-strtod tst-setcontext test-a64l tst-qsort \
 		   tst-system testmb2
 
+include ../Makeconfig
+
+ifeq ($(build-shared),yes)
+tests		+= tst-putenv
+endif
 
 # Several mpn functions from GNU MP are used by the strtod function.
 mpn-routines := inlines add_n addmul_1 cmp divmod_1 divrem udiv_qrnnd \
@@ -75,9 +80,13 @@ routines := $(strip $(routines) $(mpn-routines))	\
 	    dbl2mpn ldbl2mpn				\
 	    mpn2flt mpn2dbl mpn2ldbl
 aux += fpioconst mp_clz_tab
-distribute := $(distribute) $(mpn-headers) gen-mpn-copy fpioconst.h
+distribute := $(distribute) $(mpn-headers) gen-mpn-copy fpioconst.h \
+	      tst-putenvmod.c
+
+tests-extras += tst-putenvmod
+extra-objs += tst-putenvmod.os
 
-generated += isomac isomac.out
+generated += isomac isomac.out tst-putenvmod.so
 
 CFLAGS-bsearch.c = $(uses-callbacks)
 CFLAGS-msort.c = $(uses-callbacks)
@@ -85,8 +94,6 @@ CFLAGS-qsort.c = $(uses-callbacks)
 CFLAGS-system.c = -fexceptions
 CFLAGS-fmtmsg.c = -fexceptions
 
-include ../Makeconfig
-
 ifneq (,$(filter %REENTRANT, $(defines)))
 CFLAGS-strfmon.c = -D_IO_MTSAFE_IO
 CFLAGS-strfmon_l.c = -D_IO_MTSAFE_IO
@@ -124,3 +131,9 @@ $(objpfx)isomac: isomac.c
 
 $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
 	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)stdlib/
+
+$(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
+
+$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os
+	$(build-module)
+CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1
diff --git a/stdlib/tst-putenv.c b/stdlib/tst-putenv.c
new file mode 100644
index 0000000000..47513ea42b
--- /dev/null
+++ b/stdlib/tst-putenv.c
@@ -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
index 0000000000..7c0c337d3f
--- /dev/null
+++ b/stdlib/tst-putenvmod.c
@@ -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);
+    }
+}