1865695bbc89088b9526ea9045410e5afb70a985cplars/*
2865695bbc89088b9526ea9045410e5afb70a985cplars * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
33e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubis *  AUTHOR		: William Roske
43e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubis *  CO-PILOT		: Dave Fenner
5865695bbc89088b9526ea9045410e5afb70a985cplars *
6865695bbc89088b9526ea9045410e5afb70a985cplars * This program is free software; you can redistribute it and/or modify it
7865695bbc89088b9526ea9045410e5afb70a985cplars * under the terms of version 2 of the GNU General Public License as
8865695bbc89088b9526ea9045410e5afb70a985cplars * published by the Free Software Foundation.
9865695bbc89088b9526ea9045410e5afb70a985cplars *
10865695bbc89088b9526ea9045410e5afb70a985cplars * This program is distributed in the hope that it would be useful, but
11865695bbc89088b9526ea9045410e5afb70a985cplars * WITHOUT ANY WARRANTY; without even the implied warranty of
12865695bbc89088b9526ea9045410e5afb70a985cplars * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13865695bbc89088b9526ea9045410e5afb70a985cplars *
14865695bbc89088b9526ea9045410e5afb70a985cplars * Further, this software is distributed without any warranty that it is
15865695bbc89088b9526ea9045410e5afb70a985cplars * free of the rightful claim of any third person regarding infringement
16865695bbc89088b9526ea9045410e5afb70a985cplars * or the like.  Any license provided herein, whether implied or
17865695bbc89088b9526ea9045410e5afb70a985cplars * otherwise, applies only to this software file.  Patent licenses, if
18865695bbc89088b9526ea9045410e5afb70a985cplars * any, provided herein do not apply to combinations of this program with
19865695bbc89088b9526ea9045410e5afb70a985cplars * other software, or any other product whatsoever.
20865695bbc89088b9526ea9045410e5afb70a985cplars *
21865695bbc89088b9526ea9045410e5afb70a985cplars * You should have received a copy of the GNU General Public License along
22fed9641096e27f79a0f2d9adfe9839dd8d11dc0fWanlong Gao * with this program; if not, write the Free Software Foundation, Inc.,
23fed9641096e27f79a0f2d9adfe9839dd8d11dc0fWanlong Gao * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24865695bbc89088b9526ea9045410e5afb70a985cplars *
25865695bbc89088b9526ea9045410e5afb70a985cplars * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
26865695bbc89088b9526ea9045410e5afb70a985cplars * Mountain View, CA  94043, or:
27865695bbc89088b9526ea9045410e5afb70a985cplars *
28865695bbc89088b9526ea9045410e5afb70a985cplars * http://www.sgi.com
29865695bbc89088b9526ea9045410e5afb70a985cplars *
30865695bbc89088b9526ea9045410e5afb70a985cplars * For further information regarding this notice, see:
31865695bbc89088b9526ea9045410e5afb70a985cplars *
32865695bbc89088b9526ea9045410e5afb70a985cplars * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
33865695bbc89088b9526ea9045410e5afb70a985cplars *
34865695bbc89088b9526ea9045410e5afb70a985cplars */
35865695bbc89088b9526ea9045410e5afb70a985cplars
36865695bbc89088b9526ea9045410e5afb70a985cplars#include <sys/types.h>
37db63921767012310af15f29035a334e50486292cmridge#include <fcntl.h>
38db63921767012310af15f29035a334e50486292cmridge#include <unistd.h>
39865695bbc89088b9526ea9045410e5afb70a985cplars#include <sys/stat.h>
40865695bbc89088b9526ea9045410e5afb70a985cplars#include <errno.h>
41865695bbc89088b9526ea9045410e5afb70a985cplars#include <string.h>
42865695bbc89088b9526ea9045410e5afb70a985cplars#include <signal.h>
433e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubis
44865695bbc89088b9526ea9045410e5afb70a985cplars#include "test.h"
453e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubis#include "safe_macros.h"
46865695bbc89088b9526ea9045410e5afb70a985cplars
473e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubisstatic void setup(void);
483e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubisstatic void cleanup(void);
49865695bbc89088b9526ea9045410e5afb70a985cplars
50fdce7d5e2a219d201a2b0e3bab6b61b01ec1d716Cyril Hrubischar *TCID = "fcntl08";
51fdce7d5e2a219d201a2b0e3bab6b61b01ec1d716Cyril Hrubisint TST_TOTAL = 1;
52865695bbc89088b9526ea9045410e5afb70a985cplars
533e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubisstatic int fd;
54865695bbc89088b9526ea9045410e5afb70a985cplars
5556207cec7732e09c216c751c0b5f88a242bacae6subrata_modakint main(int ac, char **av)
56865695bbc89088b9526ea9045410e5afb70a985cplars{
5789af32a63ce8a780ea39337339e14caae244b5a4Cyril Hrubis	int lc;
5856207cec7732e09c216c751c0b5f88a242bacae6subrata_modak
59d6d11d08678aac1ed2c370ea8e42e5f45aea07beCyril Hrubis	tst_parse_opts(ac, av, NULL, NULL);
602c28215423293e443469a07ae7011135d058b671Garrett Cooper
6156207cec7732e09c216c751c0b5f88a242bacae6subrata_modak	setup();
62865695bbc89088b9526ea9045410e5afb70a985cplars
6356207cec7732e09c216c751c0b5f88a242bacae6subrata_modak	for (lc = 0; TEST_LOOPING(lc); lc++) {
64865695bbc89088b9526ea9045410e5afb70a985cplars
65d59a659cd639ca2780b00049d102acd2a783d585Caspar Zhang		tst_count = 0;
6656207cec7732e09c216c751c0b5f88a242bacae6subrata_modak
673e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubis		TEST(fcntl(fd, F_SETFL, O_NDELAY | O_APPEND | O_NONBLOCK));
6856207cec7732e09c216c751c0b5f88a242bacae6subrata_modak
693e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubis		if (TEST_RETURN == -1) {
70354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao			tst_resm(TFAIL | TTERRNO, "fcntl failed");
713e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubis		} else {
72e38b961c385192f0d804914b77bd590734b42e75Cyril Hrubis			tst_resm(TPASS, "fcntl returned %ld",
73e38b961c385192f0d804914b77bd590734b42e75Cyril Hrubis				 TEST_RETURN);
7456207cec7732e09c216c751c0b5f88a242bacae6subrata_modak		}
75865695bbc89088b9526ea9045410e5afb70a985cplars
762c28215423293e443469a07ae7011135d058b671Garrett Cooper	}
77865695bbc89088b9526ea9045410e5afb70a985cplars
7856207cec7732e09c216c751c0b5f88a242bacae6subrata_modak	cleanup();
79c737f2f044c1ab7907e1c9bd2e478857f18635e8Garrett Cooper	tst_exit();
802c28215423293e443469a07ae7011135d058b671Garrett Cooper}
81865695bbc89088b9526ea9045410e5afb70a985cplars
82c57fba5535abf457e33dd7a986b6c512d95cdef6Mike Frysingervoid setup(void)
83865695bbc89088b9526ea9045410e5afb70a985cplars{
842c28215423293e443469a07ae7011135d058b671Garrett Cooper
8556207cec7732e09c216c751c0b5f88a242bacae6subrata_modak	tst_sig(NOFORK, DEF_HANDLER, cleanup);
86865695bbc89088b9526ea9045410e5afb70a985cplars
8756207cec7732e09c216c751c0b5f88a242bacae6subrata_modak	TEST_PAUSE;
88865695bbc89088b9526ea9045410e5afb70a985cplars
8956207cec7732e09c216c751c0b5f88a242bacae6subrata_modak	tst_tmpdir();
90865695bbc89088b9526ea9045410e5afb70a985cplars
913e04fd5692574e3657f626942eda53ce86b6828cCyril Hrubis	fd = SAFE_OPEN(cleanup, "test_file", O_RDWR | O_CREAT, 0700);
922c28215423293e443469a07ae7011135d058b671Garrett Cooper}
93865695bbc89088b9526ea9045410e5afb70a985cplars
94c57fba5535abf457e33dd7a986b6c512d95cdef6Mike Frysingervoid cleanup(void)
95865695bbc89088b9526ea9045410e5afb70a985cplars{
96c737f2f044c1ab7907e1c9bd2e478857f18635e8Garrett Cooper	if (close(fd) == -1)
97354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao		tst_resm(TWARN | TERRNO, "close failed");
98865695bbc89088b9526ea9045410e5afb70a985cplars
9956207cec7732e09c216c751c0b5f88a242bacae6subrata_modak	tst_rmdir();
100ec6edca7aa42b6affd989ef91b5897f96795e40fChris Dearman}
101