summaryrefslogtreecommitdiff
path: root/dirent/tst-seekdir.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /dirent/tst-seekdir.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
2.5-18.1
Diffstat (limited to 'dirent/tst-seekdir.c')
-rw-r--r--dirent/tst-seekdir.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/dirent/tst-seekdir.c b/dirent/tst-seekdir.c
index b833c30705..43808fecb5 100644
--- a/dirent/tst-seekdir.c
+++ b/dirent/tst-seekdir.c
@@ -11,8 +11,23 @@ main (int argc, char *argv[])
int i = 0;
int result = 0;
struct dirent *dp;
+ long int save0;
+ long int rewind;
dirp = opendir (".");
+ if (dirp == NULL)
+ {
+ printf ("opendir failed: %m\n");
+ return 1;
+ }
+
+ save0 = telldir (dirp);
+ if (save0 == -1)
+ {
+ printf ("telldir failed: %m\n");
+ result = 1;
+ }
+
for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp))
{
/* save position 3 (after fourth entry) */
@@ -44,6 +59,19 @@ main (int argc, char *argv[])
for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp))
printf ("%s\n", dp->d_name);
+ /* Check rewinddir */
+ rewinddir (dirp);
+ rewind = telldir (dirp);
+ if (rewind == -1)
+ {
+ printf ("telldir failed: %m\n");
+ result = 1;
+ }
+ else if (save0 != rewind)
+ {
+ printf ("rewinddir didn't reset directory stream\n");
+ result = 1;
+ }
closedir (dirp);
return result;