aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-04-04 19:17:49 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-04-04 19:17:49 +0200
commitc5da4df6b414b29522b0ac206fb19efa60d80f66 (patch)
treeb29cc3ac82b5f5a7bda2596f577ea0835b2d8020
parent9d80261ce9cc8a3d42ca573d68af15631d867eed (diff)
downloadprops.lv2-c5da4df6b414b29522b0ac206fb19efa60d80f66.zip
props.lv2-c5da4df6b414b29522b0ac206fb19efa60d80f66.tar.gz
props.lv2-c5da4df6b414b29522b0ac206fb19efa60d80f66.tar.bz2
props.lv2-c5da4df6b414b29522b0ac206fb19efa60d80f66.tar.xz
test: add prototype unit test template.
-rw-r--r--VERSION2
-rw-r--r--meson.build26
-rw-r--r--test/props_test.c126
3 files changed, 151 insertions, 3 deletions
diff --git a/VERSION b/VERSION
index 8b06068..841597f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.117
+0.1.119
diff --git a/meson.build b/meson.build
index 176a8bb..28516ac 100644
--- a/meson.build
+++ b/meson.build
@@ -11,6 +11,8 @@ conf_data = configuration_data()
cc = meson.get_compiler('c')
cp = find_program('cp')
+lv2_validate = find_program('lv2_validate', native : true, required : false)
+lv2lint = find_program('lv2lint', required : false)
clone = [cp, '@INPUT@', '@OUTPUT@']
m_dep = cc.find_library('m')
@@ -41,11 +43,12 @@ conf_data.set('MICRO_VERSION', version[2])
suffix = mod.full_path().strip().split('.')[-1]
conf_data.set('MODULE_SUFFIX', '.' + suffix)
-configure_file(input : join_paths('test', 'manifest.ttl.in'), output : 'manifest.ttl',
+manifest_ttl = configure_file(
+ input : join_paths('test', 'manifest.ttl.in'), output : 'manifest.ttl',
configuration : conf_data,
install : true,
install_dir : inst_dir)
-custom_target('props_ttl',
+dsp_ttl = custom_target('props_ttl',
input : join_paths('test', 'props.ttl'),
output : 'props.ttl',
command : clone,
@@ -57,3 +60,22 @@ custom_target('chunk_bin',
command : clone,
install : true,
install_dir : inst_dir)
+
+props_test = executable('props_test',
+ join_paths('test', 'props_test.c'),
+ c_args : c_args,
+ install : false)
+
+test('Test', props_test,
+ timeout : 240)
+
+if lv2_validate.found()
+ test('LV2 validate', lv2_validate,
+ args : [manifest_ttl, dsp_ttl])
+endif
+
+if lv2lint.found()
+ test('LV2 lint', lv2lint,
+ args : ['-Ewarn',
+ 'http://open-music-kontrollers.ch/lv2/props#test'])
+endif
diff --git a/test/props_test.c b/test/props_test.c
new file mode 100644
index 0000000..3403a3b
--- /dev/null
+++ b/test/props_test.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the Artistic License 2.0 as published by
+ * The Perl Foundation.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Artistic License 2.0 for more details.
+ *
+ * You should have received a copy of the Artistic License 2.0
+ * along the source as a COPYING file. If not, obtain it from
+ * http://www.perlfoundation.org/artistic_license_2_0.
+ */
+
+
+#include <assert.h>
+
+#include <props.h>
+
+#define MAX_URIDS 512
+
+typedef struct _urid_t urid_t;
+typedef void (*test_t)(props_t *props);
+
+struct _urid_t {
+ LV2_URID urid;
+ char *uri;
+};
+
+static urid_t urids [MAX_URIDS];
+static LV2_URID urid;
+
+static LV2_URID
+_map(LV2_URID_Map_Handle instance __attribute__((unused)), const char *uri)
+{
+ urid_t *itm;
+ for(itm=urids; itm->urid; itm++)
+ {
+ if(!strcmp(itm->uri, uri))
+ return itm->urid;
+ }
+
+ assert(urid + 1 < MAX_URIDS);
+
+ // create new
+ itm->urid = ++urid;
+ itm->uri = strdup(uri);
+
+ return itm->urid;
+}
+
+static LV2_URID_Map map = {
+ .handle = NULL,
+ .map = _map
+};
+
+static void
+_test_1(props_t *props)
+{
+ assert(props);
+ //FIXME
+}
+
+static void
+_test_2(props_t *props)
+{
+ assert(props);
+ //FIXME
+}
+
+static const test_t tests [] = {
+ _test_1,
+ _test_2,
+ NULL
+};
+
+#define PROPS_PREFIX "http://open-music-kontrollers.ch/lv2/props#"
+#define PROPS_TEST_URI PROPS_PREFIX"test"
+
+#define MAX_NPROPS 1
+
+typedef struct _plugstate_t plugstate_t;
+
+struct _plugstate_t {
+ uint32_t dummy;
+};
+
+static const props_def_t defs [MAX_NPROPS] = {
+ {
+ .property = PROPS_PREFIX"dummy",
+ .offset = offsetof(plugstate_t, dummy),
+ .type = LV2_ATOM__Int
+ }
+};
+
+int
+main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
+{
+ static props_t props;
+ static plugstate_t state;
+ static plugstate_t stash;
+
+ for(const test_t *test = tests; *test; test++)
+ {
+ memset(&props, 0, sizeof(props));
+ memset(&state, 0, sizeof(state));
+ memset(&stash, 0, sizeof(stash));
+
+ assert(props_init(&props, PROPS_PREFIX"subj", defs, MAX_NPROPS,
+ &state, &stash, &map, NULL) == 1);
+
+ (*test)(&props);
+ }
+
+ for(unsigned i=0; i<urid; i++)
+ {
+ urid_t *itm = &urids[i];
+
+ free(itm->uri);
+ }
+
+ return 0;
+}