shithub: mp3dec

Download patch

ref: 9de1e1ccc43c2f5f16a159c1fb47ee6d9747c69b
parent: 5ebaaccfd759a12e198dae924bd5c4b6b7563ecf
author: lieff <lieff@users.noreply.github.com>
date: Tue Feb 18 19:08:50 EST 2020

test: improve coverage

--- a/minimp3_test.c
+++ b/minimp3_test.c
@@ -70,13 +70,23 @@
     return data;
 }
 
+static int io_num, fail_io_num = -1;
+
 static size_t read_cb(void *buf, size_t size, void *user_data)
 {
+    /*printf("%d read_cb(%d)\n", io_num, (int)size);*/
+    if (fail_io_num == io_num)
+        return -1;
+    io_num++;
     return fread(buf, 1, size, (FILE*)user_data);
 }
 
 static int seek_cb(uint64_t position, void *user_data)
 {
+    /*printf("%d seek_cb(%d)\n", io_num, (int)position);*/
+    if (fail_io_num == io_num)
+        return -1;
+    io_num++;
     return fseek((FILE*)user_data, position, SEEK_SET);
 }
 
@@ -356,6 +366,7 @@
         case 'm': i++; if (i < argc) mode = atoi(argv[i]); break;
         case 's': i++; if (i < argc) position = atoi(argv[i]); break;
         case 'p': i++; if (i < argc) portion  = atoi(argv[i]); break;
+        case 'e': i++; if (i < argc) fail_io_num = atoi(argv[i]); break;
         default:
             printf("error: unrecognized option\n");
             return 1;
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -34,6 +34,12 @@
 ./minimp3 vectors/l3-nonstandard-id3v1.bit vectors/ILL2_mono.pcm
 ./minimp3 vectors/l3-nonstandard-id3v1.bit - temp.pcm
 rm temp.pcm
+./minimp3 -m 8 -e 0 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
+./minimp3 -m 8 -e 1 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
+./minimp3 -m 8 -e 2 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
+./minimp3 -m 8 -e 3 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
+./minimp3 -m 8 -e 4 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
+./minimp3 -m 8 -e 5 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
 set -e
 gcov minimp3_test.c