diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-25 02:07:03 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-25 02:07:03 +1300 |
commit | 1ac960d8f38b12fe66bc5586a2ecd6927a119c3f (patch) | |
tree | 90dec838414a2fbc589375ce7786c3e73b83bb86 | |
parent | Add note/warning to mem.c (diff) | |
download | doomsh-1ac960d8f38b12fe66bc5586a2ecd6927a119c3f.tar.gz doomsh-1ac960d8f38b12fe66bc5586a2ecd6927a119c3f.zip |
Add write test
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | tests/Makefile | 2 | ||||
-rw-r--r-- | tests/write.c | 22 |
3 files changed, 24 insertions, 1 deletions
@@ -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 <signal.h> +#include <stdio.h> + +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); + } + } +} + |