X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-openat.c;h=1ef07b5b12d0d6957db2715b53f7c1ee378dae90;hb=88e5b4d4641f294d8f824d770c9c55a1abe49768;hp=77185cc45a42e4821f4e178b3b963976518ccfdd;hpb=48e988340f85e568ceb9ac1f4bf5824fddf1fd0d;p=gnulib.git diff --git a/tests/test-openat.c b/tests/test-openat.c index 77185cc45..1ef07b5b1 100644 --- a/tests/test-openat.c +++ b/tests/test-openat.c @@ -1,5 +1,5 @@ /* Test that openat works. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,24 +20,17 @@ #include +#include "signature.h" +SIGNATURE_CHECK (openat, int, (int, char const *, int, ...)); + #include #include #include #include -#include #include -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) +#include "progname.h" +#include "macros.h" #define BASE "test-openat.t" @@ -66,10 +59,25 @@ do_open (char const *name, int flags, ...) } int -main (void) +main (int argc _GL_UNUSED, char *argv[]) { int result; + set_program_name (argv[0]); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (openat (-1, "foo", O_RDONLY) == -1); + ASSERT (errno == EBADF); + } + { + close (99); + errno = 0; + ASSERT (openat (99, "foo", O_RDONLY) == -1); + ASSERT (errno == EBADF); + } + /* Basic checks. */ result = test_open (do_open, false); dfd = open (".", O_RDONLY);