summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/connect_disconnect_node_node.ttl36
-rw-r--r--tests/connect_disconnect_node_patch.ttl36
-rw-r--r--tests/connect_disconnect_patch_patch.ttl36
-rw-r--r--tests/create_delete_node.ttl15
-rw-r--r--tests/create_delete_patch.ttl14
-rw-r--r--tests/create_delete_port.ttl15
-rw-r--r--tests/disconnect_all_node.ttl45
-rw-r--r--tests/get_engine.ttl7
-rw-r--r--tests/get_node.ttl15
-rw-r--r--tests/get_patch.ttl39
-rw-r--r--tests/get_plugins.ttl7
-rw-r--r--tests/get_port.ttl15
-rw-r--r--tests/ingen_test.cpp179
-rw-r--r--tests/move_node.ttl16
-rw-r--r--tests/move_port.ttl16
-rw-r--r--tests/put_audio_in.ttl10
-rw-r--r--tests/set_patch_port_value.ttl18
17 files changed, 499 insertions, 20 deletions
diff --git a/tests/connect_disconnect_node_node.ttl b/tests/connect_disconnect_node_node.ttl
new file mode 100644
index 00000000..0f84dcaa
--- /dev/null
+++ b/tests/connect_disconnect_node_node.ttl
@@ -0,0 +1,36 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/node1> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg1>
+ a patch:Put ;
+ patch:subject <path:/node2> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg2>
+ a patch:Put ;
+ patch:subject <path:/> ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/node1/left_out> ;
+ ingen:head <path:/node2/left_in>
+ ] .
+
+<msg3>
+ a patch:Delete ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/node1/left_out> ;
+ ingen:head <path:/node2/left_in>
+ ] .
diff --git a/tests/connect_disconnect_node_patch.ttl b/tests/connect_disconnect_node_patch.ttl
new file mode 100644
index 00000000..2f7fd0df
--- /dev/null
+++ b/tests/connect_disconnect_node_patch.ttl
@@ -0,0 +1,36 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/node> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg1>
+ a patch:Put ;
+ patch:subject <path:/out> ;
+ patch:body [
+ a lv2:OutputPort ,
+ lv2:AudioPort
+ ] .
+
+<msg2>
+ a patch:Put ;
+ patch:subject <path:/> ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/node/left_out> ;
+ ingen:head <path:/out>
+ ] .
+
+<msg3>
+ a patch:Delete ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/node/left_out> ;
+ ingen:head <path:/out>
+ ] .
diff --git a/tests/connect_disconnect_patch_patch.ttl b/tests/connect_disconnect_patch_patch.ttl
new file mode 100644
index 00000000..ba31a8ec
--- /dev/null
+++ b/tests/connect_disconnect_patch_patch.ttl
@@ -0,0 +1,36 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/in> ;
+ patch:body [
+ a lv2:InputPort ,
+ lv2:AudioPort
+ ] .
+
+<msg1>
+ a patch:Put ;
+ patch:subject <path:/out> ;
+ patch:body [
+ a lv2:InputPort ,
+ lv2:AudioPort
+ ] .
+
+<msg2>
+ a patch:Put ;
+ patch:subject <path:/> ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/in> ;
+ ingen:head <path:/out>
+ ] .
+
+<msg3>
+ a patch:Delete ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/in> ;
+ ingen:head <path:/out>
+ ] .
diff --git a/tests/create_delete_node.ttl b/tests/create_delete_node.ttl
new file mode 100644
index 00000000..3494abe1
--- /dev/null
+++ b/tests/create_delete_node.ttl
@@ -0,0 +1,15 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/node> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg1>
+ a patch:Delete ;
+ patch:subject <path:/node> .
diff --git a/tests/create_delete_patch.ttl b/tests/create_delete_patch.ttl
new file mode 100644
index 00000000..8dc5e09a
--- /dev/null
+++ b/tests/create_delete_patch.ttl
@@ -0,0 +1,14 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/sub> ;
+ patch:body [
+ a ingen:Patch ;
+ ] .
+
+<msg1>
+ a patch:Delete ;
+ patch:subject <path:/sub> .
diff --git a/tests/create_delete_port.ttl b/tests/create_delete_port.ttl
new file mode 100644
index 00000000..6a92f0cc
--- /dev/null
+++ b/tests/create_delete_port.ttl
@@ -0,0 +1,15 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/in> ;
+ patch:body [
+ a lv2:InputPort ,
+ lv2:AudioPort
+ ] .
+
+<msg1>
+ a patch:Delete ;
+ patch:subject <path:/in> .
diff --git a/tests/disconnect_all_node.ttl b/tests/disconnect_all_node.ttl
new file mode 100644
index 00000000..b4fc2747
--- /dev/null
+++ b/tests/disconnect_all_node.ttl
@@ -0,0 +1,45 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/node1> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg1>
+ a patch:Put ;
+ patch:subject <path:/node2> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg2>
+ a patch:Put ;
+ patch:subject <path:/> ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/node1/left_out> ;
+ ingen:head <path:/node2/left_in>
+ ] .
+
+<msg3>
+ a patch:Put ;
+ patch:subject <path:/> ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/node1/right_out> ;
+ ingen:head <path:/node2/right_in>
+ ] .
+
+<msg4>
+ a patch:Delete ;
+ patch:subject <path:/> ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:incidentTo <path:/node1>
+ ] .
diff --git a/tests/get_engine.ttl b/tests/get_engine.ttl
new file mode 100644
index 00000000..f1be242c
--- /dev/null
+++ b/tests/get_engine.ttl
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Get ;
+ patch:subject <ingen:engine> .
diff --git a/tests/get_node.ttl b/tests/get_node.ttl
new file mode 100644
index 00000000..10ac10fb
--- /dev/null
+++ b/tests/get_node.ttl
@@ -0,0 +1,15 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/node> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg1>
+ a patch:Get ;
+ patch:subject <path:/node> .
diff --git a/tests/get_patch.ttl b/tests/get_patch.ttl
new file mode 100644
index 00000000..843316dc
--- /dev/null
+++ b/tests/get_patch.ttl
@@ -0,0 +1,39 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/sub> ;
+ patch:body [
+ a ingen:Patch
+ ] .
+
+<msg1>
+ a patch:Put ;
+ patch:subject <path:/sub/node1> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg2>
+ a patch:Put ;
+ patch:subject <path:/sub/node2> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Combo>
+ ] .
+
+<msg3>
+ a patch:Put ;
+ patch:subject <path:/> ;
+ patch:body [
+ a ingen:Edge ;
+ ingen:tail <path:/sub/node1/left_out> ;
+ ingen:head <path:/sub/node2/left_in>
+ ] .
+
+<msg4>
+ a patch:Get ;
+ patch:subject <path:/> .
diff --git a/tests/get_plugins.ttl b/tests/get_plugins.ttl
new file mode 100644
index 00000000..37b65127
--- /dev/null
+++ b/tests/get_plugins.ttl
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Get ;
+ patch:subject <ingen:plugins> .
diff --git a/tests/get_port.ttl b/tests/get_port.ttl
new file mode 100644
index 00000000..3e522af8
--- /dev/null
+++ b/tests/get_port.ttl
@@ -0,0 +1,15 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/in> ;
+ patch:body [
+ a lv2:InputPort ,
+ lv2:AudioPort
+ ] .
+
+<msg1>
+ a patch:Get ;
+ patch:subject <path:/in> .
diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp
index 0a882023..ec41cb2c 100644
--- a/tests/ingen_test.cpp
+++ b/tests/ingen_test.cpp
@@ -35,13 +35,17 @@
#include "serd/serd.h"
#include "sord/sordmm.hpp"
+#include "sratom/sratom.h"
#include "ingen_config.h"
#include "ingen/EngineBase.hpp"
#include "ingen/Interface.hpp"
#include "ingen/serialisation/Parser.hpp"
+#include "ingen/shared/AtomReader.hpp"
+#include "ingen/shared/AtomWriter.hpp"
#include "ingen/shared/Configuration.hpp"
+#include "ingen/shared/URIMap.hpp"
#include "ingen/shared/World.hpp"
#include "ingen/shared/runtime_paths.hpp"
#include "ingen/client/ThreadedSigClientInterface.hpp"
@@ -52,7 +56,70 @@
using namespace std;
using namespace Ingen;
-Ingen::Shared::World* world = NULL;
+Shared::World* world = NULL;
+
+/*
+class TestClient : public Shared::AtomSink {
+ void write(const LV2_Atom* msg) {
+ }
+};
+*/
+class TestClient : public Interface
+{
+public:
+ TestClient() {}
+ ~TestClient() {}
+
+ Raul::URI uri() const { return "http://drobilla.net/ns/ingen#AtomWriter"; }
+
+ void bundle_begin() {}
+
+ void bundle_end() {}
+
+ void put(const Raul::URI& uri,
+ const Resource::Properties& properties,
+ Resource::Graph ctx = Resource::DEFAULT) {}
+
+ void delta(const Raul::URI& uri,
+ const Resource::Properties& remove,
+ const Resource::Properties& add) {}
+
+ void move(const Raul::Path& old_path,
+ const Raul::Path& new_path) {}
+
+ void del(const Raul::URI& uri) {}
+
+ void connect(const Raul::Path& tail,
+ const Raul::Path& head) {}
+
+ void disconnect(const Raul::Path& tail,
+ const Raul::Path& head) {}
+
+ void disconnect_all(const Raul::Path& parent_patch_path,
+ const Raul::Path& path) {}
+
+ void set_property(const Raul::URI& subject,
+ const Raul::URI& predicate,
+ const Raul::Atom& value) {}
+
+ void set_response_id(int32_t id) {}
+
+ void get(const Raul::URI& uri) {}
+
+ void response(int32_t id, Status status) {
+ if (status) {
+ Raul::error(Raul::fmt("error on message %1%: %2%\n")
+ % id % ingen_status_string(status));
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ void error(const std::string& msg) {
+ Raul::error(Raul::fmt("error: %1%\n") % msg);
+ exit(EXIT_FAILURE);
+ }
+};
+
void
ingen_try(bool cond, const char* msg)
@@ -70,46 +137,118 @@ main(int argc, char** argv)
Glib::thread_init();
Shared::set_bundle_path_from_code((void*)&main);
+ if (argc != 3) {
+ cerr << "Usage: ingen_test START_PATCH COMMANDS_FILE" << endl;
+ return EXIT_FAILURE;
+ }
+
// Create world
try {
- world = new Ingen::Shared::World(argc, argv, NULL, NULL);
- if (argc <= 1) {
- world->conf().print_usage("ingen", cout);
- return EXIT_FAILURE;
- } else if (world->conf().option("help").get_bool()) {
- world->conf().print_usage("ingen", cout);
- return EXIT_SUCCESS;
- }
+ world = new Shared::World(argc, argv, NULL, NULL);
} catch (std::exception& e) {
cout << "ingen: " << e.what() << endl;
return EXIT_FAILURE;
}
- // Run engine
- //SharedPtr<Interface> engine_interface;
+ // Load modules
ingen_try(world->load_module("server_profiled"),
"Unable to load server module");
- //ingen_try(world->load_module("client"),
- // "Unable to load client module");
-
- ingen_try(world->engine(),
- "Unable to create engine");
-
ingen_try(world->load_module("serialisation_profiled"),
"Unable to load serialisation module");
+ // Initialise engine
+ ingen_try(world->engine(),
+ "Unable to create engine");
world->engine()->init(48000.0, 4096);
world->engine()->activate();
+ // Load patch
world->parser()->parse_file(world, world->interface().get(), argv[1]);
- while (world->engine()->run(4096)) {
+ while (world->engine()->pending_events()) {
+ world->engine()->run(4096);
world->engine()->main_iteration();
+ g_usleep(1000);
+ }
+
+ // Read commands
+
+ SerdChunk out = { NULL, 0 };
+ LV2_URID_Map* map = &world->uri_map().urid_map_feature()->urid_map;
+ Sratom* sratom = sratom_new(map);
+
+ sratom_set_object_mode(sratom, SRATOM_OBJECT_MODE_BLANK_SUBJECT);
+
+ LV2_Atom_Forge forge;
+ lv2_atom_forge_init(&forge, map);
+ lv2_atom_forge_set_sink(&forge, sratom_forge_sink, sratom_forge_deref, &out);
+
+ const std::string cmds_file_path = argv[2];
+
+ // AtomReader to read commands from a file and send them to engine
+ Shared::AtomReader atom_reader(
+ world->uri_map(), world->uris(), world->forge(), *world->interface().get());
+
+ // AtomWriter to serialise responses from the engine
+ /*
+ TestClient client;
+ SharedPtr<Shared::AtomWriter> atom_writer(
+ new Shared::AtomWriter(world->uri_map(), world->uris(), client));
+ */
+ SharedPtr<Interface> client(new TestClient());
+
+ world->interface()->set_respondee(client);
+ world->engine()->register_client(
+ "http://drobilla.net/ns/ingen#AtomWriter",
+ client);
+
+ SerdURI cmds_base;
+ const SerdNode cmds_file_uri = serd_node_new_file_uri(
+ (const uint8_t*)cmds_file_path.c_str(),
+ NULL, &cmds_base, false);
+ Sord::Model* cmds = new Sord::Model(*world->rdf_world(),
+ (const char*)cmds_file_uri.buf);
+ SerdEnv* env = serd_env_new(&cmds_file_uri);
+ cmds->load_file(env, SERD_TURTLE, cmds_file_path);
+ Sord::Node nil;
+ for (int i = 0; ; ++i) {
+ std::string subject_str = (Raul::fmt("msg%1%") % i).str();
+ Sord::URI subject(*world->rdf_world(), subject_str,
+ (const char*)cmds_file_uri.buf);
+ Sord::Iter iter = cmds->find(subject, nil, nil);
+ if (iter.end()) {
+ break;
+ }
+
+ out.len = 0;
+ sratom_read(sratom, &forge, world->rdf_world()->c_obj(),
+ cmds->c_obj(), subject.c_obj());
+
+ /*
+ cerr << "READ " << out.len << " BYTES" << endl;
+ LV2_Atom* atom = (LV2_Atom*)out.buf;
+ cerr << sratom_to_turtle(
+ sratom,
+ &world->uri_map().urid_unmap_feature()->urid_unmap,
+ (const char*)cmds_file_uri.buf,
+ NULL, NULL, atom->type, atom->size, LV2_ATOM_BODY(atom)) << endl;
+ */
+
+ if (!atom_reader.write((LV2_Atom*)out.buf)) {
+ return EXIT_FAILURE;
+ }
+
+ while (world->engine()->pending_events()) {
+ world->engine()->run(4096);
+ world->engine()->main_iteration();
+ g_usleep(1000);
+ }
}
+ serd_env_free(env);
+ delete cmds;
// Shut down
- if (world->engine())
- world->engine()->deactivate();
+ world->engine()->deactivate();
delete world;
return 0;
diff --git a/tests/move_node.ttl b/tests/move_node.ttl
new file mode 100644
index 00000000..f24c14c2
--- /dev/null
+++ b/tests/move_node.ttl
@@ -0,0 +1,16 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/node> ;
+ patch:body [
+ a ingen:Node ;
+ ingen:prototype <http://drobilla.net/plugins/mda/Shepard>
+ ] .
+
+<msg1>
+ a patch:Move ;
+ patch:subject <path:/node> ;
+ patch:destination <path:/tone> .
diff --git a/tests/move_port.ttl b/tests/move_port.ttl
new file mode 100644
index 00000000..b6c9ab83
--- /dev/null
+++ b/tests/move_port.ttl
@@ -0,0 +1,16 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/in> ;
+ patch:body [
+ a lv2:InputPort ,
+ lv2:AudioPort
+ ] .
+
+<msg1>
+ a patch:Move ;
+ patch:subject <path:/in> ;
+ patch:destination <path:/input> .
diff --git a/tests/put_audio_in.ttl b/tests/put_audio_in.ttl
new file mode 100644
index 00000000..2f724ab9
--- /dev/null
+++ b/tests/put_audio_in.ttl
@@ -0,0 +1,10 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/in> ;
+ patch:body [
+ a lv2:InputPort ,
+ lv2:AudioPort
+ ] .
diff --git a/tests/set_patch_port_value.ttl b/tests/set_patch_port_value.ttl
new file mode 100644
index 00000000..226d4811
--- /dev/null
+++ b/tests/set_patch_port_value.ttl
@@ -0,0 +1,18 @@
+@prefix ingen: <http://drobilla.net/ns/ingen#> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+
+<msg0>
+ a patch:Put ;
+ patch:subject <path:/in> ;
+ patch:body [
+ a lv2:InputPort ,
+ lv2:ControlPort
+ ] .
+
+<msg1>
+ a patch:Set ;
+ patch:subject <path:/in> ;
+ patch:body [
+ ingen:value 0.5
+ ] .