xref: /third_party/libsnd/tests/pipe_test.tpl (revision b815c7f3)
1b815c7f3Sopenharmony_ci[+ AutoGen5 template c +]
2b815c7f3Sopenharmony_ci/*
3b815c7f3Sopenharmony_ci** Copyright (C) 2001-2017 Erik de Castro Lopo <erikd@mega-nerd.com>
4b815c7f3Sopenharmony_ci**
5b815c7f3Sopenharmony_ci** This program is free software; you can redistribute it and/or modify
6b815c7f3Sopenharmony_ci** it under the terms of the GNU General Public License as published by
7b815c7f3Sopenharmony_ci** the Free Software Foundation; either version 2 of the License, or
8b815c7f3Sopenharmony_ci** (at your option) any later version.
9b815c7f3Sopenharmony_ci**
10b815c7f3Sopenharmony_ci** This program is distributed in the hope that it will be useful,
11b815c7f3Sopenharmony_ci** but WITHOUT ANY WARRANTY; without even the implied warranty of
12b815c7f3Sopenharmony_ci** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13b815c7f3Sopenharmony_ci** GNU General Public License for more details.
14b815c7f3Sopenharmony_ci**
15b815c7f3Sopenharmony_ci** You should have received a copy of the GNU General Public License
16b815c7f3Sopenharmony_ci** along with this program; if not, write to the Free Software
17b815c7f3Sopenharmony_ci** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18b815c7f3Sopenharmony_ci*/
19b815c7f3Sopenharmony_ci
20b815c7f3Sopenharmony_ci/*==========================================================================
21b815c7f3Sopenharmony_ci** This is a test program which tests reading from and writing to pipes.
22b815c7f3Sopenharmony_ci*/
23b815c7f3Sopenharmony_ci
24b815c7f3Sopenharmony_ci#include "sfconfig.h"
25b815c7f3Sopenharmony_ci
26b815c7f3Sopenharmony_ci#include <stdio.h>
27b815c7f3Sopenharmony_ci#include <stdlib.h>
28b815c7f3Sopenharmony_ci#include <string.h>
29b815c7f3Sopenharmony_ci
30b815c7f3Sopenharmony_ci#if (OS_IS_WIN32 || defined __OS2__ || HAVE_PIPE == 0 || HAVE_WAITPID == 0)
31b815c7f3Sopenharmony_ci
32b815c7f3Sopenharmony_ciint
33b815c7f3Sopenharmony_cimain (void)
34b815c7f3Sopenharmony_ci{
35b815c7f3Sopenharmony_ci	puts ("    pipe_test  : this test doesn't work on this OS.") ;
36b815c7f3Sopenharmony_ci	return 0 ;
37b815c7f3Sopenharmony_ci} /* main */
38b815c7f3Sopenharmony_ci
39b815c7f3Sopenharmony_ci#else
40b815c7f3Sopenharmony_ci
41b815c7f3Sopenharmony_ci#if HAVE_UNISTD_H
42b815c7f3Sopenharmony_ci#include <unistd.h>
43b815c7f3Sopenharmony_ci#endif
44b815c7f3Sopenharmony_ci
45b815c7f3Sopenharmony_ci#include <errno.h>
46b815c7f3Sopenharmony_ci#include <sys/types.h>
47b815c7f3Sopenharmony_ci#include <sys/stat.h>
48b815c7f3Sopenharmony_ci#include <sys/wait.h>
49b815c7f3Sopenharmony_ci
50b815c7f3Sopenharmony_ci#include <sndfile.h>
51b815c7f3Sopenharmony_ci
52b815c7f3Sopenharmony_ci#include "utils.h"
53b815c7f3Sopenharmony_ci
54b815c7f3Sopenharmony_citypedef struct
55b815c7f3Sopenharmony_ci{	int			format ;
56b815c7f3Sopenharmony_ci	const char	*ext ;
57b815c7f3Sopenharmony_ci} FILETYPE ;
58b815c7f3Sopenharmony_ci
59b815c7f3Sopenharmony_cistatic void		useek_pipe_rw_test (int filetype, const char *ext) ;
60b815c7f3Sopenharmony_cistatic void		pipe_read_test (int filetype, const char *ext) ;
61b815c7f3Sopenharmony_cistatic void		pipe_write_test (const char *ext) ;
62b815c7f3Sopenharmony_cistatic void		pipe_test_others (FILETYPE*, FILETYPE*) ;
63b815c7f3Sopenharmony_ci
64b815c7f3Sopenharmony_cistatic FILETYPE read_write_types [] =
65b815c7f3Sopenharmony_ci{	{	SF_FORMAT_RAW	, "raw"		},
66b815c7f3Sopenharmony_ci	{	SF_FORMAT_AU	, "au"		},
67b815c7f3Sopenharmony_ci	/* Lite remove start */
68b815c7f3Sopenharmony_ci	{	SF_FORMAT_PAF	, "paf"		},
69b815c7f3Sopenharmony_ci	{	SF_FORMAT_IRCAM	, "ircam"	},
70b815c7f3Sopenharmony_ci	{	SF_FORMAT_PVF	, "pvf"	},
71b815c7f3Sopenharmony_ci	/* Lite remove end */
72b815c7f3Sopenharmony_ci	{	0				, NULL		}
73b815c7f3Sopenharmony_ci} ;
74b815c7f3Sopenharmony_ci
75b815c7f3Sopenharmony_cistatic FILETYPE read_only_types [] =
76b815c7f3Sopenharmony_ci{	{	SF_FORMAT_RAW	, "raw"		},
77b815c7f3Sopenharmony_ci	{	SF_FORMAT_AU	, "au"		},
78b815c7f3Sopenharmony_ci	{	SF_FORMAT_AIFF	, "aiff"	},
79b815c7f3Sopenharmony_ci	{	SF_FORMAT_WAV	, "wav"		},
80b815c7f3Sopenharmony_ci	{	SF_FORMAT_W64	, "w64"		},
81b815c7f3Sopenharmony_ci	/* Lite remove start */
82b815c7f3Sopenharmony_ci	{	SF_FORMAT_PAF	, "paf"		},
83b815c7f3Sopenharmony_ci	{	SF_FORMAT_NIST	, "nist"	},
84b815c7f3Sopenharmony_ci	{	SF_FORMAT_IRCAM	, "ircam"	},
85b815c7f3Sopenharmony_ci	{	SF_FORMAT_MAT4	, "mat4"	},
86b815c7f3Sopenharmony_ci	{	SF_FORMAT_MAT5	, "mat5"	},
87b815c7f3Sopenharmony_ci	{	SF_FORMAT_SVX	, "svx"		},
88b815c7f3Sopenharmony_ci	{	SF_FORMAT_PVF	, "pvf"		},
89b815c7f3Sopenharmony_ci	/* Lite remove end */
90b815c7f3Sopenharmony_ci	{	0				, NULL		}
91b815c7f3Sopenharmony_ci} ;
92b815c7f3Sopenharmony_ci
93b815c7f3Sopenharmony_ciint
94b815c7f3Sopenharmony_cimain (void)
95b815c7f3Sopenharmony_ci{	int k ;
96b815c7f3Sopenharmony_ci
97b815c7f3Sopenharmony_ci	for (k = 0 ; read_only_types [k].format ; k++)
98b815c7f3Sopenharmony_ci		pipe_read_test (read_only_types [k].format, read_only_types [k].ext) ;
99b815c7f3Sopenharmony_ci
100b815c7f3Sopenharmony_ci	for (k = 0 ; read_write_types [k].format ; k++)
101b815c7f3Sopenharmony_ci		pipe_write_test (read_write_types [k].ext) ;
102b815c7f3Sopenharmony_ci
103b815c7f3Sopenharmony_ci	for (k = 0 ; read_write_types [k].format ; k++)
104b815c7f3Sopenharmony_ci		useek_pipe_rw_test (read_write_types [k].format, read_write_types [k].ext) ;
105b815c7f3Sopenharmony_ci
106b815c7f3Sopenharmony_ci	if (0)
107b815c7f3Sopenharmony_ci		pipe_test_others (read_write_types, read_only_types) ;
108b815c7f3Sopenharmony_ci
109b815c7f3Sopenharmony_ci	return 0 ;
110b815c7f3Sopenharmony_ci} /* main */
111b815c7f3Sopenharmony_ci
112b815c7f3Sopenharmony_ci/*==============================================================================
113b815c7f3Sopenharmony_ci*/
114b815c7f3Sopenharmony_ci
115b815c7f3Sopenharmony_cistatic void
116b815c7f3Sopenharmony_cipipe_read_test (int filetype, const char *ext)
117b815c7f3Sopenharmony_ci{	static short data [PIPE_TEST_LEN] ;
118b815c7f3Sopenharmony_ci	static char buffer [256] ;
119b815c7f3Sopenharmony_ci	static char filename [256] ;
120b815c7f3Sopenharmony_ci
121b815c7f3Sopenharmony_ci	SNDFILE	*outfile ;
122b815c7f3Sopenharmony_ci	SF_INFO sfinfo ;
123b815c7f3Sopenharmony_ci	int k, retval ;
124b815c7f3Sopenharmony_ci
125b815c7f3Sopenharmony_ci	snprintf (filename, sizeof (filename), "pipe_in.%s", ext) ;
126b815c7f3Sopenharmony_ci	print_test_name ("pipe_read_test", filename) ;
127b815c7f3Sopenharmony_ci
128b815c7f3Sopenharmony_ci	memset (&sfinfo, 0, sizeof (sfinfo)) ;
129b815c7f3Sopenharmony_ci	sfinfo.format = filetype | SF_FORMAT_PCM_16 ;
130b815c7f3Sopenharmony_ci	sfinfo.channels = 1 ;
131b815c7f3Sopenharmony_ci	sfinfo.samplerate = 44100 ;
132b815c7f3Sopenharmony_ci
133b815c7f3Sopenharmony_ci	for (k = 0 ; k < PIPE_TEST_LEN ; k++)
134b815c7f3Sopenharmony_ci		data [k] = PIPE_INDEX (k) ;
135b815c7f3Sopenharmony_ci
136b815c7f3Sopenharmony_ci	outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
137b815c7f3Sopenharmony_ci	test_writef_short_or_die (outfile, 0, data, PIPE_TEST_LEN, __LINE__) ;
138b815c7f3Sopenharmony_ci	sf_close (outfile) ;
139b815c7f3Sopenharmony_ci
140b815c7f3Sopenharmony_ci	snprintf (buffer, sizeof (buffer), "cat %s | ./tests/stdin_test %s ", filename, ext) ;
141b815c7f3Sopenharmony_ci	if ((retval = system (buffer)) != 0)
142b815c7f3Sopenharmony_ci	{	retval = WEXITSTATUS (retval) ;
143b815c7f3Sopenharmony_ci		printf ("\n\n    Line %d : pipe test returned error for file type \"%s\".\n\n", __LINE__, ext) ;
144b815c7f3Sopenharmony_ci		exit (retval) ;
145b815c7f3Sopenharmony_ci		} ;
146b815c7f3Sopenharmony_ci
147b815c7f3Sopenharmony_ci	unlink (filename) ;
148b815c7f3Sopenharmony_ci	puts ("ok") ;
149b815c7f3Sopenharmony_ci
150b815c7f3Sopenharmony_ci	return ;
151b815c7f3Sopenharmony_ci} /* pipe_read_test */
152b815c7f3Sopenharmony_ci
153b815c7f3Sopenharmony_cistatic void
154b815c7f3Sopenharmony_cipipe_write_test (const char *ext)
155b815c7f3Sopenharmony_ci{	static char buffer [256] ;
156b815c7f3Sopenharmony_ci
157b815c7f3Sopenharmony_ci	int retval ;
158b815c7f3Sopenharmony_ci
159b815c7f3Sopenharmony_ci	print_test_name ("pipe_write_test", ext) ;
160b815c7f3Sopenharmony_ci
161b815c7f3Sopenharmony_ci	snprintf (buffer, sizeof (buffer), "./tests/stdout_test %s | ./tests/stdin_test %s ", ext, ext) ;
162b815c7f3Sopenharmony_ci	if ((retval = system (buffer)))
163b815c7f3Sopenharmony_ci	{	retval = WEXITSTATUS (retval) ;
164b815c7f3Sopenharmony_ci		printf ("\n\n     Line %d : pipe test returned error file type \"%s\".\n\n", __LINE__, ext) ;
165b815c7f3Sopenharmony_ci		exit (retval) ;
166b815c7f3Sopenharmony_ci		} ;
167b815c7f3Sopenharmony_ci
168b815c7f3Sopenharmony_ci	puts ("ok") ;
169b815c7f3Sopenharmony_ci
170b815c7f3Sopenharmony_ci	return ;
171b815c7f3Sopenharmony_ci} /* pipe_write_test */
172b815c7f3Sopenharmony_ci
173b815c7f3Sopenharmony_ci/*==============================================================================
174b815c7f3Sopenharmony_ci*/
175b815c7f3Sopenharmony_ci
176b815c7f3Sopenharmony_ci[+ FOR data_type +]
177b815c7f3Sopenharmony_cistatic void
178b815c7f3Sopenharmony_ciuseek_pipe_rw_[+ (get "type_name") +] (const char * ext, SF_INFO * psfinfo_write, SF_INFO * psfinfo_read)
179b815c7f3Sopenharmony_ci{	static [+ (get "type_name") +] buffer [PIPE_TEST_LEN] ;
180b815c7f3Sopenharmony_ci	static [+ (get "type_name") +] data [PIPE_TEST_LEN] ;
181b815c7f3Sopenharmony_ci	SNDFILE *outfile ;
182b815c7f3Sopenharmony_ci	SNDFILE *infile_piped ;
183b815c7f3Sopenharmony_ci
184b815c7f3Sopenharmony_ci	int k, status = 0 ;
185b815c7f3Sopenharmony_ci	int pipefd [2] ;
186b815c7f3Sopenharmony_ci	pid_t pida ;
187b815c7f3Sopenharmony_ci
188b815c7f3Sopenharmony_ci	for (k = 0 ; k < PIPE_TEST_LEN ; k++)
189b815c7f3Sopenharmony_ci		data [k] = PIPE_INDEX (k) ;
190b815c7f3Sopenharmony_ci
191b815c7f3Sopenharmony_ci	/*
192b815c7f3Sopenharmony_ci	** Create the pipe.
193b815c7f3Sopenharmony_ci	*/
194b815c7f3Sopenharmony_ci	exit_if_true (pipe (pipefd) != 0, "\n\n%s %d : pipe failed : %s\n", __func__, __LINE__, strerror (errno)) ;
195b815c7f3Sopenharmony_ci
196b815c7f3Sopenharmony_ci	/*
197b815c7f3Sopenharmony_ci	** Attach the write end of the pipe to be written to.
198b815c7f3Sopenharmony_ci	*/
199b815c7f3Sopenharmony_ci	if ((outfile = sf_open_fd (pipefd [1], SFM_WRITE, psfinfo_write, SF_TRUE)) == NULL)
200b815c7f3Sopenharmony_ci	{	printf ("\n\n%s %d : unable to create unseekable pipe for write type \"%s\".\n", __func__, __LINE__, ext) ;
201b815c7f3Sopenharmony_ci		printf ("\t%s\n\n", sf_strerror (outfile)) ;
202b815c7f3Sopenharmony_ci		exit (1) ;
203b815c7f3Sopenharmony_ci		} ;
204b815c7f3Sopenharmony_ci
205b815c7f3Sopenharmony_ci	if (sf_error (outfile) != SF_ERR_NO_ERROR)
206b815c7f3Sopenharmony_ci	{	printf ("\n\n%s %d : unable to open unseekable pipe for write type \"%s\".\n\n", __func__, __LINE__, ext) ;
207b815c7f3Sopenharmony_ci		exit (1) ;
208b815c7f3Sopenharmony_ci		} ;
209b815c7f3Sopenharmony_ci
210b815c7f3Sopenharmony_ci	/*
211b815c7f3Sopenharmony_ci	** Attach the read end of the pipe to be read from.
212b815c7f3Sopenharmony_ci	*/
213b815c7f3Sopenharmony_ci	if ((infile_piped = sf_open_fd (pipefd [0], SFM_READ, psfinfo_read, SF_TRUE)) == NULL)
214b815c7f3Sopenharmony_ci	{	printf ("\n\n%s %d : unable to create unseekable pipe for read type. \"%s\".\n\n", __func__, __LINE__, ext) ;
215b815c7f3Sopenharmony_ci		exit (1) ;
216b815c7f3Sopenharmony_ci		} ;
217b815c7f3Sopenharmony_ci
218b815c7f3Sopenharmony_ci	if (sf_error (infile_piped) != SF_ERR_NO_ERROR)
219b815c7f3Sopenharmony_ci	{	printf ("\n\n%s %d : unable to open unseekable pipe for read type \"%s\".\n\n", __func__, __LINE__, ext) ;
220b815c7f3Sopenharmony_ci		exit (1) ;
221b815c7f3Sopenharmony_ci		} ;
222b815c7f3Sopenharmony_ci
223b815c7f3Sopenharmony_ci	/* Fork a child process that will write directly into the pipe. */
224b815c7f3Sopenharmony_ci	if ((pida = fork ()) == 0) /* child process */
225b815c7f3Sopenharmony_ci	{	test_writef_[+ (get "type_name") +]_or_die (outfile, 0, data, PIPE_TEST_LEN, __LINE__) ;
226b815c7f3Sopenharmony_ci		exit (0) ;
227b815c7f3Sopenharmony_ci		} ;
228b815c7f3Sopenharmony_ci
229b815c7f3Sopenharmony_ci	/* In the parent process, read from the pipe and compare what is read
230b815c7f3Sopenharmony_ci	** to what is written, if they match everything went as planned.
231b815c7f3Sopenharmony_ci	*/
232b815c7f3Sopenharmony_ci	test_readf_[+ (get "type_name") +]_or_die (infile_piped, 0, buffer, PIPE_TEST_LEN, __LINE__) ;
233b815c7f3Sopenharmony_ci	if (memcmp (buffer, data, sizeof (buffer)) != 0)
234b815c7f3Sopenharmony_ci	{	printf ("\n\n%s %d : unseekable pipe test failed for file type \"%s\".\n\n", __func__, __LINE__, ext) ;
235b815c7f3Sopenharmony_ci		exit (1) ;
236b815c7f3Sopenharmony_ci		} ;
237b815c7f3Sopenharmony_ci
238b815c7f3Sopenharmony_ci	/* Wait for the child process to return. */
239b815c7f3Sopenharmony_ci	waitpid (pida, &status, 0) ;
240b815c7f3Sopenharmony_ci	status = WEXITSTATUS (status) ;
241b815c7f3Sopenharmony_ci	sf_close (outfile) ;
242b815c7f3Sopenharmony_ci	sf_close (infile_piped) ;
243b815c7f3Sopenharmony_ci
244b815c7f3Sopenharmony_ci	if (status != 0)
245b815c7f3Sopenharmony_ci	{	printf ("\n\n%s %d : status of child process is %d for file type %s.\n\n", __func__, __LINE__, status, ext) ;
246b815c7f3Sopenharmony_ci		exit (1) ;
247b815c7f3Sopenharmony_ci		} ;
248b815c7f3Sopenharmony_ci
249b815c7f3Sopenharmony_ci	return ;
250b815c7f3Sopenharmony_ci} /* useek_pipe_rw_[+ (get "type_name") +] */
251b815c7f3Sopenharmony_ci
252b815c7f3Sopenharmony_ci[+ ENDFOR data_type +]
253b815c7f3Sopenharmony_ci
254b815c7f3Sopenharmony_ci
255b815c7f3Sopenharmony_cistatic void
256b815c7f3Sopenharmony_ciuseek_pipe_rw_test (int filetype, const char *ext)
257b815c7f3Sopenharmony_ci{	SF_INFO sfinfo_write ;
258b815c7f3Sopenharmony_ci	SF_INFO sfinfo_read ;
259b815c7f3Sopenharmony_ci
260b815c7f3Sopenharmony_ci	print_test_name ("useek_pipe_rw_test", ext) ;
261b815c7f3Sopenharmony_ci
262b815c7f3Sopenharmony_ci	/*
263b815c7f3Sopenharmony_ci	** Setup the INFO structures for the filetype we will be
264b815c7f3Sopenharmony_ci	** working with.
265b815c7f3Sopenharmony_ci	*/
266b815c7f3Sopenharmony_ci	sfinfo_write.format = filetype | SF_FORMAT_PCM_16 ;
267b815c7f3Sopenharmony_ci	sfinfo_write.channels = 1 ;
268b815c7f3Sopenharmony_ci	sfinfo_write.samplerate = 44100 ;
269b815c7f3Sopenharmony_ci
270b815c7f3Sopenharmony_ci
271b815c7f3Sopenharmony_ci	sfinfo_read.format = 0 ;
272b815c7f3Sopenharmony_ci	if (filetype == SF_FORMAT_RAW)
273b815c7f3Sopenharmony_ci	{	sfinfo_read.format = filetype | SF_FORMAT_PCM_16 ;
274b815c7f3Sopenharmony_ci		sfinfo_read.channels = 1 ;
275b815c7f3Sopenharmony_ci		sfinfo_read.samplerate = 44100 ;
276b815c7f3Sopenharmony_ci		} ;
277b815c7f3Sopenharmony_ci
278b815c7f3Sopenharmony_ci	useek_pipe_rw_short (ext, &sfinfo_write, &sfinfo_read) ;
279b815c7f3Sopenharmony_ci
280b815c7f3Sopenharmony_ci	sfinfo_read.format = sfinfo_write.format = filetype | SF_FORMAT_FLOAT ;
281b815c7f3Sopenharmony_ci	if (sf_format_check (&sfinfo_read) != 0)
282b815c7f3Sopenharmony_ci		useek_pipe_rw_float (ext, &sfinfo_write, &sfinfo_read) ;
283b815c7f3Sopenharmony_ci
284b815c7f3Sopenharmony_ci	sfinfo_read.format = sfinfo_write.format = filetype | SF_FORMAT_DOUBLE ;
285b815c7f3Sopenharmony_ci	if (sf_format_check (&sfinfo_read) != 0)
286b815c7f3Sopenharmony_ci		useek_pipe_rw_double (ext, &sfinfo_write, &sfinfo_read) ;
287b815c7f3Sopenharmony_ci
288b815c7f3Sopenharmony_ci	puts ("ok") ;
289b815c7f3Sopenharmony_ci	return ;
290b815c7f3Sopenharmony_ci} /* useek_pipe_rw_test */
291b815c7f3Sopenharmony_ci
292b815c7f3Sopenharmony_ci
293b815c7f3Sopenharmony_ci
294b815c7f3Sopenharmony_cistatic void
295b815c7f3Sopenharmony_cipipe_test_others (FILETYPE* list1, FILETYPE* list2)
296b815c7f3Sopenharmony_ci{	SF_FORMAT_INFO	info ;
297b815c7f3Sopenharmony_ci	int		k, m, major_count, in_list ;
298b815c7f3Sopenharmony_ci
299b815c7f3Sopenharmony_ci	print_test_name ("pipe_test_others", "") ;
300b815c7f3Sopenharmony_ci
301b815c7f3Sopenharmony_ci	sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
302b815c7f3Sopenharmony_ci
303b815c7f3Sopenharmony_ci	for (k = 0 ; k < major_count ; k++)
304b815c7f3Sopenharmony_ci	{	info.format = k ;
305b815c7f3Sopenharmony_ci
306b815c7f3Sopenharmony_ci		sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
307b815c7f3Sopenharmony_ci
308b815c7f3Sopenharmony_ci		in_list = SF_FALSE ;
309b815c7f3Sopenharmony_ci		for (m = 0 ; list1 [m].format ; m++)
310b815c7f3Sopenharmony_ci			if (info.format == list1 [m].format)
311b815c7f3Sopenharmony_ci				in_list = SF_TRUE ;
312b815c7f3Sopenharmony_ci
313b815c7f3Sopenharmony_ci		for (m = 0 ; list2 [m].format ; m++)
314b815c7f3Sopenharmony_ci			if (info.format == list2 [m].format)
315b815c7f3Sopenharmony_ci				in_list = SF_TRUE ;
316b815c7f3Sopenharmony_ci
317b815c7f3Sopenharmony_ci		if (in_list)
318b815c7f3Sopenharmony_ci			continue ;
319b815c7f3Sopenharmony_ci
320b815c7f3Sopenharmony_ci		printf ("%s  %x\n", info.name, info.format) ;
321b815c7f3Sopenharmony_ci
322b815c7f3Sopenharmony_ci		if (1)
323b815c7f3Sopenharmony_ci		{	static short data [PIPE_TEST_LEN] ;
324b815c7f3Sopenharmony_ci			static char buffer [256] ;
325b815c7f3Sopenharmony_ci			static const char *filename = "pipe_in.dat" ;
326b815c7f3Sopenharmony_ci
327b815c7f3Sopenharmony_ci			SNDFILE	*outfile ;
328b815c7f3Sopenharmony_ci			SF_INFO sfinfo ;
329b815c7f3Sopenharmony_ci			int retval ;
330b815c7f3Sopenharmony_ci
331b815c7f3Sopenharmony_ci			memset (&sfinfo, 0, sizeof (sfinfo)) ;
332b815c7f3Sopenharmony_ci			sfinfo.format = info.format | SF_FORMAT_PCM_16 ;
333b815c7f3Sopenharmony_ci			sfinfo.channels = 1 ;
334b815c7f3Sopenharmony_ci			sfinfo.samplerate = 44100 ;
335b815c7f3Sopenharmony_ci
336b815c7f3Sopenharmony_ci			outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
337b815c7f3Sopenharmony_ci			test_writef_short_or_die (outfile, 0, data, PIPE_TEST_LEN, __LINE__) ;
338b815c7f3Sopenharmony_ci			sf_close (outfile) ;
339b815c7f3Sopenharmony_ci
340b815c7f3Sopenharmony_ci			snprintf (buffer, sizeof (buffer), "cat %s | ./tests/stdin_test %s %d ", filename, info.extension, PIPE_TEST_LEN) ;
341b815c7f3Sopenharmony_ci			if ((retval = system (buffer)) == 0)
342b815c7f3Sopenharmony_ci			{	retval = WEXITSTATUS (retval) ;
343b815c7f3Sopenharmony_ci				printf ("\n\n     Line %d : pipe test should have returned error file type \"%s\" but didn't.\n\n", __LINE__, info.name) ;
344b815c7f3Sopenharmony_ci				exit (1) ;
345b815c7f3Sopenharmony_ci				} ;
346b815c7f3Sopenharmony_ci
347b815c7f3Sopenharmony_ci			unlink (filename) ;
348b815c7f3Sopenharmony_ci			} ;
349b815c7f3Sopenharmony_ci		} ;
350b815c7f3Sopenharmony_ci
351b815c7f3Sopenharmony_ci
352b815c7f3Sopenharmony_ci	puts ("ok") ;
353b815c7f3Sopenharmony_ci
354b815c7f3Sopenharmony_ci	return ;
355b815c7f3Sopenharmony_ci} /* pipe_test_others */
356b815c7f3Sopenharmony_ci
357b815c7f3Sopenharmony_ci
358b815c7f3Sopenharmony_ci/*==============================================================================
359b815c7f3Sopenharmony_ci*/
360b815c7f3Sopenharmony_ci
361b815c7f3Sopenharmony_ci#endif
362b815c7f3Sopenharmony_ci
363