From 4423b73d2b76c169e3af9770e0b4ebde91168a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 5 Feb 2021 17:39:42 +0100 Subject: add test for read --- src/examples/Makefile | 3 ++- src/examples/read.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/examples/read.c (limited to 'src/examples') diff --git a/src/examples/Makefile b/src/examples/Makefile index a89a3e3..bcfab6b 100644 --- a/src/examples/Makefile +++ b/src/examples/Makefile @@ -8,9 +8,10 @@ PROGS = cat cmp cp echo halt hex-dump ls mcat mcp mkdir pwd rm shell \ sumargv lab2test lab1test lab1test2 pfs pfs_reader pfs_writer dummy longrun \ child parent create-bad printf -PROGS += create +PROGS += create read create_SRC = create.c +read_SRC = read.c # Added test programs printf_SRC = printf.c diff --git a/src/examples/read.c b/src/examples/read.c new file mode 100644 index 0000000..4b6e20b --- /dev/null +++ b/src/examples/read.c @@ -0,0 +1,20 @@ +#include +#include + +int +main (int argc, char *argv[]) +{ + char read_buf[16] = {}; + + int fd = open ("readme"); + if (fd == -1) { + halt (); + } + printf("opened file with fd %d\n", fd); + + int n = read (fd, read_buf, 16); + printf("read %d bytes:\n", n); + + halt(); + return 0; +} -- cgit v1.2.1