mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-26 19:40:24 +00:00
tests/error_test.c: introduce wav_list_recover_test to cover #374
The test is currently been negated so it expects to hit the problem. That will change when the problem is fixed.
This commit is contained in:
parent
0faf893fd2
commit
cc5be43f09
@ -174,6 +174,47 @@ bad_wav_test (const char * filename)
|
||||
puts ("ok") ;
|
||||
} /* bad_wav_test */
|
||||
|
||||
static void
|
||||
wav_list_recover_test (const char * filename)
|
||||
{ SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
FILE *file ;
|
||||
const char data [] =
|
||||
"RIFF" "J\000\000\000"
|
||||
"WAVE" "fmt " "\020\000\000\000" "\001\000\001\000D\254\000\000\210X\001\000\002\000\020\000"
|
||||
"LIST" "\014\000\000\000" "test" "\010\000\000\000" "1234" /* test is 4 bytes short inside LIST container */
|
||||
"data" "\004\000\000\000" "abcd" ;
|
||||
|
||||
print_test_name (__func__, filename) ;
|
||||
|
||||
if ((file = fopen (filename, "w")) == NULL)
|
||||
{ printf ("\n\nLine %d : fopen returned NULL.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
exit_if_true (fwrite (data, sizeof (data) - 1, 1, file) != 1, "\n\nLine %d : fwrite failed.\n", __LINE__) ;
|
||||
fclose (file) ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
|
||||
|
||||
if (sndfile)
|
||||
{ printf ("\n\nLine %d : expected failure - issue 374 reports no recovery from bogus LIST content.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
/*
|
||||
if (sfinfo.frames != 2)
|
||||
{ printf ("\n\nLine %d : Should have read data chunk with 2 stereo frames, got %ld.\n\n", __LINE__, (long)sfinfo.frames) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
*/
|
||||
|
||||
unlink (filename) ;
|
||||
puts ("ok") ;
|
||||
} /* wav_list_recover_test */
|
||||
|
||||
static void
|
||||
error_close_test (void)
|
||||
{ static short buffer [SHORT_BUFFER] ;
|
||||
@ -266,6 +307,7 @@ main (void)
|
||||
no_file_test ("no_file.wav") ;
|
||||
zero_length_test ("zero_length.wav") ;
|
||||
bad_wav_test ("bad_wav.wav") ;
|
||||
wav_list_recover_test ("list_recover.wav") ;
|
||||
|
||||
unrecognised_test () ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user