X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-pwrite.c;h=909149ab57605ad52ef40a1c21cd375b9830872b;hb=c9f0960c2cd1acf9c29b27860589698ea54fa4ec;hp=073f6a336c286d13d8463caa003030e80cf562a8;hpb=ea1a2077de32da9837b495d589509f8269807dd1;p=gnulib.git diff --git a/tests/test-pwrite.c b/tests/test-pwrite.c index 073f6a336..909149ab5 100644 --- a/tests/test-pwrite.c +++ b/tests/test-pwrite.c @@ -1,5 +1,5 @@ /* Test the pwrite function. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009-2012 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 @@ -24,6 +24,7 @@ SIGNATURE_CHECK (pwrite, ssize_t, (int, const void *, size_t, off_t)); #include #include #include +#include #include "macros.h" @@ -69,12 +70,26 @@ main (void) ASSERT (close (fd) == 0); { - char read_buf[N]; fd = open (file, O_RDONLY); ASSERT (0 <= fd); ASSERT (read (fd, buf, N) == N); ASSERT (close (fd) == 0); ASSERT (strcmp ("W1W3W5W7W9",buf) == 0); } + + /* Test behaviour for invalid file descriptors. */ + { + char byte = 'x'; + errno = 0; + ASSERT (pwrite (-1, &byte, 1, 0) == -1); + ASSERT (errno == EBADF); + } + { + char byte = 'x'; + errno = 0; + ASSERT (pwrite (99, &byte, 1, 0) == -1); + ASSERT (errno == EBADF); + } + return 0; }