This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Some fixes to the locale tests


Here is a small patch to improve error reporting and make sure
comments are ignored in the data files for tst-fmon and tst-numeric.

2003-04-30  Petter Reinholdtsen  <pere@hungry.com>

	* tst-fmon.c: Report name of locale if setlocale() fails.
	* tst-numeric.c: Likewise.

	* tst-fmon.sh: Ignore lines starting with hash '#' in the data file.
	* tst-numeric.sh: Likewise.


Index: localedata/tst-fmon.c
===================================================================
RCS file: /cvs/glibc/libc/localedata/tst-fmon.c,v
retrieving revision 1.5
diff -u -3 -p -u -r1.5 tst-fmon.c
--- localedata/tst-fmon.c	6 Jul 2001 04:55:34 -0000	1.5
+++ localedata/tst-fmon.c	30 Apr 2003 07:16:30 -0000
@@ -23,6 +23,7 @@
 #include <monetary.h>
 #include <string.h>
 #include <stdlib.h>
+#include <errno.h>
 
 /*
   test-strfmon gets called with three parameters:
@@ -46,7 +47,8 @@ main (int argc, char *argv[])
 
   if (setlocale (LC_MONETARY, argv[1]) == NULL)
     {
-      perror ("setlocale");
+      fprintf(stderr, "setlocale(LC_MONETARY, \"%s\"): %s", argv[1],
+	      strerror(errno));
       exit (EXIT_SETLOCALE);
     }
   /* This is locale-dependent! see setlocale(3) for details */
Index: localedata/tst-numeric.c
===================================================================
RCS file: /cvs/glibc/libc/localedata/tst-numeric.c,v
retrieving revision 1.1
diff -u -3 -p -u -r1.1 tst-numeric.c
--- localedata/tst-numeric.c	27 Apr 2003 09:02:25 -0000	1.1
+++ localedata/tst-numeric.c	30 Apr 2003 07:16:31 -0000
@@ -24,6 +24,7 @@
 #include <locale.h>
 #include <string.h>
 #include <stdlib.h>
+#include <errno.h>
 
 /*
   test-numeric gets called with three parameters:
@@ -51,7 +52,8 @@ main (int argc, char *argv[])
 
   if (setlocale (LC_ALL, argv[1]) == NULL)
     {
-      perror ("setlocale");
+      fprintf(stderr, "setlocale(LC_ALL, \"%s\"): %s", argv[1],
+	      strerror(errno));
       exit (EXIT_SETLOCALE);
     }
 
Index: localedata/tst-fmon.sh
===================================================================
RCS file: /cvs/glibc/libc/localedata/tst-fmon.sh,v
retrieving revision 1.12
diff -u -3 -p -u -r1.12 tst-fmon.sh
--- localedata/tst-fmon.sh	6 Jul 2001 04:55:34 -0000	1.12
+++ localedata/tst-fmon.sh	30 Apr 2003 07:16:31 -0000
@@ -40,6 +40,7 @@ done
 
 # Run the tests.
 # There's a TAB for IFS
+grep -v "^#" $datafile |
 while IFS="	" read locale format value expect; do
     if [ -n "$format" ]; then
 	LOCPATH=${common_objpfx}localedata \
@@ -54,7 +55,7 @@ while IFS="	" read locale format value e
 		 "Value: \"${value}\" Expect: \"${expect}\"    failed"
 	fi
     fi
-done < $datafile
+done
 
 exit $?
 # Local Variables:
Index: localedata/tst-numeric.sh
===================================================================
RCS file: /cvs/glibc/libc/localedata/tst-numeric.sh,v
retrieving revision 1.1
diff -u -3 -p -u -r1.1 tst-numeric.sh
--- localedata/tst-numeric.sh	27 Apr 2003 09:02:25 -0000	1.1
+++ localedata/tst-numeric.sh	30 Apr 2003 07:16:31 -0000
@@ -26,6 +26,7 @@ datafile=$3
 
 # Run the tests.
 # There's a TAB for IFS
+grep -v "^#" $datafile |
 while IFS="	" read locale format value expect; do
     if [ -n "$format" ]; then
 	LOCPATH=${common_objpfx}localedata \
@@ -40,7 +41,7 @@ while IFS="	" read locale format value e
 		 "Value: \"${value}\" Expect: \"${expect}\"    failed"
 	fi
     fi
-done < $datafile
+done
 
 exit $?
 # Local Variables:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]