git » libfiu » commit 94e897a

tests: Add tests for some of the new stdio functions

author Alberto Bertogli
2018-09-26 19:14:37 UTC
committer Alberto Bertogli
2018-09-26 19:14:37 UTC
parent 3481b5cce4827ea774ea86e572967274c97e9705

tests: Add tests for some of the new stdio functions

This patch adds tests for some of the new stdio functions (fopen(),
fread(), and fprintf()).

They're implemented using the test auto-generation infrastructure.

tests/generated/tests/fopen.conf +9 -0
tests/generated/tests/fprintf.conf +10 -0
tests/generated/tests/fread.conf +10 -0

diff --git a/tests/generated/tests/fopen.conf b/tests/generated/tests/fopen.conf
new file mode 100644
index 0000000..25e057b
--- /dev/null
+++ b/tests/generated/tests/fopen.conf
@@ -0,0 +1,9 @@
+
+[fopen]
+fp: posix/stdio/oc/fopen
+include: stdio.h
+prep: FILE *fp;
+call: fp = fopen("/dev/null", "r");
+success_cond: fp != NULL
+failure_cond: fp == NULL
+errno_on_fail: ELOOP
diff --git a/tests/generated/tests/fprintf.conf b/tests/generated/tests/fprintf.conf
new file mode 100644
index 0000000..f8ed16e
--- /dev/null
+++ b/tests/generated/tests/fprintf.conf
@@ -0,0 +1,10 @@
+
+[fprintf]
+fp: posix/stdio/sp/fprintf
+include: stdio.h
+prep: int r; FILE *fp = fopen("/dev/null", "w");
+call: r = fprintf(fp, "%%d\n", 1234);
+success_cond: r == 5 && ferror(fp) == 0
+failure_cond: r == -1 && ferror(fp) != 0
+errno_on_fail: EIO
+
diff --git a/tests/generated/tests/fread.conf b/tests/generated/tests/fread.conf
new file mode 100644
index 0000000..5eee474
--- /dev/null
+++ b/tests/generated/tests/fread.conf
@@ -0,0 +1,10 @@
+
+[fread]
+fp: posix/stdio/rw/fread
+include: stdio.h
+prep: unsigned char buf[1024]; ssize_t r; FILE *fp = fopen("/dev/zero", "r");
+call: r = fread(buf, 1, 1024, fp);
+success_cond: r == 1024 && ferror(fp) == 0
+failure_cond: r == 0 && ferror(fp) != 0
+errno_on_fail: EIO
+