summary refs log tree commit diff
path: root/stdlib/tst-environ.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/tst-environ.c')
-rw-r--r--stdlib/tst-environ.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/stdlib/tst-environ.c b/stdlib/tst-environ.c
index 52c26e8391..6dd9a40527 100644
--- a/stdlib/tst-environ.c
+++ b/stdlib/tst-environ.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2004 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
@@ -16,6 +16,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -173,5 +174,49 @@ main (void)
       result = 1;
     }
 
+  /* Both setenv and unsetenv should return -1/EINVAL for NULL or "" name
+     or if name contains '=' character.  */
+  errno = 0;
+  if (setenv (NULL, "val", 1) >= 0 || errno != EINVAL)
+    {
+      puts ("setenv #4 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (setenv ("", "val", 0) >= 0 || errno != EINVAL)
+    {
+      puts ("setenv #5 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (setenv ("var=val", "val", 1) >= 0 || errno != EINVAL)
+    {
+      puts ("setenv #6 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (unsetenv (NULL) >= 0 || errno != EINVAL)
+    {
+      puts ("unsetenv #1 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (unsetenv ("") >= 0 || errno != EINVAL)
+    {
+      puts ("unsetenv #2 failed");
+      result = 1;
+    }
+
+  errno = 0;
+  if (unsetenv ("x=y") >= 0 || errno != EINVAL)
+    {
+      puts ("unsetenv #3 failed");
+      result = 1;
+    }
+
   return result;
 }