about summary refs log tree commit diff
path: root/stdlib/tst-bsearch.c
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2000-09-07 14:54:03 +0000
committerAndreas Jaeger <aj@suse.de>2000-09-07 14:54:03 +0000
commit9aee41dec0608dad42d95b76ee0245a9bd7abee5 (patch)
treeb81413fbc2965550dd745e25f28317340cde4321 /stdlib/tst-bsearch.c
parentc5914fa7ccbfeef72a6303114cf845be5cac1a53 (diff)
downloadglibc-9aee41dec0608dad42d95b76ee0245a9bd7abee5.tar.gz
glibc-9aee41dec0608dad42d95b76ee0245a9bd7abee5.tar.xz
glibc-9aee41dec0608dad42d95b76ee0245a9bd7abee5.zip
Update.
	* sysdeps/unix/sysv/linux/mips/syscalls.list: Add __syscall_fcntl.

	* sysdeps/mips/dl-machine.h (RESOLVE_GOTSYM): Fix calls to
	dl_lookup.
	(ELF_MACHINE_RUNTIME_TRAMPOLINE): Likewise.

	* sysdeps/unix/sysv/linux/mips/fcntl.c: New file.

	* stdlib/tst-bsearch.c (main): Add more test cases.
Diffstat (limited to 'stdlib/tst-bsearch.c')
-rw-r--r--stdlib/tst-bsearch.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/stdlib/tst-bsearch.c b/stdlib/tst-bsearch.c
index 2d067c3acc..0f3db24fd5 100644
--- a/stdlib/tst-bsearch.c
+++ b/stdlib/tst-bsearch.c
@@ -56,11 +56,11 @@ main (void)
 {
   int cnt;
   int result = 0;
+  struct entry key;
+  struct entry *res;
 
   for (cnt = 0; cnt < narr; ++cnt)
     {
-      struct entry key;
-      struct entry *res;
 
       key.val = arr[cnt].val;
 
@@ -77,6 +77,57 @@ main (void)
 	}
     }
 
+  /* And some special tests that shouldn't find any entry.  */
+  key.val = -1;
+  res = (struct entry *) bsearch (&key, arr, narr, sizeof (arr[0]), comp);
+  if (res != NULL)
+    {
+      puts ("found an entry that's not there");
+      result = 1;
+    }
+
+  key.val = 11;
+  res = (struct entry *) bsearch (&key, arr, narr, sizeof (arr[0]), comp);
+  if (res != NULL)
+    {
+      puts ("found an entry that's not there");
+      result = 1;
+    }
+
+  key.val = 11;
+  res = (struct entry *) bsearch (&key, arr, 0, sizeof (arr[0]), comp);
+  if (res != NULL)
+    {
+      puts ("found an entry that's not there");
+      result = 1;
+    }
+  
+  /* Now the array contains only one element - no entry should be found.  */
+  for (cnt = 0; cnt < narr; ++cnt)
+    {
+      key.val = arr[cnt].val;
+
+      res = (struct entry *) bsearch (&key, &arr[5], 1, sizeof (arr[0]), comp);
+      if (cnt == 5)
+	{
+	  if (res == NULL)
+	    {
+	      printf ("entry %d not found\n", cnt);
+	      result = 1;
+	    }
+	  else if (res != &arr[cnt])
+	    {
+	      puts ("wrong entry returned");
+	      result = 1;
+	    }
+	}
+      else if (res != NULL)
+	{
+	  puts ("found an entry that's not there");
+	  result = 1;
+	}
+    }
+
   if (result == 0)
     puts ("all OK");