1.1 --- a/tests/dstest_file_readdir.cc Mon May 06 01:14:09 2024 +0200
1.2 +++ b/tests/dstest_file_readdir.cc Thu May 09 16:46:44 2024 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Test directory reading operations.
1.6 *
1.7 - * Copyright (C) 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2020, 2021, 2022, 2024 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -122,16 +122,36 @@
1.13 return 1;
1.14 }
1.15
1.16 + char *name = NULL;
1.17 +
1.18 dirent = client_readdir(reader);
1.19
1.20 if (dirent != NULL)
1.21 {
1.22 + name = strdup(dirent->d_name);
1.23 printf("> %s\n", dirent->d_name);
1.24 free(dirent);
1.25 }
1.26
1.27 printf("Entry shown.\n");
1.28
1.29 + /* Rewind to show the same entry. */
1.30 +
1.31 + char *name2 = NULL;
1.32 +
1.33 + client_rewinddir(reader);
1.34 +
1.35 + dirent = client_readdir(reader);
1.36 +
1.37 + if (dirent != NULL)
1.38 + {
1.39 + name2 = strdup(dirent->d_name);
1.40 + printf("> %s\n", dirent->d_name);
1.41 + free(dirent);
1.42 + }
1.43 +
1.44 + printf("Entry shown and identical: %s\n", (name != NULL) && (name2 != NULL) && !strcmp(name, name2) ? "True" : "False");
1.45 +
1.46 printf("End of test.\n");
1.47 return 0;
1.48 }