Replace Sys.time by Unix.time in main.ml.
[Faustine.git] / interpreter / lib / src / libsndfile-1.0.25 / tests / utils.h
1 /*
2 ** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
3 **
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.
8 **
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.
13 **
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.
17 */
18
19 /*
20 ** Utility functions to make writing the test suite easier.
21 **
22 ** The .c and .h files were generated automagically with Autogen from
23 ** the files utils.def and utils.tpl.
24 */
25
26
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 #include <stdint.h>
33 #include <stdarg.h>
34
35 #define SF_COUNT_TO_LONG(x) ((long) (x))
36 #define ARRAY_LEN(x) ((int) (sizeof (x)) / (sizeof ((x) [0])))
37 #define SIGNED_SIZEOF(x) ((int64_t) (sizeof (x)))
38 #define NOT(x) (! (x))
39
40 #define PIPE_INDEX(x) ((x) + 500)
41 #define PIPE_TEST_LEN 12345
42
43
44 void gen_windowed_sine_float (float *data, int len, double maximum) ;
45 void gen_windowed_sine_double (double *data, int len, double maximum) ;
46
47
48 void create_short_sndfile (const char *filename, int format, int channels) ;
49
50 void check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num) ;
51
52 void print_test_name (const char *test, const char *filename) ;
53
54 void dump_data_to_file (const char *filename, const void *data, unsigned int datalen) ;
55
56 void write_mono_file (const char * filename, int format, int srate, float * output, int len) ;
57
58 static inline void
59 exit_if_true (int test, const char *format, ...)
60 { if (test)
61 { va_list argptr ;
62 va_start (argptr, format) ;
63 vprintf (format, argptr) ;
64 va_end (argptr) ;
65 exit (1) ;
66 } ;
67 } /* exit_if_true */
68
69 /*
70 ** Functions for saving two vectors of data in an ascii text file which
71 ** can then be loaded into GNU octave for comparison.
72 */
73
74 int oct_save_short (const short *a, const short *b, int len) ;
75 int oct_save_int (const int *a, const int *b, int len) ;
76 int oct_save_float (const float *a, const float *b, int len) ;
77 int oct_save_double (const double *a, const double *b, int len) ;
78
79
80 void delete_file (int format, const char *filename) ;
81
82 void count_open_files (void) ;
83 void increment_open_file_count (void) ;
84 void check_open_file_count_or_die (int lineno) ;
85
86 #ifdef SNDFILE_H
87
88 static inline void
89 sf_info_clear (SF_INFO * info)
90 { memset (info, 0, sizeof (SF_INFO)) ;
91 } /* sf_info_clear */
92
93 static inline void
94 sf_info_setup (SF_INFO * info, int format, int samplerate, int channels)
95 { sf_info_clear (info) ;
96
97 info->format = format ;
98 info->samplerate = samplerate ;
99 info->channels = channels ;
100 } /* sf_info_setup */
101
102
103 void dump_log_buffer (SNDFILE *file) ;
104 void check_log_buffer_or_die (SNDFILE *file, int line_num) ;
105 int string_in_log_buffer (SNDFILE *file, const char *s) ;
106 void hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) ;
107
108
109 SNDFILE *test_open_file_or_die
110 (const char *filename, int mode, SF_INFO *sfinfo, int allow_fd, int line_num) ;
111
112 void test_read_write_position_or_die
113 (SNDFILE *file, int line_num, int pass, sf_count_t read_pos, sf_count_t write_pos) ;
114
115 void test_seek_or_die
116 (SNDFILE *file, sf_count_t offset, int whence, sf_count_t new_pos, int channels, int line_num) ;
117
118
119 void test_read_short_or_die
120 (SNDFILE *file, int pass, short *test, sf_count_t items, int line_num) ;
121 void test_read_int_or_die
122 (SNDFILE *file, int pass, int *test, sf_count_t items, int line_num) ;
123 void test_read_float_or_die
124 (SNDFILE *file, int pass, float *test, sf_count_t items, int line_num) ;
125 void test_read_double_or_die
126 (SNDFILE *file, int pass, double *test, sf_count_t items, int line_num) ;
127
128 void test_readf_short_or_die
129 (SNDFILE *file, int pass, short *test, sf_count_t frames, int line_num) ;
130 void test_readf_int_or_die
131 (SNDFILE *file, int pass, int *test, sf_count_t frames, int line_num) ;
132 void test_readf_float_or_die
133 (SNDFILE *file, int pass, float *test, sf_count_t frames, int line_num) ;
134 void test_readf_double_or_die
135 (SNDFILE *file, int pass, double *test, sf_count_t frames, int line_num) ;
136
137
138 void
139 test_read_raw_or_die (SNDFILE *file, int pass, void *test, sf_count_t items, int line_num) ;
140
141
142 void test_write_short_or_die
143 (SNDFILE *file, int pass, const short *test, sf_count_t items, int line_num) ;
144 void test_write_int_or_die
145 (SNDFILE *file, int pass, const int *test, sf_count_t items, int line_num) ;
146 void test_write_float_or_die
147 (SNDFILE *file, int pass, const float *test, sf_count_t items, int line_num) ;
148 void test_write_double_or_die
149 (SNDFILE *file, int pass, const double *test, sf_count_t items, int line_num) ;
150
151 void test_writef_short_or_die
152 (SNDFILE *file, int pass, const short *test, sf_count_t frames, int line_num) ;
153 void test_writef_int_or_die
154 (SNDFILE *file, int pass, const int *test, sf_count_t frames, int line_num) ;
155 void test_writef_float_or_die
156 (SNDFILE *file, int pass, const float *test, sf_count_t frames, int line_num) ;
157 void test_writef_double_or_die
158 (SNDFILE *file, int pass, const double *test, sf_count_t frames, int line_num) ;
159
160
161 void
162 test_write_raw_or_die (SNDFILE *file, int pass, const void *test, sf_count_t items, int line_num) ;
163
164 void compare_short_or_die (const short *left, const short *right, unsigned count, int line_num) ;
165 void compare_int_or_die (const int *left, const int *right, unsigned count, int line_num) ;
166 void compare_float_or_die (const float *left, const float *right, unsigned count, int line_num) ;
167 void compare_double_or_die (const double *left, const double *right, unsigned count, int line_num) ;
168
169
170
171 void gen_lowpass_noise_float (float *data, int len) ;
172
173 sf_count_t file_length (const char * fname) ;
174 sf_count_t file_length_fd (int fd) ;
175
176 #endif
177
178 #ifdef __cplusplus
179 } /* extern "C" */
180 #endif /* __cplusplus */
181
182
183