]> granicus.if.org Git - strace/commitdiff
tests/truncate64.c: use libtests
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 09:36:00 +0000 (09:36 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 09:39:07 +0000 (09:39 +0000)
* tests/truncate64.c: Use SKIP_MAIN_UNDEFINED.
(main): Use assert and perror_msg_and_skip.

tests/truncate64.c

index ba7f827bd6cdfc55d619bfbc54e1779d6bbbc48a..0e193d594455dc4c4a03bc1773aaa4ed86cda2fe 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_truncate64
 
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
+# include <assert.h>
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
 
 int
 main(void)
@@ -40,12 +41,11 @@ main(void)
        static const char fname[] = "truncate64\nfilename";
        static const char qname[] = "truncate64\\nfilename";
        const off_t len = 0xdefaceddeadbeef;
-       int rc = truncate(fname, len);
 
-       if (rc != -1 || ENOENT != errno)
-               return 77;
-
-       printf("truncate64(\"%s\", %llu) = -1 ENOENT (No such file or directory)\n",
+       assert(truncate(fname, len) == -1);
+       if (ENOENT != errno)
+               perror_msg_and_skip("truncate");
+       printf("truncate64(\"%s\", %llu) = -1 ENOENT (%m)\n",
               qname, (unsigned long long) len);
 
        puts("+++ exited with 0 +++");
@@ -54,10 +54,6 @@ main(void)
 
 #else
 
-int
-main(void)
-{
-       return 77;
-}
+SKIP_MAIN_UNDEFINED("__NR_truncate64")
 
 #endif