57 lines
2.3 KiB
C
57 lines
2.3 KiB
C
|
|
#define _POSIX_C_SOURCE 200809L
|
||
|
|
#include "../../src/plugin/module_path.h"
|
||
|
|
#include <assert.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <string.h>
|
||
|
|
#include <sys/stat.h>
|
||
|
|
#include <unistd.h>
|
||
|
|
|
||
|
|
int main(void)
|
||
|
|
{
|
||
|
|
char root[] = "/tmp/xtc-module-path-XXXXXX", out[512] = "preserved", path[512];
|
||
|
|
char bundle[512], contents[512], binary[512];
|
||
|
|
FILE *file;
|
||
|
|
assert(mkdtemp(root));
|
||
|
|
assert(xtc_plugin_module_path(NULL,out) == XTC_ERR_INVALID_ARGUMENT);
|
||
|
|
assert(xtc_plugin_module_path("relative.vst3",out) == XTC_ERR_INVALID_ARGUMENT);
|
||
|
|
assert(xtc_plugin_module_path(root,out) == XTC_ERR_UNSUPPORTED);
|
||
|
|
assert(!strcmp(out,"preserved"));
|
||
|
|
snprintf(bundle,sizeof(bundle),"%s/Example.vst3",root);
|
||
|
|
assert(mkdir(bundle,0700) == 0);
|
||
|
|
#if defined(__x86_64__) || defined(__aarch64__) || defined(__i386__) || defined(__arm__)
|
||
|
|
assert(xtc_plugin_module_path(bundle,out) == XTC_ERR_NOT_FOUND);
|
||
|
|
#else
|
||
|
|
assert(xtc_plugin_module_path(bundle,out) == XTC_ERR_UNSUPPORTED);
|
||
|
|
assert(rmdir(bundle) == 0 && rmdir(root) == 0);
|
||
|
|
return 0;
|
||
|
|
#endif
|
||
|
|
assert(!strcmp(out,"preserved"));
|
||
|
|
snprintf(contents,sizeof(contents),"%s/Example.vst3/Contents",root);
|
||
|
|
assert(mkdir(contents,0700) == 0);
|
||
|
|
#if defined(__x86_64__)
|
||
|
|
#define ARCH "x86_64-linux"
|
||
|
|
#elif defined(__aarch64__)
|
||
|
|
#define ARCH "aarch64-linux"
|
||
|
|
#elif defined(__i386__)
|
||
|
|
#define ARCH "i386-linux"
|
||
|
|
#elif defined(__arm__)
|
||
|
|
#define ARCH "arm-linux"
|
||
|
|
#else
|
||
|
|
#define ARCH "unsupported"
|
||
|
|
#endif
|
||
|
|
snprintf(path,sizeof(path),"%s/Example.vst3/Contents/" ARCH,root);
|
||
|
|
assert(mkdir(path,0700) == 0);
|
||
|
|
snprintf(binary,sizeof(binary),"%s/Example.vst3/Contents/" ARCH "/Example.so",root);
|
||
|
|
file = fopen(binary,"wb"); assert(file); assert(fclose(file) == 0);
|
||
|
|
assert(xtc_plugin_module_path(bundle,out) == XTC_OK && !strcmp(out,binary));
|
||
|
|
assert(xtc_plugin_module_path(binary,out) == XTC_OK && !strcmp(out,binary));
|
||
|
|
assert(unlink(binary) == 0);
|
||
|
|
assert(mkfifo(binary,0600) == 0);
|
||
|
|
strcpy(out,"preserved");
|
||
|
|
assert(xtc_plugin_module_path(bundle,out) == XTC_ERR_UNSUPPORTED && !strcmp(out,"preserved"));
|
||
|
|
assert(unlink(binary) == 0);
|
||
|
|
assert(rmdir(path) == 0 && rmdir(contents) == 0 && rmdir(bundle) == 0 && rmdir(root) == 0);
|
||
|
|
puts("Plugin binary/bundle resolution and transactional errors passed.");
|
||
|
|
return 0;
|
||
|
|
}
|