From 1e587dc77b42426f0ccac821ad355ed87ae0d400 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Mon, 5 Jan 2026 12:43:51 +0700 Subject: [PATCH] Add putc_unlocked tests --- tests/Makefile | 1 + .../bins_dynamic/stdio/putc_unlocked.stderr | 0 .../bins_dynamic/stdio/putc_unlocked.stdout | 0 .../bins_static/stdio/putc_unlocked.stderr | 0 .../bins_static/stdio/putc_unlocked.stdout | 0 tests/stdio/putc_unlocked.c | 24 +++++++++++++++++++ 6 files changed, 25 insertions(+) create mode 100644 tests/expected/bins_dynamic/stdio/putc_unlocked.stderr create mode 100644 tests/expected/bins_dynamic/stdio/putc_unlocked.stdout create mode 100644 tests/expected/bins_static/stdio/putc_unlocked.stderr create mode 100644 tests/expected/bins_static/stdio/putc_unlocked.stdout create mode 100644 tests/stdio/putc_unlocked.c 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; +}