]> sourceware.org Git - glibc.git/commitdiff
* string/Makefile (tests): Add bug-envz1.
authorUlrich Drepper <drepper@redhat.com>
Sun, 4 Jun 2006 16:36:04 +0000 (16:36 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 4 Jun 2006 16:36:04 +0000 (16:36 +0000)
* string/bug-enz1.c: New file.

ChangeLog
string/Makefile
string/bug-envz1.c [new file with mode: 0644]

index 6999e7d1e761868b5fb773d8841e4395bb4a3176..84240b993db9f25b8b821ec5efadfdfd837eb8b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-04  Ulrich Drepper  <drepper@redhat.com>
+
+       * string/Makefile (tests): Add bug-envz1.
+       * string/bug-enz1.c: New file.
+
 2006-06-02  Jakub Jelinek  <jakub@redhat.com>
 
        * posix/regex_internal.c (re_string_skip_chars): If no character has
index 7c11c1ac22a7b27d89368c48cc20ec20c9818f45..a84ebebcaa8544d65423ef14eb3e317d1f36e463 100644 (file)
@@ -53,7 +53,8 @@ tests         := tester inl-tester noinl-tester testcopy test-ffs     \
                   tst-strlen stratcliff tst-svc tst-inlcall            \
                   bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap      \
                   tst-strtok tst-strxfrm bug-strcoll1 tst-strfry       \
-                  bug-strtok1 $(addprefix test-,$(strop-tests))
+                  bug-strtok1 $(addprefix test-,$(strop-tests))        \
+                  bug-envz1
 distribute     := memcopy.h pagecopy.h tst-svc.expect test-string.h
 
 
diff --git a/string/bug-envz1.c b/string/bug-envz1.c
new file mode 100644 (file)
index 0000000..e8a6097
--- /dev/null
@@ -0,0 +1,76 @@
+/* Test for bug BZ #2703.  */
+#include <stdio.h>
+#include <envz.h>
+#include <stdlib.h>
+#include <string.h>
+
+static const struct
+{
+  const char *s;
+  int in_result;
+} strs[] =
+{
+  { "a=1", 1 },
+  { "b=2", 1 },
+  { "(*)", 0 },
+  { "(*)", 0 },
+  { "e=5", 1 },
+  { "f=", 1 },
+  { "(*)", 0 },
+  { "h=8", 1 },
+  { "i=9", 1 },
+  { "j", 0 }
+};
+
+#define nstrs (sizeof (strs) / sizeof (strs[0]))
+
+
+static int
+do_test (void)
+{
+
+  size_t size = 0;
+  char *str = malloc (100);
+  if (str == NULL)
+    {
+      puts ("out of memory");
+      return 1;
+    }
+
+  char **argz = &str;
+
+  for (int i = 0; i < nstrs; ++i)
+    argz_add_sep (argz, &size, strs[i].s, '\0');
+
+  printf ("calling envz_strip with size=%zu\n", size);
+  envz_strip (argz, &size);
+
+  int result = 0;
+  printf ("new size=%zu\n", size);
+  for (int i = 0; i < nstrs; ++i)
+    if (strs[i].in_result)
+      {
+        char name[2];
+        name[0] = strs[i].s[0];
+        name[1] = '\0';
+
+        char *e = envz_entry (*argz, size, name);
+        if (e == NULL)
+          {
+            printf ("entry '%s' not found\n", name);
+            result = 1;
+          }
+        else if (strcmp (e, strs[i].s) != 0)
+          {
+            printf ("entry '%s' does not match: is '%s', expected '%s'\n",
+                    name, e, strs[i].s);
+            result = 1;
+          }
+      }
+
+  free (*argz);
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
This page took 0.050953 seconds and 5 git commands to generate.