xref: /aosp_15_r20/external/ltp/testcases/kernel/fs/stream/stream03.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker /*
2*49cdfc7eSAndroid Build Coastguard Worker  *
3*49cdfc7eSAndroid Build Coastguard Worker  *   Copyright (c) International Business Machines  Corp., 2002
4*49cdfc7eSAndroid Build Coastguard Worker  *
5*49cdfc7eSAndroid Build Coastguard Worker  *   This program is free software;  you can redistribute it and/or modify
6*49cdfc7eSAndroid Build Coastguard Worker  *   it under the terms of the GNU General Public License as published by
7*49cdfc7eSAndroid Build Coastguard Worker  *   the Free Software Foundation; either version 2 of the License, or
8*49cdfc7eSAndroid Build Coastguard Worker  *   (at your option) any later version.
9*49cdfc7eSAndroid Build Coastguard Worker  *
10*49cdfc7eSAndroid Build Coastguard Worker  *   This program is distributed in the hope that it will be useful,
11*49cdfc7eSAndroid Build Coastguard Worker  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12*49cdfc7eSAndroid Build Coastguard Worker  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13*49cdfc7eSAndroid Build Coastguard Worker  *   the GNU General Public License for more details.
14*49cdfc7eSAndroid Build Coastguard Worker  *
15*49cdfc7eSAndroid Build Coastguard Worker  *   You should have received a copy of the GNU General Public License
16*49cdfc7eSAndroid Build Coastguard Worker  *   along with this program;  if not, write to the Free Software
17*49cdfc7eSAndroid Build Coastguard Worker  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*49cdfc7eSAndroid Build Coastguard Worker  */
19*49cdfc7eSAndroid Build Coastguard Worker 
20*49cdfc7eSAndroid Build Coastguard Worker /* ported from SPIE, section2/filesuite/stream3.c, by Airong Zhang */
21*49cdfc7eSAndroid Build Coastguard Worker 
22*49cdfc7eSAndroid Build Coastguard Worker /*======================================================================
23*49cdfc7eSAndroid Build Coastguard Worker 	=================== TESTPLAN SEGMENT ===================
24*49cdfc7eSAndroid Build Coastguard Worker >KEYS:  < fseek() ftell()
25*49cdfc7eSAndroid Build Coastguard Worker >WHAT:  < 1) Ensure ftell reports the correct current byte offset.
26*49cdfc7eSAndroid Build Coastguard Worker >HOW:   < 1) Open a file, write to it, reposition the file pointer and
27*49cdfc7eSAndroid Build Coastguard Worker 	     check it.
28*49cdfc7eSAndroid Build Coastguard Worker >BUGS:  <
29*49cdfc7eSAndroid Build Coastguard Worker ======================================================================*/
30*49cdfc7eSAndroid Build Coastguard Worker #define _XOPEN_SOURCE 500
31*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
32*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
33*49cdfc7eSAndroid Build Coastguard Worker #include <fcntl.h>
34*49cdfc7eSAndroid Build Coastguard Worker #include <sys/types.h>
35*49cdfc7eSAndroid Build Coastguard Worker #include <sys/stat.h>
36*49cdfc7eSAndroid Build Coastguard Worker #include <inttypes.h>
37*49cdfc7eSAndroid Build Coastguard Worker #include "test.h"
38*49cdfc7eSAndroid Build Coastguard Worker 
39*49cdfc7eSAndroid Build Coastguard Worker char *TCID = "stream03";
40*49cdfc7eSAndroid Build Coastguard Worker int TST_TOTAL = 1;
41*49cdfc7eSAndroid Build Coastguard Worker int local_flag;
42*49cdfc7eSAndroid Build Coastguard Worker 
43*49cdfc7eSAndroid Build Coastguard Worker #define PASSED 1
44*49cdfc7eSAndroid Build Coastguard Worker #define FAILED 0
45*49cdfc7eSAndroid Build Coastguard Worker 
46*49cdfc7eSAndroid Build Coastguard Worker char progname[] = "stream03()";
47*49cdfc7eSAndroid Build Coastguard Worker char tempfile1[40] = "";
48*49cdfc7eSAndroid Build Coastguard Worker 
main(int ac,char * av[])49*49cdfc7eSAndroid Build Coastguard Worker int main(int ac, char *av[])
50*49cdfc7eSAndroid Build Coastguard Worker {
51*49cdfc7eSAndroid Build Coastguard Worker 	FILE *stream;
52*49cdfc7eSAndroid Build Coastguard Worker 	char buf[30];
53*49cdfc7eSAndroid Build Coastguard Worker 	char *junk = "abcdefghijklmnopqrstuvwxyz";
54*49cdfc7eSAndroid Build Coastguard Worker 	long pos;
55*49cdfc7eSAndroid Build Coastguard Worker 	off_t opos;
56*49cdfc7eSAndroid Build Coastguard Worker 	int lc;
57*49cdfc7eSAndroid Build Coastguard Worker 
58*49cdfc7eSAndroid Build Coastguard Worker 	/*
59*49cdfc7eSAndroid Build Coastguard Worker 	 * parse standard options
60*49cdfc7eSAndroid Build Coastguard Worker 	 */
61*49cdfc7eSAndroid Build Coastguard Worker 	tst_parse_opts(ac, av, NULL, NULL);
62*49cdfc7eSAndroid Build Coastguard Worker 
63*49cdfc7eSAndroid Build Coastguard Worker 	local_flag = PASSED;
64*49cdfc7eSAndroid Build Coastguard Worker 	tst_tmpdir();
65*49cdfc7eSAndroid Build Coastguard Worker 
66*49cdfc7eSAndroid Build Coastguard Worker 	for (lc = 0; TEST_LOOPING(lc); lc++) {
67*49cdfc7eSAndroid Build Coastguard Worker 
68*49cdfc7eSAndroid Build Coastguard Worker 		sprintf(tempfile1, "stream03.%d", getpid());
69*49cdfc7eSAndroid Build Coastguard Worker 	/*--------------------------------------------------------------------*/
70*49cdfc7eSAndroid Build Coastguard Worker 		//block0:
71*49cdfc7eSAndroid Build Coastguard Worker 
72*49cdfc7eSAndroid Build Coastguard Worker 		if ((stream = fopen(tempfile1, "a+")) == NULL) {
73*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TBROK, NULL, "fopen(%s) a+ failed: %s",
74*49cdfc7eSAndroid Build Coastguard Worker 				 tempfile1,
75*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
76*49cdfc7eSAndroid Build Coastguard Worker 		}
77*49cdfc7eSAndroid Build Coastguard Worker 
78*49cdfc7eSAndroid Build Coastguard Worker 		/* make sure offset of zero at start */
79*49cdfc7eSAndroid Build Coastguard Worker 		pos = ftell(stream);
80*49cdfc7eSAndroid Build Coastguard Worker 
81*49cdfc7eSAndroid Build Coastguard Worker 		if (pos != 0) {
82*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL, "file pointer descrepancy 1");
83*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
84*49cdfc7eSAndroid Build Coastguard Worker 		}
85*49cdfc7eSAndroid Build Coastguard Worker 
86*49cdfc7eSAndroid Build Coastguard Worker 		/* write something and check */
87*49cdfc7eSAndroid Build Coastguard Worker 		if (fwrite(junk, sizeof(*junk), strlen(junk), stream) == 0) {
88*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fwrite failed: %s",
89*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
90*49cdfc7eSAndroid Build Coastguard Worker 		}
91*49cdfc7eSAndroid Build Coastguard Worker 
92*49cdfc7eSAndroid Build Coastguard Worker 		pos = ftell(stream);
93*49cdfc7eSAndroid Build Coastguard Worker 
94*49cdfc7eSAndroid Build Coastguard Worker 		if (pos != strlen(junk)) {
95*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
96*49cdfc7eSAndroid Build Coastguard Worker 				 "strlen(junk)=%zi: file pointer descrepancy 2 (pos=%li)",
97*49cdfc7eSAndroid Build Coastguard Worker 				 strlen(junk), pos);
98*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
99*49cdfc7eSAndroid Build Coastguard Worker 		}
100*49cdfc7eSAndroid Build Coastguard Worker 
101*49cdfc7eSAndroid Build Coastguard Worker 		/* rewind and check */
102*49cdfc7eSAndroid Build Coastguard Worker 		rewind(stream);
103*49cdfc7eSAndroid Build Coastguard Worker 		pos = ftell(stream);
104*49cdfc7eSAndroid Build Coastguard Worker 
105*49cdfc7eSAndroid Build Coastguard Worker 		if (pos != 0) {
106*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
107*49cdfc7eSAndroid Build Coastguard Worker 				 "file pointer descrepancy 3 (pos=%li, wanted pos=0)",
108*49cdfc7eSAndroid Build Coastguard Worker 				 pos);
109*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
110*49cdfc7eSAndroid Build Coastguard Worker 		}
111*49cdfc7eSAndroid Build Coastguard Worker 
112*49cdfc7eSAndroid Build Coastguard Worker 		/* seek from current position and then check */
113*49cdfc7eSAndroid Build Coastguard Worker 		if (fseek(stream, strlen(junk), 1) != 0) {
114*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fseek failed: %s",
115*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
116*49cdfc7eSAndroid Build Coastguard Worker 		}
117*49cdfc7eSAndroid Build Coastguard Worker 
118*49cdfc7eSAndroid Build Coastguard Worker 		pos = ftell(stream);
119*49cdfc7eSAndroid Build Coastguard Worker 
120*49cdfc7eSAndroid Build Coastguard Worker 		if (pos != strlen(junk)) {
121*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
122*49cdfc7eSAndroid Build Coastguard Worker 				 "strlen(junk)=%zi: file pointer descrepancy 4 (pos=%li)",
123*49cdfc7eSAndroid Build Coastguard Worker 				 strlen(junk), pos);
124*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
125*49cdfc7eSAndroid Build Coastguard Worker 		}
126*49cdfc7eSAndroid Build Coastguard Worker 
127*49cdfc7eSAndroid Build Coastguard Worker 		/* seek from end of file and then check */
128*49cdfc7eSAndroid Build Coastguard Worker 		if (fseek(stream, 0, 2) != 0) {
129*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fseek failed: %s",
130*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
131*49cdfc7eSAndroid Build Coastguard Worker 		}
132*49cdfc7eSAndroid Build Coastguard Worker 
133*49cdfc7eSAndroid Build Coastguard Worker 		pos = ftell(stream);
134*49cdfc7eSAndroid Build Coastguard Worker 
135*49cdfc7eSAndroid Build Coastguard Worker 		if (pos != strlen(junk)) {
136*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
137*49cdfc7eSAndroid Build Coastguard Worker 				 "strlen(junk)=%zi: file pointer descrepancy 5 (pos=%li)",
138*49cdfc7eSAndroid Build Coastguard Worker 				 strlen(junk), pos);
139*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
140*49cdfc7eSAndroid Build Coastguard Worker 		}
141*49cdfc7eSAndroid Build Coastguard Worker 
142*49cdfc7eSAndroid Build Coastguard Worker 		/* rewind with seek and then check */
143*49cdfc7eSAndroid Build Coastguard Worker 		if (fseek(stream, 0, 0) != 0) {
144*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fseek failed: %s",
145*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
146*49cdfc7eSAndroid Build Coastguard Worker 		}
147*49cdfc7eSAndroid Build Coastguard Worker 
148*49cdfc7eSAndroid Build Coastguard Worker 		pos = ftell(stream);
149*49cdfc7eSAndroid Build Coastguard Worker 
150*49cdfc7eSAndroid Build Coastguard Worker 		if (pos != 0) {
151*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
152*49cdfc7eSAndroid Build Coastguard Worker 				 "file pointer descrepancy 6 (pos=%li, wanted pos=0)",
153*49cdfc7eSAndroid Build Coastguard Worker 				 pos);
154*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
155*49cdfc7eSAndroid Build Coastguard Worker 		}
156*49cdfc7eSAndroid Build Coastguard Worker 
157*49cdfc7eSAndroid Build Coastguard Worker 		/* read till EOF, do getc and then check ftell */
158*49cdfc7eSAndroid Build Coastguard Worker 		while (fgets(buf, sizeof(buf), stream)) ;
159*49cdfc7eSAndroid Build Coastguard Worker 		pos = ftell(stream);
160*49cdfc7eSAndroid Build Coastguard Worker 		getc(stream);
161*49cdfc7eSAndroid Build Coastguard Worker 		pos = ftell(stream);
162*49cdfc7eSAndroid Build Coastguard Worker 
163*49cdfc7eSAndroid Build Coastguard Worker 		if (pos != strlen(junk)) {
164*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
165*49cdfc7eSAndroid Build Coastguard Worker 				 "strlen(junk)=%zi: file pointer descrepancy 7 (pos=%li)",
166*49cdfc7eSAndroid Build Coastguard Worker 				 strlen(junk), pos);
167*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
168*49cdfc7eSAndroid Build Coastguard Worker 		}
169*49cdfc7eSAndroid Build Coastguard Worker 
170*49cdfc7eSAndroid Build Coastguard Worker 		fclose(stream);
171*49cdfc7eSAndroid Build Coastguard Worker 
172*49cdfc7eSAndroid Build Coastguard Worker 		if (local_flag == PASSED) {
173*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TPASS, "Test passed in block0.");
174*49cdfc7eSAndroid Build Coastguard Worker 		} else {
175*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL, "Test failed in block0.");
176*49cdfc7eSAndroid Build Coastguard Worker 		}
177*49cdfc7eSAndroid Build Coastguard Worker 
178*49cdfc7eSAndroid Build Coastguard Worker 		local_flag = PASSED;
179*49cdfc7eSAndroid Build Coastguard Worker 
180*49cdfc7eSAndroid Build Coastguard Worker 		unlink(tempfile1);
181*49cdfc7eSAndroid Build Coastguard Worker 	/*--------------------------------------------------------------------*/
182*49cdfc7eSAndroid Build Coastguard Worker 		//block1:
183*49cdfc7eSAndroid Build Coastguard Worker 		if ((stream = fopen(tempfile1, "a+")) == NULL) {
184*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fopen(%s) a+ failed: %s",
185*49cdfc7eSAndroid Build Coastguard Worker 				 tempfile1,
186*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
187*49cdfc7eSAndroid Build Coastguard Worker 		}
188*49cdfc7eSAndroid Build Coastguard Worker 
189*49cdfc7eSAndroid Build Coastguard Worker 		/* make sure offset of zero at start */
190*49cdfc7eSAndroid Build Coastguard Worker 		opos = ftello(stream);
191*49cdfc7eSAndroid Build Coastguard Worker 
192*49cdfc7eSAndroid Build Coastguard Worker 		if (opos != 0) {
193*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
194*49cdfc7eSAndroid Build Coastguard Worker 				 "file pointer descrepancy 1 (opos=%" PRId64
195*49cdfc7eSAndroid Build Coastguard Worker 				 ", wanted opos=0)", (int64_t) opos);
196*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
197*49cdfc7eSAndroid Build Coastguard Worker 		}
198*49cdfc7eSAndroid Build Coastguard Worker 
199*49cdfc7eSAndroid Build Coastguard Worker 		/* write something and check */
200*49cdfc7eSAndroid Build Coastguard Worker 		if (fwrite(junk, sizeof(*junk), strlen(junk), stream) == 0) {
201*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fwrite failed: %s",
202*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
203*49cdfc7eSAndroid Build Coastguard Worker 		}
204*49cdfc7eSAndroid Build Coastguard Worker 
205*49cdfc7eSAndroid Build Coastguard Worker 		opos = ftello(stream);
206*49cdfc7eSAndroid Build Coastguard Worker 
207*49cdfc7eSAndroid Build Coastguard Worker 		if (opos != strlen(junk)) {
208*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
209*49cdfc7eSAndroid Build Coastguard Worker 				 "strlen(junk)=%zi: file pointer descrepancy 2 (opos=%"
210*49cdfc7eSAndroid Build Coastguard Worker 				 PRId64 ")", strlen(junk), (int64_t) opos);
211*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
212*49cdfc7eSAndroid Build Coastguard Worker 		}
213*49cdfc7eSAndroid Build Coastguard Worker 
214*49cdfc7eSAndroid Build Coastguard Worker 		/* rewind and check */
215*49cdfc7eSAndroid Build Coastguard Worker 		rewind(stream);
216*49cdfc7eSAndroid Build Coastguard Worker 		opos = ftello(stream);
217*49cdfc7eSAndroid Build Coastguard Worker 
218*49cdfc7eSAndroid Build Coastguard Worker 		if (opos != 0) {
219*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
220*49cdfc7eSAndroid Build Coastguard Worker 				 "file pointer descrepancy 3 (opos=%" PRId64
221*49cdfc7eSAndroid Build Coastguard Worker 				 ", wanted opos=0)", (int64_t) opos);
222*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
223*49cdfc7eSAndroid Build Coastguard Worker 		}
224*49cdfc7eSAndroid Build Coastguard Worker 
225*49cdfc7eSAndroid Build Coastguard Worker 		/* seek from current position and then check */
226*49cdfc7eSAndroid Build Coastguard Worker 		if (fseeko(stream, strlen(junk), 1) != 0) {
227*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fseeko failed: %s",
228*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
229*49cdfc7eSAndroid Build Coastguard Worker 		}
230*49cdfc7eSAndroid Build Coastguard Worker 
231*49cdfc7eSAndroid Build Coastguard Worker 		opos = ftello(stream);
232*49cdfc7eSAndroid Build Coastguard Worker 
233*49cdfc7eSAndroid Build Coastguard Worker 		if (opos != strlen(junk)) {
234*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
235*49cdfc7eSAndroid Build Coastguard Worker 				 "strlen(junk)=%zi: file pointer descrepancy 4 (opos=%"
236*49cdfc7eSAndroid Build Coastguard Worker 				 PRId64 ")", strlen(junk), (int64_t) opos);
237*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
238*49cdfc7eSAndroid Build Coastguard Worker 		}
239*49cdfc7eSAndroid Build Coastguard Worker 
240*49cdfc7eSAndroid Build Coastguard Worker 		/* seek from end of file and then check */
241*49cdfc7eSAndroid Build Coastguard Worker 		if (fseeko(stream, 0, 2) != 0) {
242*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fseeko failed: %s",
243*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
244*49cdfc7eSAndroid Build Coastguard Worker 		}
245*49cdfc7eSAndroid Build Coastguard Worker 
246*49cdfc7eSAndroid Build Coastguard Worker 		opos = ftello(stream);
247*49cdfc7eSAndroid Build Coastguard Worker 
248*49cdfc7eSAndroid Build Coastguard Worker 		if (opos != strlen(junk)) {
249*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
250*49cdfc7eSAndroid Build Coastguard Worker 				 "strlen(junk)=%zi: file pointer descrepancy 5 (opos=%"
251*49cdfc7eSAndroid Build Coastguard Worker 				 PRId64 ")", strlen(junk), (int64_t) opos);
252*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
253*49cdfc7eSAndroid Build Coastguard Worker 		}
254*49cdfc7eSAndroid Build Coastguard Worker 
255*49cdfc7eSAndroid Build Coastguard Worker 		/* rewind with seek and then check */
256*49cdfc7eSAndroid Build Coastguard Worker 		if (fseeko(stream, 0, 0) != 0) {
257*49cdfc7eSAndroid Build Coastguard Worker 			tst_brkm(TFAIL, NULL, "fseeko failed: %s",
258*49cdfc7eSAndroid Build Coastguard Worker 				 strerror(errno));
259*49cdfc7eSAndroid Build Coastguard Worker 		}
260*49cdfc7eSAndroid Build Coastguard Worker 
261*49cdfc7eSAndroid Build Coastguard Worker 		opos = ftello(stream);
262*49cdfc7eSAndroid Build Coastguard Worker 
263*49cdfc7eSAndroid Build Coastguard Worker 		if (opos != 0) {
264*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
265*49cdfc7eSAndroid Build Coastguard Worker 				 "file pointer descrepancy 6 (opos=%" PRId64
266*49cdfc7eSAndroid Build Coastguard Worker 				 ", wanted opos=0)", (int64_t) opos);
267*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
268*49cdfc7eSAndroid Build Coastguard Worker 		}
269*49cdfc7eSAndroid Build Coastguard Worker 
270*49cdfc7eSAndroid Build Coastguard Worker 		/* read till EOF, do getc and then check ftello */
271*49cdfc7eSAndroid Build Coastguard Worker 		while (fgets(buf, sizeof(buf), stream)) ;
272*49cdfc7eSAndroid Build Coastguard Worker 
273*49cdfc7eSAndroid Build Coastguard Worker 		opos = ftello(stream);
274*49cdfc7eSAndroid Build Coastguard Worker 		getc(stream);
275*49cdfc7eSAndroid Build Coastguard Worker 		opos = ftello(stream);
276*49cdfc7eSAndroid Build Coastguard Worker 
277*49cdfc7eSAndroid Build Coastguard Worker 		if (opos != strlen(junk)) {
278*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL,
279*49cdfc7eSAndroid Build Coastguard Worker 				 "strlen(junk)=%zi: file pointer descrepancy 7 (opos=%li)",
280*49cdfc7eSAndroid Build Coastguard Worker 				 strlen(junk), opos);
281*49cdfc7eSAndroid Build Coastguard Worker 			local_flag = FAILED;
282*49cdfc7eSAndroid Build Coastguard Worker 		}
283*49cdfc7eSAndroid Build Coastguard Worker 
284*49cdfc7eSAndroid Build Coastguard Worker 		fclose(stream);
285*49cdfc7eSAndroid Build Coastguard Worker 
286*49cdfc7eSAndroid Build Coastguard Worker 		if (local_flag == PASSED) {
287*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TPASS, "Test passed in block1.");
288*49cdfc7eSAndroid Build Coastguard Worker 		} else {
289*49cdfc7eSAndroid Build Coastguard Worker 			tst_resm(TFAIL, "Test failed in block1.");
290*49cdfc7eSAndroid Build Coastguard Worker 		}
291*49cdfc7eSAndroid Build Coastguard Worker 
292*49cdfc7eSAndroid Build Coastguard Worker 		unlink(tempfile1);
293*49cdfc7eSAndroid Build Coastguard Worker 	}
294*49cdfc7eSAndroid Build Coastguard Worker 
295*49cdfc7eSAndroid Build Coastguard Worker 	tst_rmdir();
296*49cdfc7eSAndroid Build Coastguard Worker 	tst_exit();
297*49cdfc7eSAndroid Build Coastguard Worker }
298