80a696cf53257d42e3051f39db12cbc01c27e0d9
2 ** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 /*==========================================================================
20 ** This is a test program which tests reading from stdin and writing to
34 #include <sys/types.h>
44 #if (OS_IS_WIN32) || defined (__EMX__)
49 puts (" stdio_test : this test doesn't work on win32.") ;
56 #define WIFEXITED(s) (((s) & 0xff) == 0)
59 #define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
63 static size_t file_length (const char *filename
) ;
64 static int file_exists (const char *filename
) ;
65 static void stdio_test (const char *filetype
) ;
67 static const char *filetypes
[] =
68 { "raw", "wav", "aiff", "au", "paf", "svx", "nist", "ircam",
69 "voc", "w64", "mat4", "mat5", "pvf",
77 if (file_exists ("libsndfile.spec.in"))
78 exit_if_true (chdir ("tests") != 0, "\n Error : chdir ('tests') failed.\n") ;
80 for (k
= 0 ; filetypes
[k
] ; k
++)
81 stdio_test (filetypes
[k
]) ;
88 stdio_test (const char *filetype
)
89 { static char buffer
[256] ;
91 int file_size
, retval
;
93 print_test_name ("stdio_test", filetype
) ;
95 snprintf (buffer
, sizeof (buffer
), "./stdout_test %s > stdio.%s", filetype
, filetype
) ;
96 if ((retval
= system (buffer
)))
97 { retval
= WIFEXITED (retval
) ? WEXITSTATUS (retval
) : 1 ;
98 printf ("%s : %s", buffer
, (strerror (retval
))) ;
102 snprintf (buffer
, sizeof (buffer
), "stdio.%s", filetype
) ;
103 if ((file_size
= file_length (buffer
)) < PIPE_TEST_LEN
)
104 { printf ("\n Error : test file '%s' too small (%d).\n\n", buffer
, file_size
) ;
108 snprintf (buffer
, sizeof (buffer
), "./stdin_test %s < stdio.%s", filetype
, filetype
) ;
109 if ((retval
= system (buffer
)))
110 { retval
= WIFEXITED (retval
) ? WEXITSTATUS (retval
) : 1 ;
111 printf ("%s : %s", buffer
, (strerror (retval
))) ;
115 snprintf (buffer
, sizeof (buffer
), "rm stdio.%s", filetype
) ;
116 if ((retval
= system (buffer
)))
117 { retval
= WIFEXITED (retval
) ? WEXITSTATUS (retval
) : 1 ;
118 printf ("%s : %s", buffer
, (strerror (retval
))) ;
131 file_length (const char *filename
)
134 if (stat (filename
, &buf
))
135 { perror (filename
) ;
143 file_exists (const char *filename
)
146 if (stat (filename
, &buf
))