summaryrefslogtreecommitdiff
path: root/tests/stdio_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-01-25 18:31:35 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-01-25 18:31:35 +0000
commit05db62657b7f44e303fb47fb502555059eb6ec61 (patch)
tree3d19dfb91698de780cfcffaaa872aa1ac6eb5c2a /tests/stdio_test.cpp
parent8fb40bad496c680b5ca644dbf6a2ada79a239eee (diff)
parent71288cbfdfe138a7f0d59fa2e642dc6e2317eb6d (diff)
Merge "Add another stdio test."
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r--tests/stdio_test.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 31acfec90..a7df78448 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -1093,3 +1093,31 @@ TEST(STDIO_TEST, fseek_ftell_unseekable) {
fclose(fp);
#endif
}
+
+TEST(STDIO_TEST, lots_of_concurrent_files) {
+ std::vector<TemporaryFile*> tfs;
+ std::vector<FILE*> fps;
+
+ for (size_t i = 0; i < 256; ++i) {
+ TemporaryFile* tf = new TemporaryFile;
+ tfs.push_back(tf);
+ FILE* fp = fopen(tf->filename, "w+");
+ fps.push_back(fp);
+ fprintf(fp, "hello %zu!\n", i);
+ fflush(fp);
+ }
+
+ for (size_t i = 0; i < 256; ++i) {
+ rewind(fps[i]);
+
+ char buf[BUFSIZ];
+ ASSERT_TRUE(fgets(buf, sizeof(buf), fps[i]) != nullptr);
+
+ char expected[BUFSIZ];
+ snprintf(expected, sizeof(expected), "hello %zu!\n", i);
+ ASSERT_STREQ(expected, buf);
+
+ fclose(fps[i]);
+ delete tfs[i];
+ }
+}