ref: 387b605e7539ce6e8a637bed7dd869271960dfaa
parent: 7b5e1a5cb8dbcf879fca6c4ad6ab3f7dfaf088d8
author: Paul Brossier <piem@piem.org>
date: Wed Dec 19 09:49:22 EST 2018
[tests] avoid test-sink crash on missing input file
--- a/tests/src/io/base-sink_custom.h
+++ b/tests/src/io/base-sink_custom.h
@@ -25,17 +25,21 @@
char_t *source_path = argv[1];
char_t *sink_path = argv[2];
+ aubio_source_t *i = NULL;
+ aubio_sink_custom_t *o = NULL;
+
if ( argc >= 4 ) samplerate = atoi(argv[3]);
if ( argc >= 5 ) hop_size = atoi(argv[4]);
fvec_t *vec = new_fvec(hop_size);
+ if (!vec) { err = 1; goto failure; }
- aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
+ i = new_aubio_source(source_path, samplerate, hop_size);
+ if (!i) { err = 1; goto failure; }
if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
- aubio_sink_custom_t *o = new_aubio_sink_custom(sink_path, samplerate);
-
- if (!vec || !i || !o) { err = 1; goto failure; }
+ o = new_aubio_sink_custom(sink_path, samplerate);
+ if (!o) { err = 1; goto failure; }
do {
aubio_source_do(i, vec, &read);
--- a/tests/src/io/test-sink.c
+++ b/tests/src/io/test-sink.c
@@ -21,17 +21,21 @@
char_t *source_path = argv[1];
char_t *sink_path = argv[2];
+ aubio_source_t *i = NULL;
+ aubio_sink_t *o = NULL;
+
if ( argc >= 4 ) samplerate = atoi(argv[3]);
if ( argc >= 5 ) hop_size = atoi(argv[4]);
fvec_t *vec = new_fvec(hop_size);
+ if (!vec) { err = 1; goto failure; }
- aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
+ i = new_aubio_source(source_path, samplerate, hop_size);
+ if (!i) { err = 1; goto failure; }
if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
- aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
-
- if (!vec || !i || !o) { err = 1; goto failure; }
+ o = new_aubio_sink(sink_path, samplerate);
+ if (!o) { err = 1; goto failure; }
do {
aubio_source_do(i, vec, &read);