mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
FS-4657 --resolve update libsndfile to its latest master
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2002-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@@ -68,10 +69,11 @@ file_open_test (const char *filename)
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ;
|
||||
psf->file.mode = SFM_READ ;
|
||||
snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ;
|
||||
|
||||
/* Test that open for read fails if the file doesn't exist. */
|
||||
error = psf_fopen (psf, psf->filename, SFM_READ) ;
|
||||
error = psf_fopen (psf) ;
|
||||
if (error == 0)
|
||||
{ printf ("\n\nLine %d: psf_fopen() should have failed.\n\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
@@ -81,26 +83,26 @@ file_open_test (const char *filename)
|
||||
psf->error = SFE_NO_ERROR ;
|
||||
|
||||
/* Test file open in write mode. */
|
||||
psf->mode = SFM_WRITE ;
|
||||
psf->file.mode = SFM_WRITE ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
|
||||
test_close_or_die (psf, __LINE__) ;
|
||||
|
||||
unlink (psf->filename) ;
|
||||
unlink (psf->file.path.c) ;
|
||||
|
||||
/* Test file open in read/write mode for a non-existant file. */
|
||||
psf->mode = SFM_RDWR ;
|
||||
psf->file.mode = SFM_RDWR ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
|
||||
test_close_or_die (psf, __LINE__) ;
|
||||
|
||||
/* Test file open in read/write mode for an existing file. */
|
||||
psf->mode = SFM_RDWR ;
|
||||
psf->file.mode = SFM_RDWR ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
|
||||
test_close_or_die (psf, __LINE__) ;
|
||||
|
||||
unlink (psf->filename) ;
|
||||
unlink (psf->file.path.c) ;
|
||||
puts ("ok") ;
|
||||
} /* file_open_test */
|
||||
|
||||
@@ -121,17 +123,17 @@ file_read_write_test (const char *filename)
|
||||
|
||||
memset (&sf_data, 0, sizeof (sf_data)) ;
|
||||
psf = &sf_data ;
|
||||
snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ;
|
||||
snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ;
|
||||
|
||||
/* Test file open in write mode. */
|
||||
psf->mode = SFM_WRITE ;
|
||||
psf->file.mode = SFM_WRITE ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
|
||||
make_data (data_out, ARRAY_LEN (data_out), 1) ;
|
||||
test_write_or_die (psf, data_out, sizeof (data_out [0]), ARRAY_LEN (data_out), sizeof (data_out), __LINE__) ;
|
||||
|
||||
if ((retval = psf_get_filelen (psf)) != sizeof (data_out))
|
||||
{ printf ("\n\nLine %d: file length after write is not correct (%ld should be %d).\n\n", __LINE__, (long) retval, (int) sizeof (data_out)) ;
|
||||
{ printf ("\n\nLine %d: file length after write is not correct (%" PRId64 " should be %zd).\n\n", __LINE__, retval, sizeof (data_out)) ;
|
||||
if (retval == 0)
|
||||
printf ("An fsync() may be necessary before fstat() in psf_get_filelen().\n\n") ;
|
||||
exit (1) ;
|
||||
@@ -141,7 +143,7 @@ file_read_write_test (const char *filename)
|
||||
test_write_or_die (psf, data_out, ARRAY_LEN (data_out), sizeof (data_out [0]), 2 * sizeof (data_out), __LINE__) ;
|
||||
|
||||
if ((retval = psf_get_filelen (psf)) != 2 * sizeof (data_out))
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%ld should be %d)\n\n", __LINE__, (long) retval, 2 * ((int) sizeof (data_out))) ;
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 2 * sizeof (data_out)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
@@ -156,7 +158,7 @@ file_read_write_test (const char *filename)
|
||||
print_test_name ("Testing file read") ;
|
||||
|
||||
/* Test file open in write mode. */
|
||||
psf->mode = SFM_READ ;
|
||||
psf->file.mode = SFM_READ ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
|
||||
make_data (data_out, ARRAY_LEN (data_out), 1) ;
|
||||
@@ -180,7 +182,7 @@ file_read_write_test (const char *filename)
|
||||
print_test_name ("Testing file seek") ;
|
||||
|
||||
/* Test file open in read/write mode. */
|
||||
psf->mode = SFM_RDWR ;
|
||||
psf->file.mode = SFM_RDWR ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
|
||||
test_seek_or_die (psf, 0, SEEK_SET, 0, __LINE__) ;
|
||||
@@ -218,12 +220,12 @@ file_read_write_test (const char *filename)
|
||||
print_test_name ("Testing file offset") ;
|
||||
|
||||
/* Test file open in read/write mode. */
|
||||
psf->mode = SFM_RDWR ;
|
||||
psf->file.mode = SFM_RDWR ;
|
||||
psf->fileoffset = sizeof (data_out [0]) * ARRAY_LEN (data_out) ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
|
||||
if ((retval = psf_get_filelen (psf)) != 3 * sizeof (data_out))
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%ld should be %d)\n\n", __LINE__, (long) retval, 3 * ((int) sizeof (data_out))) ;
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 3 * sizeof (data_out)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
@@ -234,12 +236,12 @@ file_read_write_test (const char *filename)
|
||||
|
||||
/* final test with psf->fileoffset == 0. */
|
||||
|
||||
psf->mode = SFM_RDWR ;
|
||||
psf->file.mode = SFM_RDWR ;
|
||||
psf->fileoffset = 0 ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
|
||||
if ((retval = psf_get_filelen (psf)) != 3 * sizeof (data_out))
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%ld should be %d)\n\n", __LINE__, (long) retval, 3 * ((int) sizeof (data_out))) ;
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %zd)\n\n", __LINE__, retval, 3 * sizeof (data_out)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
@@ -277,20 +279,20 @@ file_truncate_test (const char *filename)
|
||||
memset (buffer, 0xEE, sizeof (buffer)) ;
|
||||
|
||||
psf = &sf_data ;
|
||||
snprintf (psf->filename, sizeof (psf->filename), "%s", filename) ;
|
||||
snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ;
|
||||
|
||||
/*
|
||||
** Open the file write mode, write 0xEE data and then extend the file
|
||||
** using truncate (the extended data should be 0x00).
|
||||
*/
|
||||
psf->mode = SFM_WRITE ;
|
||||
psf->file.mode = SFM_WRITE ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
test_write_or_die (psf, buffer, sizeof (buffer) / 2, 1, sizeof (buffer) / 2, __LINE__) ;
|
||||
psf_ftruncate (psf, sizeof (buffer)) ;
|
||||
test_close_or_die (psf, __LINE__) ;
|
||||
|
||||
/* Open the file in read mode and check the data. */
|
||||
psf->mode = SFM_READ ;
|
||||
psf->file.mode = SFM_READ ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
test_read_or_die (psf, buffer, sizeof (buffer), 1, sizeof (buffer), __LINE__) ;
|
||||
test_close_or_die (psf, __LINE__) ;
|
||||
@@ -308,13 +310,13 @@ file_truncate_test (const char *filename)
|
||||
} ;
|
||||
|
||||
/* Open the file in read/write and shorten the file using truncate. */
|
||||
psf->mode = SFM_RDWR ;
|
||||
psf->file.mode = SFM_RDWR ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
psf_ftruncate (psf, sizeof (buffer) / 4) ;
|
||||
test_close_or_die (psf, __LINE__) ;
|
||||
|
||||
/* Check the file length. */
|
||||
psf->mode = SFM_READ ;
|
||||
psf->file.mode = SFM_READ ;
|
||||
test_open_or_die (psf, __LINE__) ;
|
||||
test_seek_or_die (psf, 0, SEEK_END, SIGNED_SIZEOF (buffer) / 4, __LINE__) ;
|
||||
test_close_or_die (psf, __LINE__) ;
|
||||
@@ -331,7 +333,7 @@ test_open_or_die (SF_PRIVATE *psf, int linenum)
|
||||
{ int error ;
|
||||
|
||||
/* Test that open for read fails if the file doesn't exist. */
|
||||
error = psf_fopen (psf, psf->filename, psf->mode) ;
|
||||
error = psf_fopen (psf) ;
|
||||
if (error)
|
||||
{ printf ("\n\nLine %d: psf_fopen() failed : %s\n\n", linenum, strerror (errno)) ;
|
||||
exit (1) ;
|
||||
@@ -344,7 +346,7 @@ test_close_or_die (SF_PRIVATE *psf, int linenum)
|
||||
{
|
||||
psf_fclose (psf) ;
|
||||
if (psf_file_valid (psf))
|
||||
{ printf ("\n\nLine %d: psf->filedes should not be valid.\n\n", linenum) ;
|
||||
{ printf ("\n\nLine %d: psf->file.filedes should not be valid.\n\n", linenum) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
@@ -356,12 +358,12 @@ test_write_or_die (SF_PRIVATE *psf, void *data, sf_count_t bytes, sf_count_t ite
|
||||
|
||||
retval = psf_fwrite (data, bytes, items, psf) ;
|
||||
if (retval != items)
|
||||
{ printf ("\n\nLine %d: psf_write() returned %ld (should be %ld)\n\n", linenum, (long) retval, (long) items) ;
|
||||
{ printf ("\n\nLine %d: psf_write() returned %" PRId64 " (should be %" PRId64 ")\n\n", linenum, retval, items) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if ((retval = psf_ftell (psf)) != new_position)
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%ld should be %ld)\n\n", linenum, (long) retval, (long) new_position) ;
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %" PRId64 ")\n\n", linenum, retval, new_position) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
@@ -374,12 +376,12 @@ test_read_or_die (SF_PRIVATE *psf, void *data, sf_count_t bytes, sf_count_t item
|
||||
|
||||
retval = psf_fread (data, bytes, items, psf) ;
|
||||
if (retval != items)
|
||||
{ printf ("\n\nLine %d: psf_write() returned %ld (should be %ld)\n\n", linenum, (long) retval, (long) items) ;
|
||||
{ printf ("\n\nLine %d: psf_write() returned %" PRId64 " (should be %" PRId64 ")\n\n", linenum, retval, items) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if ((retval = psf_ftell (psf)) != new_position)
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%ld should be %ld)\n\n", linenum, (long) retval, (long) new_position) ;
|
||||
{ printf ("\n\nLine %d: file length after write is not correct. (%" PRId64 " should be %" PRId64 ")\n\n", linenum, retval, new_position) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
@@ -393,8 +395,8 @@ test_seek_or_die (SF_PRIVATE *psf, sf_count_t offset, int whence, sf_count_t new
|
||||
retval = psf_fseek (psf, offset, whence) ;
|
||||
|
||||
if (retval != new_position)
|
||||
{ printf ("\n\nLine %d: psf_fseek() failed. New position is %ld (should be %ld).\n\n",
|
||||
linenum, (long) retval, (long) new_position) ;
|
||||
{ printf ("\n\nLine %d: psf_fseek() failed. New position is %" PRId64 " (should be %" PRId64 ").\n\n",
|
||||
linenum, retval, new_position) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
|
Reference in New Issue
Block a user