diff options
Diffstat (limited to 'rt/tst-aio.c')
-rw-r--r-- | rt/tst-aio.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/rt/tst-aio.c b/rt/tst-aio.c index 83833ee117..a6c0762a2a 100644 --- a/rt/tst-aio.c +++ b/rt/tst-aio.c @@ -26,9 +26,12 @@ #include <sys/stat.h> -/* prototype for our test function. */ +/* Prototype for our test function. */ +extern void do_prepare (int argc, char *argv[]); extern int do_test (int argc, char *argv[]); +/* We have a preparation function. */ +#define PREPARE do_prepare /* We might need a bit longer timeout. */ #define TIMEOUT 20 /* sec */ @@ -37,6 +40,28 @@ extern int do_test (int argc, char *argv[]); #include <test-skeleton.c> +/* These are for the temporary file we generate. */ +char *name; +int fd; + +void +do_prepare (int argc, char *argv[]) +{ + char name_len; + + name_len = strlen (test_dir); + name = malloc (name_len + sizeof ("/aioXXXXXX")); + mempcpy (mempcpy (name, test_dir, name_len), + "/aioXXXXXX", sizeof ("/aioXXXXXX")); + add_temp_file (name); + + /* Open our test file. */ + fd = mkstemp (name); + if (fd == -1) + error (EXIT_FAILURE, errno, "cannot open test file `%s'", name); +} + + int test_file (const void *buf, size_t size, int fd, const char *msg) { @@ -98,26 +123,12 @@ do_wait (struct aiocb **cbp, size_t nent) int do_test (int argc, char *argv[]) { - char *name; - char name_len; struct aiocb cbs[10]; struct aiocb *cbp[10]; char buf[1000]; size_t cnt; - int fd; int result = 0; - name_len = strlen (test_dir); - name = malloc (name_len + sizeof ("/aioXXXXXX")); - mempcpy (mempcpy (name, test_dir, name_len), - "/aioXXXXXX", sizeof ("/aioXXXXXX")); - add_temp_file (name); - - /* Open our test file. */ - fd = mkstemp (name); - if (fd == -1) - error (EXIT_FAILURE, errno, "cannot open test file `%s'", name); - /* Preparation. */ for (cnt = 0; cnt < 10; ++cnt) { |