diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_plugin.lv2/test_plugin.c | 24 | ||||
-rw-r--r-- | test/test_util.c | 2 |
2 files changed, 16 insertions, 10 deletions
diff --git a/test/test_plugin.lv2/test_plugin.c b/test/test_plugin.lv2/test_plugin.c index 572443b..c8851d4 100644 --- a/test/test_plugin.lv2/test_plugin.c +++ b/test/test_plugin.lv2/test_plugin.c @@ -301,8 +301,10 @@ save(LV2_Handle instance, if (make_path) { char* spath = make_path->path(make_path->handle, "save"); FILE* sfile = fopen(spath, "w"); - fprintf(sfile, "save"); - fclose(sfile); + if (sfile) { + fprintf(sfile, "save"); + fclose(sfile); + } apath = map_path->abstract_path(map_path->handle, spath); store(callback_data, @@ -367,14 +369,16 @@ restore(LV2_Handle instance, } if (apath) { - char* path = map_path->absolute_path(map_path->handle, apath); - FILE* f = fopen(path, "r"); - char str[8]; - size_t n_read = fread(str, 1, sizeof(str), f); - fclose(f); - if (!!strncmp(str, "Hello\n", n_read)) { - fprintf( - stderr, "error: Restored bad file contents `%s' != `Hello'\n", str); + char* path = map_path->absolute_path(map_path->handle, apath); + FILE* f = fopen(path, "r"); + if (f) { + char str[8] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; + size_t n_read = fread(str, 1, 6, f); + fclose(f); + + if (!!strncmp(str, "Hello\n", n_read)) { + fprintf(stderr, "error: Restored bad file `%s' != `Hello'\n", str); + } } free_path->free_path(free_path->handle, path); } diff --git a/test/test_util.c b/test/test_util.c index 22edbbe..3063aa7 100644 --- a/test/test_util.c +++ b/test/test_util.c @@ -22,6 +22,8 @@ main(void) FILE* const fa = fopen(a_path, "w"); FILE* const fb = fopen(b_path, "w"); + assert(fa); + assert(fb); fprintf(fa, "AA\n"); fprintf(fb, "AB\n"); fclose(fb); |