From 1ac960d8f38b12fe66bc5586a2ecd6927a119c3f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 25 Mar 2016 02:07:03 +1300 Subject: Add write test --- .gitignore | 1 + tests/Makefile | 2 +- tests/write.c | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/write.c diff --git a/.gitignore b/.gitignore index 804eaa0..0180353 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ tests/files tests/mem tests/stack +tests/write diff --git a/tests/Makefile b/tests/Makefile index abc4fc5..d14df80 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,5 +2,5 @@ CC = clang -all : files mem stack +all : files mem stack write diff --git a/tests/write.c b/tests/write.c new file mode 100644 index 0000000..5ccbc90 --- /dev/null +++ b/tests/write.c @@ -0,0 +1,22 @@ +#include +#include + +int main(void) { + FILE *fp = NULL; + int b = 1; + char c = '\0'; + if ((fp = tmpfile()) == NULL) { + perror("tmpfile"); + raise(SIGABRT); + } + for (;;b++) { + if (fwrite(&c, 1, 1, fp) == 0) { + perror("fwrite"); + raise(SIGABRT); + } + if (b % 1000 == 0) { + fprintf(stderr, "Wrote %u octets\n", b); + } + } +} + -- cgit v1.2.3