diff --git a/tests/Makefile b/tests/Makefile index b8d479c99c..10d017974c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -71,6 +71,7 @@ EXPECT_NAMES=\ stdio/mutex \ stdio/popen \ stdio/printf \ + stdio/putc_unlocked \ stdio/rename \ stdio/renameat \ stdio/scanf \ diff --git a/tests/expected/bins_dynamic/stdio/putc_unlocked.stderr b/tests/expected/bins_dynamic/stdio/putc_unlocked.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/bins_dynamic/stdio/putc_unlocked.stdout b/tests/expected/bins_dynamic/stdio/putc_unlocked.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/bins_static/stdio/putc_unlocked.stderr b/tests/expected/bins_static/stdio/putc_unlocked.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/bins_static/stdio/putc_unlocked.stdout b/tests/expected/bins_static/stdio/putc_unlocked.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/stdio/putc_unlocked.c b/tests/stdio/putc_unlocked.c new file mode 100644 index 0000000000..d38a80f32b --- /dev/null +++ b/tests/stdio/putc_unlocked.c @@ -0,0 +1,24 @@ +#include +#include + +#include "test_helpers.h" + +int main(void) +{ + FILE* fp = tmpfile(); + assert(fp != NULL); + flockfile(fp); + int c = 'c', r = 0; + r = putc_unlocked(c, fp); + ERROR_IF(putc_unlocked, r, == EOF); + // TODO: hang + // r = fflush(fp); + // ERROR_IF(fflush, r, == EOF); + funlockfile(fp); + // make sure unlock works + r = putc(c, fp); + ERROR_IF(putc, r, == EOF); + r = fflush(fp); + ERROR_IF(fflush, r, == EOF); + return 0; +}