X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-open.h;h=d7bd5afc49be027725d6d71a393d1cd27e6a1636;hb=1276a2c5f24c0c932426aca9c899fa524d2443f2;hp=9b43945825b4624c98995717b05eadedc31fa091;hpb=48e988340f85e568ceb9ac1f4bf5824fddf1fd0d;p=gnulib.git diff --git a/tests/test-open.h b/tests/test-open.h index 9b4394582..d7bd5afc4 100644 --- a/tests/test-open.h +++ b/tests/test-open.h @@ -1,5 +1,5 @@ /* Test of opening a file descriptor. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2014 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 @@ -16,13 +16,22 @@ /* Written by Bruno Haible , 2007. */ +/* Make test_open always inline if we're using Fortify, which defines + __always_inline to do that. Do nothing otherwise. This works + around a glibc bug whereby 'open' cannot be used as a function + pointer when _FORTIFY_SOURCE is positive. */ + +#ifndef __always_inline +#define __always_inline +#endif + /* This file is designed to test both open(n,buf[,mode]) and openat(AT_FDCWD,n,buf[,mode]). FUNC is the function to test. Assumes that BASE and ASSERT are already defined, and that appropriate headers are already included. If PRINT, warn before skipping symlink tests with status 77. */ -static int +static __always_inline int test_open (int (*func) (char const *, int, ...), bool print) { int fd; @@ -63,6 +72,12 @@ test_open (int (*func) (char const *, int, ...), bool print) ASSERT (write (fd, "c", 1) == 1); ASSERT (close (fd) == 0); + /* Although O_NONBLOCK on regular files can be ignored, it must not + cause a failure. */ + fd = func (BASE "file", O_NONBLOCK | O_RDONLY); + ASSERT (0 <= fd); + ASSERT (close (fd) == 0); + /* Symlink handling, where supported. */ if (symlink (BASE "file", BASE "link") != 0) {