Add putc_unlocked tests

This commit is contained in:
Wildan M
2026-01-05 12:43:51 +07:00
parent 79f88ab6ad
commit 1e587dc77b
6 changed files with 25 additions and 0 deletions
+1
View File
@@ -71,6 +71,7 @@ EXPECT_NAMES=\
stdio/mutex \
stdio/popen \
stdio/printf \
stdio/putc_unlocked \
stdio/rename \
stdio/renameat \
stdio/scanf \
+24
View File
@@ -0,0 +1,24 @@
#include <assert.h>
#include <stdio.h>
#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;
}