From a84049e8f78c93fd07220c2333af8ec6fa99f85a Mon Sep 17 00:00:00 2001 From: mazze Date: Thu, 17 Aug 2017 14:47:32 +0000 Subject: [PATCH] Simple test for asyncio.library. git-svn-id: https://svn.aros.org/svn/aros/trunk/contrib@54878 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/libs/asyncio/mmakefile.src | 13 +++++++++++++ workbench/libs/asyncio/testasync.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 workbench/libs/asyncio/mmakefile.src create mode 100644 workbench/libs/asyncio/testasync.c diff --git a/workbench/libs/asyncio/mmakefile.src b/workbench/libs/asyncio/mmakefile.src new file mode 100644 index 000000000..86ad4d9b4 --- /dev/null +++ b/workbench/libs/asyncio/mmakefile.src @@ -0,0 +1,13 @@ +include $(SRCDIR)/config/aros-contrib.cfg + +#MM- workbench-libs : workbench-libs-asyncio + +#MM- workbench-libs-asyncio : workbench-libs-asyncio-test + +TARGETDIR := $(AROS_TESTS)/asyncio + +%build_prog mmake=workbench-libs-asyncio-test \ + progname=testasync targetdir=$(TARGETDIR) \ + uselibs=asyncio + +%common diff --git a/workbench/libs/asyncio/testasync.c b/workbench/libs/asyncio/testasync.c new file mode 100644 index 000000000..73b975ca2 --- /dev/null +++ b/workbench/libs/asyncio/testasync.c @@ -0,0 +1,35 @@ +#include + +#include + +#include +#include +#include + +int main(void) +{ + struct AsyncFile *write_fh = 0; + LONG bytes = 0; + LONG i; + + STRPTR line = "This is a test."; + + if ((write_fh = OpenAsync("testasync.txt", MODE_WRITE, 2000))) + { + puts("File opened."); + for (i = 0; i < 1000; i++) + { + bytes = WriteLineAsync(write_fh, line); + printf("%d bytes written.\n", bytes); + bytes = WriteCharAsync(write_fh,'\n'); + printf("%d byte written.\n", bytes); + } + CloseAsync(write_fh); + } + else + { + puts("Can't open file"); + } + + return 0; +} -- 2.11.4.GIT