summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_plugin.lv2/meson.build2
-rw-r--r--test/test_plugin.lv2/test_plugin.c50
2 files changed, 8 insertions, 44 deletions
diff --git a/test/test_plugin.lv2/meson.build b/test/test_plugin.lv2/meson.build
index 9b74245..e6c54cf 100644
--- a/test/test_plugin.lv2/meson.build
+++ b/test/test_plugin.lv2/meson.build
@@ -5,7 +5,7 @@ module = shared_module(
'test_plugin',
files('test_plugin.c'),
c_args: c_suppressions,
- dependencies: lv2_dep,
+ dependencies: [lv2_dep, zix_dep],
gnu_symbol_visibility: 'hidden',
name_prefix: '',
)
diff --git a/test/test_plugin.lv2/test_plugin.c b/test/test_plugin.lv2/test_plugin.c
index cb89136..124f64c 100644
--- a/test/test_plugin.lv2/test_plugin.c
+++ b/test/test_plugin.lv2/test_plugin.c
@@ -5,11 +5,8 @@
#include "lv2/core/lv2.h"
#include "lv2/state/state.h"
#include "lv2/urid/urid.h"
-
-#ifdef _WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-#endif
+#include "zix/filesystem.h"
+#include "zix/path.h"
#include <stdint.h>
#include <stdio.h>
@@ -37,35 +34,6 @@ typedef struct {
unsigned num_runs;
} Test;
-static char*
-temp_directory_path(void)
-{
-#ifdef _WIN32
- const DWORD len = GetTempPath(0, NULL);
- char* const buf = (char*)calloc(len, 1);
- if (GetTempPath(len, buf) == 0) {
- free(buf);
- return NULL;
- }
-
- return buf;
-#else
- const char* const tmpdir = getenv("TMPDIR");
- if (tmpdir) {
- const size_t tmpdir_len = strlen(tmpdir);
- char* const result = (char*)calloc(tmpdir_len + 1, 1);
-
- memcpy(result, tmpdir, tmpdir_len + 1);
- return result;
- }
-
- char* const result = (char*)calloc(6, 1);
-
- memcpy(result, "/tmp/", 6);
- return result;
-#endif
-}
-
static void
cleanup(LV2_Handle instance)
{
@@ -116,7 +84,7 @@ instantiate(const LV2_Descriptor* descriptor,
return NULL;
}
- test->tmp_dir_path = temp_directory_path();
+ test->tmp_dir_path = zix_temp_directory_path(NULL);
LV2_State_Make_Path* make_path = NULL;
@@ -284,14 +252,10 @@ save(LV2_Handle instance,
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
if (map_path) {
- const char* const file_name = "temp_file.txt";
- const size_t file_name_len = strlen(file_name);
- const size_t dir_path_len = strlen(plugin->tmp_dir_path);
- char* const tmp_file_path =
- (char*)calloc(dir_path_len + file_name_len + 1, 1);
-
- memcpy(tmp_file_path, plugin->tmp_dir_path, dir_path_len);
- memcpy(tmp_file_path + dir_path_len, file_name, file_name_len + 1);
+ const char* const file_name = "temp_file.txt";
+
+ char* const tmp_file_path =
+ zix_path_join(NULL, plugin->tmp_dir_path, file_name);
FILE* file = fopen(tmp_file_path, "w");
if (!file) {