]> granicus.if.org Git - strace/commitdiff
tests/lseek.c: use libtests
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 5 Jan 2016 23:27:42 +0000 (23:27 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 5 Jan 2016 23:27:42 +0000 (23:27 +0000)
* tests/lseek.c: Use SKIP_MAIN_UNDEFINED.
(main): Use assert and perror_msg_and_skip.

tests/lseek.c

index 526a3ae35e1280032b9c72fd19f42c6235b40b53..9dcf0cadec698f69c490e9068126ca7813831063 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 
 #ifdef __NR_lseek
 
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "kernel_types.h"
+# include <assert.h>
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+# include "kernel_types.h"
 
 int
 main(void)
 {
        const kernel_ulong_t offset = (kernel_ulong_t) 0xdefaced0badc0deULL;
-       int rc;
 
        if (sizeof(offset) > sizeof(long))
-               rc = lseek(-1, offset, SEEK_SET);
+               assert(lseek(-1, offset, SEEK_SET) == -1);
        else
-               rc = syscall(__NR_lseek, -1L, offset, SEEK_SET);
+               assert(syscall(__NR_lseek, -1L, offset, SEEK_SET) == -1);
 
-       if (rc != -1 || EBADF != errno)
-               return 77;
+       if (EBADF != errno)
+               perror_msg_and_skip("lseek");
 
-       printf("lseek(-1, %llu, SEEK_SET) = -1 EBADF (Bad file descriptor)\n",
+       printf("lseek(-1, %llu, SEEK_SET) = -1 EBADF (%m)\n",
               (unsigned long long) offset);
 
        puts("+++ exited with 0 +++");
@@ -59,10 +58,6 @@ main(void)
 
 #else
 
-int
-main(void)
-{
-       return 77;
-}
+SKIP_MAIN_UNDEFINED("__NR_lseek")
 
 #endif