env.Default (libraries)
+#
+## Run 'scons dynamic' to compile dynamic libraries
+#
+dynamic_list = []
+dynamic = os.path.join (current_directory, "dynamic")
+# Find SConstruct files:
+dynamics=[os.path.join(r,f) for r,d,fs in os.walk(dynamic) for f in fs if f.endswith('SConstruct')]
+for dynamic in dynamics:
+ ss = str (dynamic)
+ bn_ss = os.path.basename(ss)
+ if (bn_ss == "SConstruct"):
+ dynamic_program = SConscript (ss, exports='env')
+ if dynamic_program:
+ dynamic_list.extend (dynamic_program)
+ print dynamic_program [0]
+
+#Depends (dynamic_list, compile_library)
+
+# In order to remove dynamics objects with 'scons -c' we need to default them at built ('scons') procedure:
+env.Default (dynamic_list)
+#env.Alias ('dynamic', dynamic_list)
+
+
#
## Run 'scons example' to compile examples
#
env.Default (example_list)
#env.Alias ('example', example_list)
-
#
# Run 'scons test' to compile unit-tests
#
# See http://www.scons.org/wiki/InstallTargets and http://www.scons.org/doc/production/HTML/scons-user/c2938.html
install_include = env.Install (target_usr_local_include, Glob("include/anna/*"))
install_lib = env.Install (target_usr_local_lib, Glob("source/*/" + variant + "/*.a"))
+install_dynlib = env.Install (target_usr_local_lib, Glob("dynamic/launcher/default/" + variant + "/*.so"))
install_example = env.Install (target_opt_bin, Glob("example/*/*/" + variant + "/example_*"))
postinstall_example = env.Command('./example/postinstall.out', None, './example/postinstall.sh')
if test_unit_result:
Depends (install_include, test_unit_result)
Depends (install_lib, test_unit_result)
+ Depends (install_dynlib, test_unit_result)
Depends (install_example, test_unit_result)
ii = env.Alias('install-include', [target_usr_local_include])
il = env.Alias('install-lib', [target_usr_local_lib])
+idl = env.Alias('install-dynlib', [target_usr_local_lib])
iil = env.Alias('install-include-and-lib', [target_usr_local_include, target_usr_local_lib])
iex = env.Alias('install-example', [target_opt_bin, postinstall_example])
env.Alias('install', [iil, iex])
--- /dev/null
+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+// Standard
+#include <iostream>
+#include <string>
+
+
+// Local
+#include "Procedure.hpp"
+
+void Procedure::execute(const std::string &args, std::string &response) throw() {
+ response = "Empty default implementation. Make dynamic library and reimplement this method.";
+ if (args != "" ) {
+ response += " Provided argument(s) ignored: ";
+ response += args;
+ }
+}
+
--- /dev/null
+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef dynamic_launcher_default_hpp
+#define dynamic_launcher_default_hpp
+
+// Project
+#include <anna/comm/comm.hpp>
+
+
+
+class Procedure {
+ anna::comm::Application *a_app;
+
+ public:
+ Procedure(anna::comm::Application *app) : a_app(app) {;}
+
+ virtual void execute(const std::string &args, std::string &response) throw();
+};
+
+#endif
--- /dev/null
+Import ('env')
+
+sources = Glob('*.cpp')
+
+result = env.SharedLibrary ('anna_dynamicLauncherProcedure', sources);
+
+Return ('result')
+
--- /dev/null
+release = ARGUMENTS.get ('release', 0)
+
+Import ('env')
+
+# See http://stackoverflow.com/questions/4693826/scons-binary-directory
+if int(release):
+ result = SConscript ('SConscript', exports='env', variant_dir="release", duplicate=0)
+else:
+ result = SConscript ('SConscript', exports='env', variant_dir="debug", duplicate=0)
+
+Return ('result')
+
--- /dev/null
+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+// Standard
+#include <iostream>
+#include <string>
+
+
+// Local
+#include "Procedure.hpp"
+
+void Procedure::execute(const std::string &args, std::string &response) throw() {
+ response = "00001 Empty default implementation. Make dynamic library and reimplement this method.";
+ if (args != "" ) {
+ response += " Provided argument(s) ignored: ";
+ response += args;
+ }
+}
+
--- /dev/null
+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef dynamic_launcher_gx_00001_hpp
+#define dynamic_launcher_gx_00001_hpp
+
+// Project
+#include <anna/comm/comm.hpp>
+
+
+
+class Procedure {
+ anna::comm::Application *a_app;
+
+ public:
+ Procedure(anna::comm::Application *app) : a_app(app) {;}
+
+ virtual void execute(const std::string &args, std::string &response) throw();
+};
+
+#endif
--- /dev/null
+Import ('env')
+
+sources = Glob('*.cpp')
+
+result = env.SharedLibrary ('anna_dynamicLauncherProcedure', sources);
+
+Return ('result')
+
--- /dev/null
+release = ARGUMENTS.get ('release', 0)
+
+Import ('env')
+
+# See http://stackoverflow.com/questions/4693826/scons-binary-directory
+if int(release):
+ result = SConscript ('SConscript', exports='env', variant_dir="release", duplicate=0)
+else:
+ result = SConscript ('SConscript', exports='env', variant_dir="debug", duplicate=0)
+
+Return ('result')
+
STACKMGMT_EXEC_installed=/opt/bin/anna/example_diameter_stackManagement
STACKMGMT_EXECS=( $STACKMGMT_EXEC_installed ../stackManagement/release/example_diameter_stackManagement ../stackManagement/debug/example_diameter_stackManagement )
+# Dynamic library:
+DYNLIB_installed=/usr/local/lib/libanna_dynamicLauncherProcedure.so
+DYNLIBS=( $DYNLIB_installed ../../../dynamic/launcher/default/release/libanna_dynamicLauncherProcedure.so ../../../dynamic/launcher/default/debug/libanna_dynamicLauncherProcedure.so )
+
#############
# FUNCTIONS #
#############
0> launcher.trace
rm -f counters/* test-reports/*
# Execution line:
+export LD_LIBRARY_PATH=\$PWD
./\$EXE --services services.xml --cntDir counters --tmDir test-reports $other &
echo \$! > .pid
EOF
echo " (--help or -h for more info)"
echo
echo "Basic checkings ..."
+
# Launcher executable:
available=
for EXEC in ${EXECS[@]}; do
echo "not found"
done
[ -z "$available" ] && _exit "Anna Diameter Launcher (ADML) is not installed neither linked. See README.md (Install section)."
+
# Dictionary creation:
available=
for STACKMGMT_EXEC in ${STACKMGMT_EXECS[@]}; do
[ -z "$available" ] && _exit "Anna Diameter Stack Management Tool is not installed neither linked. See README.md (Install section)."
STACKMGMT_EXEC=`readlink -f $STACKMGMT_EXEC`
+# Dynamic library:
+available=
+for DYNLIB in ${DYNLIBS[@]}; do
+ echo -n "Looking dynamic library at '$DYNLIB' ... "
+ [ -x $DYNLIB ] && { available=yes ; echo "available !" ; break ; }
+ echo "not found"
+done
+[ -z "$available" ] && _exit "Anna Diameter Launcher Dynamic Procedure Library (ADML) is not installed neither linked. See README.md (Install section)."
+
[ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR)."
echo
mkdir -p $DPATH/DTDs
mkdir -p $DPATH/counters
mkdir -p $DPATH/test-reports
+cp $DYNLIB $DPATH
+
[ "$option" = "b" ] && mkdir -p $DPATH/services
# ADML executable:
#include <anna/time/functions.hpp>
#include <anna/diameter.comm/ApplicationMessageOamModule.hpp>
#include <anna/xml/xml.hpp>
+#include <Procedure.hpp>
// Process
#include <Launcher.hpp>
result += "\n test|report-hex[|[yes]|no] Reports could include the diameter messages in hexadecimal format. Disabled by default.";
result += "\n";
result += "\n";
+ result += "\n------------------------------------------------------------------------------------- Dynamic procedure";
+ result += "\n";
+ result += "\ndynamic[|args] This launch an internal operation implemented in 'Procedure' class.";
+ result += "\n Its default implementation does nothing, but you could create a dynamic";
+ result += "\n library 'libanna_launcherDynamic.so' and replace the one in this project.";
+ result += "\n One interesting application consists in the use of the diameter API and";
+ result += "\n event operation to create a set of libraries as the testing framework.";
+ result += "\n To execute each test case, the ADML process would be executed with a";
+ result += "\n specific library path. But the main use would be the stress programming";
+ result += "\n to achieve a great amount of cloned (even mixed) tests without using";
+ result += "\n the management operation interface by mean http or signals: a single";
+ result += "\n call to 'dynamic' would be enough to start a cascade of internally";
+ result += "\n implemented operations.";
+ result += "\n This operation accepts a generic string argument (piped or not, as you";
+ result += "\n desire and depending on your procedure implementation).";
+ result += "\n";
+ result += "\n This operation requires advanced programming and knowlegde of ANNA Diameter";
+ result += "\n stack and testing framework, to take advantage of all the possibilities.";
+ result += "\n";
+ result += "\n";
+ result += "\n";
result += "\nUSING OPERATIONS INTERFACE";
result += "\n--------------------------";
result += "\n";
///////////////////////////////////////////////////////////////////
// Simple operations without arguments:
+ // Dynamic operation:
+ if(operation.find("dynamic") == 0) {
+ Procedure p(this);
+ int op_size = operation.size();
+ std::string args = ((operation.find("dynamic|") == 0) && (op_size > 8)) ? operation.substr(8) : "";
+ if (args == "" && op_size != 7)
+ throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+ p.execute(args, response_content);
+ return;
+ }
+
// Help:
if(operation == "help") {
response_content = help();
pwd = str(Dir ('.').abspath);
anna_libpaths = []
anna_libs = []
+
modules = [ 'core', 'io', 'xml', 'app', 'http', 'comm', 'timex', 'http', 'statistics', 'time', 'diameter', 'diameter_comm' ];
for module in modules:
anna_libs.append ("anna_" + module)
module = module.replace("_", ".")
+ kk = pwd.replace (pPath, ("source/" + module + "/"))
anna_libpaths.append (pwd.replace (pPath, ("source/" + module + "/")))
+# dynamic lib:
+anna_libs.append ("anna_dynamicLauncherProcedure")
+dynamic_libpath = os.path.join (pwd, "../../../../dynamic/launcher/default/debug")
+anna_libpaths.append (dynamic_libpath)
+
anna_rlibs = list(anna_libs)
anna_rlibs.reverse()
localEnv.Append(LIBPATH = anna_libpaths)
+
# Linking #################################################################
# Process includes (avoid mandatory using of quoted includes and ../ paths from testing directory):
current_directory = Dir ('.').abspath
testing_include = os.path.join (current_directory, "testing")
-localEnv.Append (CPPPATH = [current_directory, testing_include])
+dynamic_include = os.path.join (pwd, "../../../../dynamic/launcher/default/")
+localEnv.Append (CPPPATH = [current_directory, testing_include, dynamic_include])
result = localEnv.Program (pName, Glob ('*.cpp') + Glob ('testing/*.cpp'))
0> launcher.trace
rm -f counters/* test-reports/*
# Execution line:
+export LD_LIBRARY_PATH=\$PWD
./$@ --services services.xml &
echo \$! > .pid
EOF