This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
>>>>> Ulrich Drepper writes: Uli> Andreas Jaeger <aj@arthur.rhein-neckar.de> writes: >> The appended test program allocates all memory with large groups - and >> fails. One problem seems to be (debug just fgetgrent) that fgetgrent >> tries to read again from the stream and doesn't move the stream back. Uli> This is fixed now. Maybe you can make this into a regression test? Appended - and it shows one bug in the last iteration. Andreas --- grp/Makefile.~1~ Sun Mar 21 14:05:19 1999 +++ grp/Makefile Tue Jun 8 08:11:08 1999 @@ -26,7 +26,7 @@ getgrent getgrgid getgrnam putgrent \ getgrent_r getgrgid_r getgrnam_r fgetgrent_r -tests := testgrp +tests := testgrp tst_fgetgrent include ../Rules 1999-06-08 Andreas Jaeger <aj@arthur.rhein-neckar.de> * grp/Makefile (tests): Add tst_fgetgrent. * grp/tst_fgetgrent: New test. /* Copyright (C) 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1999. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <grp.h> #include <stdio.h> #include <string.h> #include <sys/types.h> static int errors; static void write_users (FILE *f, int large_pos, int pos) { int i; if (pos == large_pos) { /* we need more than 2048 bytes for proper testing. */ for (i = 0; i < 500; i++) fprintf (f, ",user%03d", i); } fprintf (f, "\n"); } static void write_group (const char *filename, int pos) { FILE *f; f = fopen (filename, "w"); fprintf (f, "one:x:0:one"); write_users (f, pos, 1); fprintf (f, "two:x:1:two"); write_users (f, pos, 2); fprintf (f, "three:x:2"); write_users (f, pos, 3); fclose (f); } static void test_entry (const char *name, gid_t gid, struct group *g) { if (!g) { printf ("Error: Entry is empty\n"); errors++; return; } if ((g->gr_gid == gid) && (strcmp (g->gr_name, name) == 0)) printf ("Ok: %s: %d\n", g->gr_name, g->gr_gid); else { printf ("Error: %s: %d should be: %s: %d\n", g->gr_name, g->gr_gid, name, gid); errors++; } } static void test_fgetgrent (const char *filename) { struct group *g; FILE *f; f = fopen (filename,"r"); g = fgetgrent (f); test_entry ("one", 0, g); g = fgetgrent (f); test_entry ("two", 1, g); g = fgetgrent (f); test_entry ("three", 2, g); fclose (f); } int main (void) { char *file = tmpnam (NULL); int i; for (i = 0; i < 4; i++) { printf ("Pass %d\n", i); write_group (file, i); test_fgetgrent (file); } remove (file); return (errors != 0); } -- Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |