diff options
author | Elliott Hughes <enh@google.com> | 2014-11-03 12:32:17 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-11-03 13:46:41 -0800 |
commit | d18f4b25785761c022906b93b2123b3be90182e8 (patch) | |
tree | 5c4f679c6b6a483ac0cddea1f17a6f614edb577c /tests | |
parent | 445111a1c977e94a4233efd54f3690defa4a7582 (diff) | |
download | bionic-d18f4b25785761c022906b93b2123b3be90182e8.zip bionic-d18f4b25785761c022906b93b2123b3be90182e8.tar.gz bionic-d18f4b25785761c022906b93b2123b3be90182e8.tar.bz2 |
Ensure we initialize stdin/stdout/stderr's recursive mutexes.
(cherry-pick of 6a03abcfd23f31d1df06eb0059830e22621282bb.)
Bug: 18208568
Change-Id: I9da16ce0f9375bc363d1d02be706d73fd3b1e150
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdio_test.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index 8c8c235..6a2991f 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -29,6 +29,23 @@ #include "TemporaryFile.h" +TEST(stdio, flockfile_18208568_stderr) { + // Check that we have a _recursive_ mutex for flockfile. + flockfile(stderr); + feof(stderr); // We don't care about the result, but this needs to take the lock. + funlockfile(stderr); +} + +TEST(stdio, flockfile_18208568_regular) { + // We never had a bug for streams other than stdin/stdout/stderr, but test anyway. + FILE* fp = fopen("/dev/null", "w"); + ASSERT_TRUE(fp != NULL); + flockfile(fp); + feof(fp); + funlockfile(fp); + fclose(fp); +} + TEST(stdio, tmpfile_fileno_fprintf_rewind_fgets) { FILE* fp = tmpfile(); ASSERT_TRUE(fp != NULL); |