annotate src/libsndfile-1.0.25/tests/utils.h @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 545efbb81310
children
rev   line source
cannam@85 1 /*
cannam@85 2 ** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
cannam@85 3 **
cannam@85 4 ** This program is free software; you can redistribute it and/or modify
cannam@85 5 ** it under the terms of the GNU General Public License as published by
cannam@85 6 ** the Free Software Foundation; either version 2 of the License, or
cannam@85 7 ** (at your option) any later version.
cannam@85 8 **
cannam@85 9 ** This program is distributed in the hope that it will be useful,
cannam@85 10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@85 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@85 12 ** GNU General Public License for more details.
cannam@85 13 **
cannam@85 14 ** You should have received a copy of the GNU General Public License
cannam@85 15 ** along with this program; if not, write to the Free Software
cannam@85 16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cannam@85 17 */
cannam@85 18
cannam@85 19 /*
cannam@85 20 ** Utility functions to make writing the test suite easier.
cannam@85 21 **
cannam@85 22 ** The .c and .h files were generated automagically with Autogen from
cannam@85 23 ** the files utils.def and utils.tpl.
cannam@85 24 */
cannam@85 25
cannam@85 26
cannam@85 27
cannam@85 28 #ifdef __cplusplus
cannam@85 29 extern "C" {
cannam@85 30 #endif /* __cplusplus */
cannam@85 31
cannam@85 32 #include <stdint.h>
cannam@85 33 #include <stdarg.h>
cannam@85 34
cannam@85 35 #define SF_COUNT_TO_LONG(x) ((long) (x))
cannam@85 36 #define ARRAY_LEN(x) ((int) (sizeof (x)) / (sizeof ((x) [0])))
cannam@85 37 #define SIGNED_SIZEOF(x) ((int64_t) (sizeof (x)))
cannam@85 38 #define NOT(x) (! (x))
cannam@85 39
cannam@85 40 #define PIPE_INDEX(x) ((x) + 500)
cannam@85 41 #define PIPE_TEST_LEN 12345
cannam@85 42
cannam@85 43
cannam@85 44 void gen_windowed_sine_float (float *data, int len, double maximum) ;
cannam@85 45 void gen_windowed_sine_double (double *data, int len, double maximum) ;
cannam@85 46
cannam@85 47
cannam@85 48 void create_short_sndfile (const char *filename, int format, int channels) ;
cannam@85 49
cannam@85 50 void check_file_hash_or_die (const char *filename, uint64_t target_hash, int line_num) ;
cannam@85 51
cannam@85 52 void print_test_name (const char *test, const char *filename) ;
cannam@85 53
cannam@85 54 void dump_data_to_file (const char *filename, const void *data, unsigned int datalen) ;
cannam@85 55
cannam@85 56 void write_mono_file (const char * filename, int format, int srate, float * output, int len) ;
cannam@85 57
cannam@85 58 static inline void
cannam@85 59 exit_if_true (int test, const char *format, ...)
cannam@85 60 { if (test)
cannam@85 61 { va_list argptr ;
cannam@85 62 va_start (argptr, format) ;
cannam@85 63 vprintf (format, argptr) ;
cannam@85 64 va_end (argptr) ;
cannam@85 65 exit (1) ;
cannam@85 66 } ;
cannam@85 67 } /* exit_if_true */
cannam@85 68
cannam@85 69 /*
cannam@85 70 ** Functions for saving two vectors of data in an ascii text file which
cannam@85 71 ** can then be loaded into GNU octave for comparison.
cannam@85 72 */
cannam@85 73
cannam@85 74 int oct_save_short (const short *a, const short *b, int len) ;
cannam@85 75 int oct_save_int (const int *a, const int *b, int len) ;
cannam@85 76 int oct_save_float (const float *a, const float *b, int len) ;
cannam@85 77 int oct_save_double (const double *a, const double *b, int len) ;
cannam@85 78
cannam@85 79
cannam@85 80 void delete_file (int format, const char *filename) ;
cannam@85 81
cannam@85 82 void count_open_files (void) ;
cannam@85 83 void increment_open_file_count (void) ;
cannam@85 84 void check_open_file_count_or_die (int lineno) ;
cannam@85 85
cannam@85 86 #ifdef SNDFILE_H
cannam@85 87
cannam@85 88 static inline void
cannam@85 89 sf_info_clear (SF_INFO * info)
cannam@85 90 { memset (info, 0, sizeof (SF_INFO)) ;
cannam@85 91 } /* sf_info_clear */
cannam@85 92
cannam@85 93 static inline void
cannam@85 94 sf_info_setup (SF_INFO * info, int format, int samplerate, int channels)
cannam@85 95 { sf_info_clear (info) ;
cannam@85 96
cannam@85 97 info->format = format ;
cannam@85 98 info->samplerate = samplerate ;
cannam@85 99 info->channels = channels ;
cannam@85 100 } /* sf_info_setup */
cannam@85 101
cannam@85 102
cannam@85 103 void dump_log_buffer (SNDFILE *file) ;
cannam@85 104 void check_log_buffer_or_die (SNDFILE *file, int line_num) ;
cannam@85 105 int string_in_log_buffer (SNDFILE *file, const char *s) ;
cannam@85 106 void hexdump_file (const char * filename, sf_count_t offset, sf_count_t length) ;
cannam@85 107
cannam@85 108
cannam@85 109 SNDFILE *test_open_file_or_die
cannam@85 110 (const char *filename, int mode, SF_INFO *sfinfo, int allow_fd, int line_num) ;
cannam@85 111
cannam@85 112 void test_read_write_position_or_die
cannam@85 113 (SNDFILE *file, int line_num, int pass, sf_count_t read_pos, sf_count_t write_pos) ;
cannam@85 114
cannam@85 115 void test_seek_or_die
cannam@85 116 (SNDFILE *file, sf_count_t offset, int whence, sf_count_t new_pos, int channels, int line_num) ;
cannam@85 117
cannam@85 118
cannam@85 119 void test_read_short_or_die
cannam@85 120 (SNDFILE *file, int pass, short *test, sf_count_t items, int line_num) ;
cannam@85 121 void test_read_int_or_die
cannam@85 122 (SNDFILE *file, int pass, int *test, sf_count_t items, int line_num) ;
cannam@85 123 void test_read_float_or_die
cannam@85 124 (SNDFILE *file, int pass, float *test, sf_count_t items, int line_num) ;
cannam@85 125 void test_read_double_or_die
cannam@85 126 (SNDFILE *file, int pass, double *test, sf_count_t items, int line_num) ;
cannam@85 127
cannam@85 128 void test_readf_short_or_die
cannam@85 129 (SNDFILE *file, int pass, short *test, sf_count_t frames, int line_num) ;
cannam@85 130 void test_readf_int_or_die
cannam@85 131 (SNDFILE *file, int pass, int *test, sf_count_t frames, int line_num) ;
cannam@85 132 void test_readf_float_or_die
cannam@85 133 (SNDFILE *file, int pass, float *test, sf_count_t frames, int line_num) ;
cannam@85 134 void test_readf_double_or_die
cannam@85 135 (SNDFILE *file, int pass, double *test, sf_count_t frames, int line_num) ;
cannam@85 136
cannam@85 137
cannam@85 138 void
cannam@85 139 test_read_raw_or_die (SNDFILE *file, int pass, void *test, sf_count_t items, int line_num) ;
cannam@85 140
cannam@85 141
cannam@85 142 void test_write_short_or_die
cannam@85 143 (SNDFILE *file, int pass, const short *test, sf_count_t items, int line_num) ;
cannam@85 144 void test_write_int_or_die
cannam@85 145 (SNDFILE *file, int pass, const int *test, sf_count_t items, int line_num) ;
cannam@85 146 void test_write_float_or_die
cannam@85 147 (SNDFILE *file, int pass, const float *test, sf_count_t items, int line_num) ;
cannam@85 148 void test_write_double_or_die
cannam@85 149 (SNDFILE *file, int pass, const double *test, sf_count_t items, int line_num) ;
cannam@85 150
cannam@85 151 void test_writef_short_or_die
cannam@85 152 (SNDFILE *file, int pass, const short *test, sf_count_t frames, int line_num) ;
cannam@85 153 void test_writef_int_or_die
cannam@85 154 (SNDFILE *file, int pass, const int *test, sf_count_t frames, int line_num) ;
cannam@85 155 void test_writef_float_or_die
cannam@85 156 (SNDFILE *file, int pass, const float *test, sf_count_t frames, int line_num) ;
cannam@85 157 void test_writef_double_or_die
cannam@85 158 (SNDFILE *file, int pass, const double *test, sf_count_t frames, int line_num) ;
cannam@85 159
cannam@85 160
cannam@85 161 void
cannam@85 162 test_write_raw_or_die (SNDFILE *file, int pass, const void *test, sf_count_t items, int line_num) ;
cannam@85 163
cannam@85 164 void compare_short_or_die (const short *left, const short *right, unsigned count, int line_num) ;
cannam@85 165 void compare_int_or_die (const int *left, const int *right, unsigned count, int line_num) ;
cannam@85 166 void compare_float_or_die (const float *left, const float *right, unsigned count, int line_num) ;
cannam@85 167 void compare_double_or_die (const double *left, const double *right, unsigned count, int line_num) ;
cannam@85 168
cannam@85 169
cannam@85 170
cannam@85 171 void gen_lowpass_noise_float (float *data, int len) ;
cannam@85 172
cannam@85 173 sf_count_t file_length (const char * fname) ;
cannam@85 174 sf_count_t file_length_fd (int fd) ;
cannam@85 175
cannam@85 176 #endif
cannam@85 177
cannam@85 178 #ifdef __cplusplus
cannam@85 179 } /* extern "C" */
cannam@85 180 #endif /* __cplusplus */
cannam@85 181
cannam@85 182
cannam@85 183