summaryrefslogtreecommitdiffstats
path: root/src/progs
diff options
context:
space:
mode:
Diffstat (limited to 'src/progs')
-rw-r--r--src/progs/Makefile.am2
-rw-r--r--src/progs/demolition/Makefile.am13
-rw-r--r--src/progs/demolition/README7
-rw-r--r--src/progs/demolition/cmdline.c149
-rw-r--r--src/progs/demolition/cmdline.ggo7
-rw-r--r--src/progs/demolition/cmdline.h45
-rw-r--r--src/progs/demolition/demolition.cpp358
7 files changed, 1 insertions, 580 deletions
diff --git a/src/progs/Makefile.am b/src/progs/Makefile.am
index 836c924a..9fd842d2 100644
--- a/src/progs/Makefile.am
+++ b/src/progs/Makefile.am
@@ -1,6 +1,6 @@
AM_CXXFLAGS = -I$(top_srcdir)/src/common
-DIST_SUBDIRS = python supercollider demolition
+DIST_SUBDIRS = python supercollider ingen
SUBDIRS = ingen
diff --git a/src/progs/demolition/Makefile.am b/src/progs/demolition/Makefile.am
deleted file mode 100644
index fe2b20b6..00000000
--- a/src/progs/demolition/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-EXTRA_DIST = README
-
-om_demolition_CXXFLAGS = -I$(top_srcdir)/src/libs/client -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LXML2_CFLAGS) $(LOSC_CFLAGS) $(LSIGCPP_CFLAGS)
-om_demolition_LDADD = ../../libs/client/libingenclient.la $(LOSC_LIBS) $(LXML2_LIBS) $(LSIGCPP_LIBS)
-
-bin_PROGRAMS = om_demolition
-
-om_demolition_DEPENDENCIES = ../../libs/client/libingenclient.la
-
-om_demolition_SOURCES = \
- demolition.cpp \
- cmdline.h \
- cmdline.c
diff --git a/src/progs/demolition/README b/src/progs/demolition/README
deleted file mode 100644
index 536d3481..00000000
--- a/src/progs/demolition/README
+++ /dev/null
@@ -1,7 +0,0 @@
-This is a stress tester for the Om engine.
-
-It constantly sends random events (with a bias towards sane events) to the
-engine, to test for potential segfaults (or assertion failures, etc).
-
-It's not very clever at the moment, and doesn't hit all test cases. Renaming
-is also not supported yet.
diff --git a/src/progs/demolition/cmdline.c b/src/progs/demolition/cmdline.c
deleted file mode 100644
index 11fcd108..00000000
--- a/src/progs/demolition/cmdline.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- File autogenerated by gengetopt version 2.10
- generated with the following command:
- gengetopt
-
- The developers of gengetopt consider the fixed text that goes in all
- gengetopt output files to be in the public domain:
- we make no copyright claims on it.
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* If we use autoconf. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "getopt.h"
-
-#include "cmdline.h"
-
-void
-cmdline_parser_print_version (void)
-{
- printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
-}
-
-void
-cmdline_parser_print_help (void)
-{
- cmdline_parser_print_version ();
- printf("\n"
- "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
- printf(" -h --help Print help and exit\n");
- printf(" -V --version Print version and exit\n");
- printf(" -uSTRING --engine-url=STRING Om engine URL to connect to\n");
- printf(" -pINT --client-port=INT Client port to listen on\n");
-}
-
-
-static char *gengetopt_strdup (const char *s);
-
-/* gengetopt_strdup() */
-/* strdup.c replacement of strdup, which is not standard */
-char *
-gengetopt_strdup (const char *s)
-{
- char *result = (char*)malloc(strlen(s) + 1);
- if (result == (char*)0)
- return (char*)0;
- strcpy(result, s);
- return result;
-}
-
-int
-cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
-{
- int c; /* Character of the parsed option. */
- int missing_required_options = 0;
-
- args_info->help_given = 0 ;
- args_info->version_given = 0 ;
- args_info->engine_url_given = 0 ;
- args_info->client_port_given = 0 ;
-#define clear_args() { \
- args_info->engine_url_arg = NULL; \
-}
-
- clear_args();
-
- optarg = 0;
- optind = 1;
- opterr = 1;
- optopt = '?';
-
- while (1)
- {
- int option_index = 0;
- char *stop_char;
-
- static struct option long_options[] = {
- { "help", 0, NULL, 'h' },
- { "version", 0, NULL, 'V' },
- { "engine-url", 1, NULL, 'u' },
- { "client-port", 1, NULL, 'p' },
- { NULL, 0, NULL, 0 }
- };
-
- stop_char = 0;
- c = getopt_long (argc, argv, "hVu:p:", long_options, &option_index);
-
- if (c == -1) break; /* Exit from `while (1)' loop. */
-
- switch (c)
- {
- case 'h': /* Print help and exit. */
- clear_args ();
- cmdline_parser_print_help ();
- exit (EXIT_SUCCESS);
-
- case 'V': /* Print version and exit. */
- clear_args ();
- cmdline_parser_print_version ();
- exit (EXIT_SUCCESS);
-
- case 'u': /* Om engine URL to connect to. */
- if (args_info->engine_url_given)
- {
- fprintf (stderr, "%s: `--engine-url' (`-u') option given more than once\n", CMDLINE_PARSER_PACKAGE);
- clear_args ();
- exit (EXIT_FAILURE);
- }
- args_info->engine_url_given = 1;
- args_info->engine_url_arg = gengetopt_strdup (optarg);
- break;
-
- case 'p': /* Client port to listen on. */
- if (args_info->client_port_given)
- {
- fprintf (stderr, "%s: `--client-port' (`-p') option given more than once\n", CMDLINE_PARSER_PACKAGE);
- clear_args ();
- exit (EXIT_FAILURE);
- }
- args_info->client_port_given = 1;
- args_info->client_port_arg = strtol (optarg,&stop_char,0);
- break;
-
-
- case 0: /* Long option with no short option */
-
- case '?': /* Invalid option. */
- /* `getopt_long' already printed an error message. */
- exit (EXIT_FAILURE);
-
- default: /* bug: option not considered. */
- fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
- abort ();
- } /* switch */
- } /* while */
-
-
- if ( missing_required_options )
- exit (EXIT_FAILURE);
-
- return 0;
-}
diff --git a/src/progs/demolition/cmdline.ggo b/src/progs/demolition/cmdline.ggo
deleted file mode 100644
index 8fb68170..00000000
--- a/src/progs/demolition/cmdline.ggo
+++ /dev/null
@@ -1,7 +0,0 @@
-# Process this file with gengetopt -u to generate the necessary code (in cmdline.h, cmdline.c)
-
-package "om_demolition - A stress testing client for Om"
-
-option "engine-url" u "Om engine URL to connect to" string no
-option "client-port" p "Client port to listen on" int no
-
diff --git a/src/progs/demolition/cmdline.h b/src/progs/demolition/cmdline.h
deleted file mode 100644
index be56aafe..00000000
--- a/src/progs/demolition/cmdline.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* cmdline.h */
-
-/* File autogenerated by gengetopt version 2.10 */
-
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-/* If we use autoconf. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#ifndef CMDLINE_PARSER_PACKAGE
-#define CMDLINE_PARSER_PACKAGE "om_demolotion - A stress testing client for Om"
-#endif
-
-#ifndef CMDLINE_PARSER_VERSION
-#define CMDLINE_PARSER_VERSION VERSION
-#endif
-
-struct gengetopt_args_info
-{
- char * engine_url_arg; /* Om engine URL to connect to. */
- int client_port_arg; /* Client port to listen on. */
-
- int help_given ; /* Whether help was given. */
- int version_given ; /* Whether version was given. */
- int engine_url_given ; /* Whether engine-url was given. */
- int client_port_given ; /* Whether client-port was given. */
-
-} ;
-
-int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info);
-
-void cmdline_parser_print_help(void);
-void cmdline_parser_print_version(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* CMDLINE_H */
diff --git a/src/progs/demolition/demolition.cpp b/src/progs/demolition/demolition.cpp
deleted file mode 100644
index feba204a..00000000
--- a/src/progs/demolition/demolition.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen 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 GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "interface/ClientInterface.h"
-#include "interface/ClientKey.h"
-#include "OSCModelEngineInterface.h"
-#include "OSCClientReceiver.h"
-#include "SigClientInterface.h"
-#include "Store.h"
-#include "PatchLibrarian.h"
-#include "PluginModel.h"
-#include <raul/SharedPtr.h>
-#include <iostream>
-#include <unistd.h>
-#include <stdlib.h>
-#include "cmdline.h" // generated by gengetopt
-
-using std::cout;
-using std::endl;
-
-using namespace Ingen::Client;
-
-void do_something();
-
-string random_name();
-
-void create_patch();
-void destroy();
-void add_node();
-void connect();
-void disconnect();
-void disconnect_all();
-void set_port_value();
-void set_port_value_queued();
-void rename_object();
-
-
-// Yay globals!
-SharedPtr<OSCModelEngineInterface> engine;
-SharedPtr<Store> store;
-
-
-// OSC listening non-threaded signal emitter
-struct OSCSigEmitter : public OSCClientReceiver, public SigClientInterface {
-public:
- OSCSigEmitter(int listen_port)
- : Ingen::Shared::ClientInterface()
- , OSCClientReceiver(listen_port)
- , SigClientInterface()
- {
- }
-};
-
-
-int
-main(int argc, char** argv)
-{
- const char* engine_url = NULL;
- int client_port = 0;
-
- /* Parse command line options */
- gengetopt_args_info args_info;
- if (cmdline_parser (argc, argv, &args_info) != 0)
- return 1;
-
- if (args_info.engine_url_given) {
- engine_url = args_info.engine_url_arg;
- } else {
- cout << "[Main] No engine URL specified. Attempting to use osc.udp://localhost:16180" << endl;
- engine_url = "osc.udp://localhost:16180";
- }
-
- if (args_info.client_port_given)
- client_port = args_info.client_port_arg;
- else
- client_port = 0; // will choose a free port automatically
-
- engine = SharedPtr<ModelEngineInterface>(new OSCModelEngineInterface(engine_url));
- SharedPtr<SigClientInterface> emitter(new OSCSigEmitter(16182));
-
- store = SharedPtr<Store>(new Store(engine, emitter));
-
- engine->activate();
-
- /* Connect to engine */
- //engine->attach(engine_url);
- engine->register_client(ClientKey(), emitter);
-
- engine->load_plugins();
- engine->request_plugins();
-
- //int id = engine->get_next_request_id();
- engine->request_all_objects(/*id*/);
- //engine->set_wait_response_id(id);
- //engine->wait_for_response();
-
- // Disable DSP for stress testing
- engine->disable_patch("/");
-
- while (true) {
- do_something();
- usleep(10000);
- }
-
- sleep(2);
- engine->unregister_client(ClientKey());
- //engine->detach();
-
- return 0;
-}
-
-/** Does some random action
- */
-void
-do_something()
-{
- int action = rand() % 10;
-
- switch(action) {
- case 0:
- create_patch(); break;
- case 1:
- destroy(); break;
- case 2:
- add_node(); break;
- case 3:
- connect(); break;
- case 4:
- disconnect(); break;
- case 5:
- disconnect_all(); break;
- case 6:
- set_port_value(); break;
- case 7:
- set_port_value_queued(); break;
- case 8:
- rename_object(); break;
- default:
- break;
- }
-}
-
-
-string
-random_name()
-{
- int length = (rand()%10)+1;
- string name(length, '-');
-
- for (int i=0; i < length; ++i)
- name[i] = 'a' + rand()%26;
-
- return name;
-}
-
-
-Path
-random_object()
-{
- typedef map<Path, SharedPtr<ObjectModel> > ObjectMap;
-
- const ObjectMap& objects = store->objects();
-
- // Return a crap path every once in a while
- if (rand() % 30)
- return "/DEAD/BEEF";
-
- // "random" is a bit of a generous label...
- for (ObjectMap::const_iterator i = objects.begin(); i != objects.end(); ++i)
- if (rand() % objects.size())
- return i->second->path();
-
- return "/";
-}
-
-
-string
-random_plugin()
-{
- typedef map<string, SharedPtr<PluginModel> > PluginMap;
-
- const PluginMap& plugins = store->plugins();
-
- // Return a crap path every once in a while
- if (rand() % 30)
- return "DEAD:BEEF";
-
- // "random" is a bit of a generous label...
- for (PluginMap::const_iterator i = plugins.begin(); i != plugins.end(); ++i)
- if (rand() % plugins.size())
- return i->second->uri();
-
- return "DEAD:BEEF2";
-}
-
-
-void
-create_patch()
-{
- // Make the probability of this happening inversely proportionate to the number
- // of objects to keep the # in a sane range
- if (store->objects().size() > 0 && (rand() % store->objects().size()))
- return;
-
- bool subpatch = rand()%2;
- Path parent = "/";
- string name = random_name();
-
- if (subpatch)
- parent = random_object(); // very likely invalid parent error
-
- const Path path = parent.base() + name;
-
- cout << "Creating patch " << path << endl;
-
- engine->create_patch(path, (rand()%8)+1);
-
- // Spread them out a bit for easier monitoring with ingenuity
- engine->set_metadata(path, "ingenuity:module-x", 1600 + rand()%800 - 400);
- engine->set_metadata(path, "ingenuity:module-y", 1200 + rand()%700 - 350);
-}
-
-
-void
-destroy()
-{
- // Make the probability of this happening proportionate to the number
- // of patches to keep the # in a sane range
- if (store->objects().size() > 0 && !(rand() % store->objects().size()))
- return;
-
- engine->destroy(random_object());
-}
-
-
-void
-add_node()
-{
- const Path path = random_object().base() + random_name();
-
- cout << "Adding node " << path << endl;
- engine->create_node(path, random_plugin(), rand()%2);
-
- // Spread them out a bit for easier monitoring with ingenuity
- engine->set_metadata(path, "ingenuity:module-x", 1600 + rand()%800 - 400);
- engine->set_metadata(path, "ingenuity:module-y", 1200 + rand()%700 - 350);
-}
-
-
-void
-connect()
-{
- if (!(rand() % 10)) { // Attempt a connection between two nodes in the same patch
- PatchModel* parent = store->random_patch();
- NodeModel* n1 = store->random_node_in_patch(parent);
- NodeModel* n2 = store->random_node_in_patch(parent);
- PortModel* p1 = store->random_port_in_node(n1);
- PortModel* p2 = store->random_port_in_node(n2);
-
- if (p1 != NULL && p2 != NULL) {
- cout << "Connecting " << p1->path() << " -> " << p2->path() << endl;
- engine->connect(p1->path(), p2->path());
- }
-
- } else { // Attempt a connection between two truly random nodes
- PortModel* p1 = store->random_port();
- PortModel* p2 = store->random_port();
-
- if (p1 != NULL && p2 != NULL) {
- cout << "Connecting " << p1->path() << " -> " << p2->path() << endl;
- engine->connect(p1->path(), p2->path());
- }
- }
-}
-
-
-void
-disconnect()
-{
- PortModel* p1 = store->random_port();
- PortModel* p2 = store->random_port();
-
- if (p1 != NULL && p2 != NULL) {
- cout << "Disconnecting " << p1->path() << " -> " << p2->path() << endl;
- engine->disconnect(p1->path(), p2->path());
- }
-}
-
-
-void
-disconnect_all()
-{
- PortModel* p = store->random_port();
-
- if (p != NULL) {
- cout << "Disconnecting all from" << p->path() << endl;
- engine->disconnect_all(p->path());
- }
-}
-
-
-void
-set_port_value()
-{
- PortModel* pm = store->random_port();
- float val = (float)rand() / (float)RAND_MAX;
-
- if (pm != NULL) {
- cout << "Setting control for port " << pm->path() << " to " << val << endl;
- engine->set_port_value(pm->path(), val);
- }
-}
-
-
-void
-set_port_value_queued()
-{
- PortModel* pm = store->random_port();
- float val = (float)rand() / (float)RAND_MAX;
-
- if (pm != NULL) {
- cout << "Setting control (slow) for port " << pm->path() << " to " << val << endl;
- engine->set_port_value_queued(pm->path(), val);
- }
-}
-
-
-void
-rename_object()
-{
- // 1/6th chance of it being a patch
- /*int type = rand()%6;
-
- if (type == 0) {
- NodeModel* n = store->random_node();
- if (n != NULL)
- engine->rename(n->path(), random_name());
- } else {
- PatchModel* p = store->random_patch();
- if (p != NULL)
- engine->rename(p->path(), random_name());
- }*/
-}
-