From 89eb888ebf20d358fa79311dda7f27b91500d663 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 6 Jan 2016 09:35:39 +0000 Subject: [PATCH] tests/truncate.c: use libtests * tests/truncate.c: Use SKIP_MAIN_UNDEFINED. (main): Use assert and perror_msg_and_skip. --- tests/truncate.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/tests/truncate.c b/tests/truncate.c index 7c69059b..b47a97e6 100644 --- a/tests/truncate.c +++ b/tests/truncate.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Dmitry V. Levin + * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,11 +30,11 @@ #ifdef __NR_truncate -#include -#include -#include - -#include "kernel_types.h" +# include +# include +# include +# include +# include "kernel_types.h" int main(void) @@ -42,17 +42,16 @@ main(void) static const char fname[] = "truncate\nfilename"; static const char qname[] = "truncate\\nfilename"; const kernel_ulong_t len = (kernel_ulong_t) 0xdefaced0badc0deULL; - int rc; if (sizeof(len) > sizeof(long)) - rc = truncate(fname, len); + assert(truncate(fname, len) == -1); else - rc = syscall(__NR_truncate, fname, len); + assert(syscall(__NR_truncate, fname, len) == -1); - if (rc != -1 || ENOENT != errno) - return 77; + if (ENOENT != errno) + perror_msg_and_skip("truncate"); - printf("truncate(\"%s\", %llu) = -1 ENOENT (No such file or directory)\n", + printf("truncate(\"%s\", %llu) = -1 ENOENT (%m)\n", qname, (unsigned long long) len); puts("+++ exited with 0 +++"); @@ -61,10 +60,6 @@ main(void) #else -int -main(void) -{ - return 77; -} +SKIP_MAIN_UNDEFINED("__NR_truncate") #endif -- 2.40.0