Home | History | Annotate | Download | only in fcntl
      1 /*
      2  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
      3  *  AUTHOR		: William Roske
      4  *  CO-PILOT		: Dave Fenner
      5  *
      6  * This program is free software; you can redistribute it and/or modify it
      7  * under the terms of version 2 of the GNU General Public License as
      8  * published by the Free Software Foundation.
      9  *
     10  * This program is distributed in the hope that it would be useful, but
     11  * WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     13  *
     14  * Further, this software is distributed without any warranty that it is
     15  * free of the rightful claim of any third person regarding infringement
     16  * or the like.  Any license provided herein, whether implied or
     17  * otherwise, applies only to this software file.  Patent licenses, if
     18  * any, provided herein do not apply to combinations of this program with
     19  * other software, or any other product whatsoever.
     20  *
     21  * You should have received a copy of the GNU General Public License along
     22  * with this program; if not, write the Free Software Foundation, Inc.,
     23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     24  *
     25  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
     26  * Mountain View, CA  94043, or:
     27  *
     28  * http://www.sgi.com
     29  *
     30  * For further information regarding this notice, see:
     31  *
     32  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
     33  *
     34  */
     35 
     36 #include <sys/types.h>
     37 #include <fcntl.h>
     38 #include <unistd.h>
     39 #include <sys/stat.h>
     40 #include <errno.h>
     41 #include <string.h>
     42 #include <signal.h>
     43 
     44 #include "test.h"
     45 #include "safe_macros.h"
     46 
     47 static void setup(void);
     48 static void cleanup(void);
     49 
     50 char *TCID = "fcntl08";
     51 int TST_TOTAL = 1;
     52 
     53 static int fd;
     54 
     55 int main(int ac, char **av)
     56 {
     57 	int lc;
     58 
     59 	tst_parse_opts(ac, av, NULL, NULL);
     60 
     61 	setup();
     62 
     63 	for (lc = 0; TEST_LOOPING(lc); lc++) {
     64 
     65 		tst_count = 0;
     66 
     67 		TEST(fcntl(fd, F_SETFL, O_NDELAY | O_APPEND | O_NONBLOCK));
     68 
     69 		if (TEST_RETURN == -1) {
     70 			tst_resm(TFAIL | TTERRNO, "fcntl failed");
     71 		} else {
     72 			tst_resm(TPASS, "fcntl returned %ld",
     73 				 TEST_RETURN);
     74 		}
     75 
     76 	}
     77 
     78 	cleanup();
     79 	tst_exit();
     80 }
     81 
     82 void setup(void)
     83 {
     84 
     85 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
     86 
     87 	TEST_PAUSE;
     88 
     89 	tst_tmpdir();
     90 
     91 	fd = SAFE_OPEN(cleanup, "test_file", O_RDWR | O_CREAT, 0700);
     92 }
     93 
     94 void cleanup(void)
     95 {
     96 	if (close(fd) == -1)
     97 		tst_resm(TWARN | TERRNO, "close failed");
     98 
     99 	tst_rmdir();
    100 }
    101