svn commit: trunk/uClibc/test: misc regex

psm at uclibc.org psm at uclibc.org
Wed Mar 1 20:39:50 UTC 2006


Author: psm
Date: 2006-03-01 12:39:48 -0800 (Wed, 01 Mar 2006)
New Revision: 14402

Log:
Move regex tests to their own subdir and dont run them if regex is disabled

Added:
   trunk/uClibc/test/regex/tst-regex2.c
   trunk/uClibc/test/regex/tst-regexloc.c

Removed:
   trunk/uClibc/test/misc/tst-regex2.c
   trunk/uClibc/test/misc/tst-regexloc.c

Modified:
   trunk/uClibc/test/Makefile
   trunk/uClibc/test/misc/Makefile
   trunk/uClibc/test/regex/Makefile


Changeset:
Modified: trunk/uClibc/test/Makefile
===================================================================
--- trunk/uClibc/test/Makefile	2006-03-01 20:35:48 UTC (rev 14401)
+++ trunk/uClibc/test/Makefile	2006-03-01 20:39:48 UTC (rev 14402)
@@ -24,6 +24,9 @@
 ifneq ($(UCLIBC_HAS_FULL_RPC),y)
 	DIRS := $(filter-out rpc,$(DIRS))
 endif
+ifneq ($(UCLIBC_HAS_REGEX),y)
+	DIRS := $(filter-out regex,$(DIRS))
+endif
 DIRS := $(filter-out math,$(DIRS))
 
 

Modified: trunk/uClibc/test/misc/Makefile
===================================================================
--- trunk/uClibc/test/misc/Makefile	2006-03-01 20:35:48 UTC (rev 14401)
+++ trunk/uClibc/test/misc/Makefile	2006-03-01 20:39:48 UTC (rev 14402)
@@ -6,7 +6,6 @@
 include ../Test.mak
 
 CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-CFLAGS_tst-regex2 := -std=c99
 
 DODIFF_dirent    := 1
 DODIFF_dirent64  := 1

Deleted: trunk/uClibc/test/misc/tst-regex2.c
===================================================================
--- trunk/uClibc/test/misc/tst-regex2.c	2006-03-01 20:35:48 UTC (rev 14401)
+++ trunk/uClibc/test/misc/tst-regex2.c	2006-03-01 20:39:48 UTC (rev 14402)
@@ -1,244 +0,0 @@
-#include <fcntl.h>
-#include <locale.h>
-#include <regex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <unistd.h>
-#include <errno.h>
-
-#undef _POSIX_CPUTIME
-#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
-static clockid_t cl;
-static int use_clock;
-#endif
-
-static int
-do_test (void)
-{
-#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
-# if _POSIX_CPUTIME == 0
-  if (sysconf (_SC_CPUTIME) < 0)
-    use_clock = 0;
-  else
-# endif
-    /* See whether we can use the CPU clock.  */
-    use_clock = clock_getcpuclockid (0, &cl) == 0;
-#endif
-
-  static const char *pat[] = {
-    ".?.?.?.?.?.?.?Log\\.13",
-    "(.?)(.?)(.?)(.?)(.?)(.?)(.?)Log\\.13",
-    "((((((((((.?))))))))))((((((((((.?))))))))))((((((((((.?))))))))))"
-    "((((((((((.?))))))))))((((((((((.?))))))))))((((((((((.?))))))))))"
-    "((((((((((.?))))))))))Log\\.13" };
-
-  int fd = open (".regex.ChangeLog.14", O_RDONLY);
-  if (fd < 0)
-    {
-      printf ("Couldn't open .regex.ChangeLog.14: %s\n", strerror(errno));
-      return 1;
-    }
-
-  struct stat64 st;
-  if (fstat64 (fd, &st) < 0)
-    {
-      printf ("Couldn't fstat ChangeLog.14: %s\n", strerror(errno));
-      return 1;
-    }
-
-  char *buf = malloc (st.st_size + 1);
-  if (buf == NULL)
-    {
-      printf ("Couldn't allocate buffer: %s\n", strerror(errno));
-      return 1;
-    }
-
-  if (read (fd, buf, st.st_size) != (ssize_t) st.st_size)
-    {
-      puts ("Couldn't read ChangeLog.14");
-      return 1;
-    }
-
-  close (fd);
-  buf[st.st_size] = '\0';
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-  setlocale (LC_ALL, "de_DE.UTF-8");
-#endif
-
-  char *string = buf;
-  size_t len = st.st_size;
-
-  for (int testno = 0; testno < 4; ++testno)
-    for (int i = 0; i < sizeof (pat) / sizeof (pat[0]); ++i)
-      {
-	printf ("test %d pattern %d", testno, i);
-
-	regex_t rbuf;
-	struct re_pattern_buffer rpbuf;
-	int err;
-	if (testno < 2)
-	  {
-	    err = regcomp (&rbuf, pat[i],
-			   REG_EXTENDED | (testno ? REG_NOSUB : 0));
-	    if (err != 0)
-	      {
-		putchar ('\n');
-		char errstr[300];
-		regerror (err, &rbuf, errstr, sizeof (errstr));
-		puts (errstr);
-		return err;
-	      }
-	  }
-	else
-	  {
-	    re_set_syntax (RE_SYNTAX_POSIX_EGREP
-			   | (testno == 3 ? RE_NO_SUB : 0));
-
-	    memset (&rpbuf, 0, sizeof (rpbuf));
-	    const char *s = re_compile_pattern (pat[i], strlen (pat[i]),
-						&rpbuf);
-	    if (s != NULL)
-	      {
-		printf ("\n%s\n", s);
-		return 1;
-	      }
-
-	    /* Just so that this can be tested with earlier glibc as well.  */
-	    if (testno == 3)
-	      rpbuf.no_sub = 1;
-	  }
-
-#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
-      struct timespec start, stop;
-      if (use_clock)
-	use_clock = clock_gettime (cl, &start) == 0;
-#endif
-
-      if (testno < 2)
-	{
-	  regmatch_t pmatch[71];
-	  err = regexec (&rbuf, string, 71, pmatch, 0);
-	  if (err == REG_NOMATCH)
-	    {
-	      puts ("\nregexec failed");
-	      return 1;
-	    }
-
-	  if (testno == 0)
-	    {
-	      if (pmatch[0].rm_eo != pmatch[0].rm_so + 13
-		  || pmatch[0].rm_eo > len
-		  || pmatch[0].rm_so < len - 100
-		  || strncmp (string + pmatch[0].rm_so,
-			      " ChangeLog.13 for earlier changes",
-			      sizeof " ChangeLog.13 for earlier changes" - 1)
-		     != 0)
-		{
-		  puts ("\nregexec without REG_NOSUB did not find the correct match");
-		  return 1;
-		}
-
-	      if (i > 0)
-		for (int j = 0, l = 1; j < 7; ++j)
-		  for (int k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
-		    if (pmatch[l].rm_so != pmatch[0].rm_so + j
-			|| pmatch[l].rm_eo != pmatch[l].rm_so + 1)
-		      {
-			printf ("\npmatch[%d] incorrect\n", l);
-			return 1;
-		      }
-	    }
-	}
-      else
-	{
-	  struct re_registers regs;
-
-	  memset (&regs, 0, sizeof (regs));
-	  int match = re_search (&rpbuf, string, len, 0, len,
-				 &regs);
-	  if (match < 0)
-	    {
-	      puts ("\nre_search failed");
-	      return 1;
-	    }
-
-	  if (match + 13 > len
-	      || match < len - 100
-	      || strncmp (string + match,
-			  " ChangeLog.13 for earlier changes",
-			  sizeof " ChangeLog.13 for earlier changes" - 1)
-		  != 0)
-	    {
-	      puts ("\nre_search did not find the correct match");
-	      return 1;
-	    }
-
-	  if (testno == 2)
-	    {
-	      if (regs.num_regs != 2 + (i == 0 ? 0 : i == 1 ? 7 : 70))
-		{
-		  printf ("\nincorrect num_regs %d\n", regs.num_regs);
-		  return 1;
-		}
-
-	      if (regs.start[0] != match || regs.end[0] != match + 13)
-		{
-		  printf ("\nincorrect regs.{start,end}[0] = { %d, %d}\n",
-			  regs.start[0], regs.end[0]);
-		  return 1;
-		}
-
-	      if (regs.start[regs.num_regs - 1] != -1
-		  || regs.end[regs.num_regs - 1] != -1)
-		{
-		  puts ("\nincorrect regs.{start,end}[num_regs - 1]");
-		  return 1;
-		}
-
-	      if (i > 0)
-		for (int j = 0, l = 1; j < 7; ++j)
-		  for (int k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
-		    if (regs.start[l] != match + j
-			|| regs.end[l] != regs.start[l] + 1)
-		      {
-			printf ("\nregs.{start,end}[%d] incorrect\n", l);
-			return 1;
-		      }
-	    }
-	}
-
-#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
-      if (use_clock)
-	use_clock = clock_gettime (cl, &stop) == 0;
-      if (use_clock)
-	{
-	  stop.tv_sec -= start.tv_sec;
-	  if (stop.tv_nsec < start.tv_nsec)
-	    {
-	      stop.tv_sec--;
-	      stop.tv_nsec += 1000000000 - start.tv_nsec;
-	    }
-	  else
-	    stop.tv_nsec -= start.tv_nsec;
-	  printf (": %ld.%09lds\n", (long) stop.tv_sec, (long) stop.tv_nsec);
-	}
-      else
-#endif
-	putchar ('\n');
-
-      if (testno < 2)
-	regfree (&rbuf);
-      else
-	regfree (&rpbuf);
-    }
-
-  return 0;
-}
-
-#define TIMEOUT 20
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"

Deleted: trunk/uClibc/test/misc/tst-regexloc.c
===================================================================
--- trunk/uClibc/test/misc/tst-regexloc.c	2006-03-01 20:35:48 UTC (rev 14401)
+++ trunk/uClibc/test/misc/tst-regexloc.c	2006-03-01 20:39:48 UTC (rev 14402)
@@ -1,48 +0,0 @@
-/* Copyright (C) 2001 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
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include <sys/types.h>
-#include <regex.h>
-#include <locale.h>
-#include <stdio.h>
-
-int
-main (int argc, char *argv[])
-{
-#ifdef __UCLIBC_HAS_XLOCALE__
-  regex_t re;
-  regmatch_t mat[1];
-  int res = 1;
-
-  if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)
-    puts ("cannot set locale");
-  else if (regcomp (&re, "[a-f]*", 0) != REG_NOERROR)
-    puts ("cannot compile expression \"[a-f]*\"");
-  else if (regexec (&re, "abcdefCDEF", 1, mat, 0) == REG_NOMATCH)
-    puts ("no match");
-  else
-    {
-      printf ("match from %d to %d\n", mat[0].rm_so, mat[0].rm_eo);
-      res = mat[0].rm_so != 0 || mat[0].rm_eo != 6;
-    }
-
-  return res;
-#else
-  return 0;
-#endif
-}

Modified: trunk/uClibc/test/regex/Makefile
===================================================================
--- trunk/uClibc/test/regex/Makefile	2006-03-01 20:35:48 UTC (rev 14401)
+++ trunk/uClibc/test/regex/Makefile	2006-03-01 20:39:48 UTC (rev 14402)
@@ -5,6 +5,8 @@
 
 include ../Test.mak
 
+CFLAGS_tst-regex2 := -std=c99
+
 CFLAGS-OMIT_testregex.c := -D_GNU_SOURCE
 CFLAGS-OMIT_testregexc.c := -D_GNU_SOURCE
 CFLAGS-OMIT_testregexf.c := -D_GNU_SOURCE

Copied: trunk/uClibc/test/regex/tst-regex2.c (from rev 14384, trunk/uClibc/test/misc/tst-regex2.c)

Copied: trunk/uClibc/test/regex/tst-regexloc.c (from rev 14384, trunk/uClibc/test/misc/tst-regexloc.c)




More information about the uClibc-cvs mailing list