diff --git a/SConstruct b/SConstruct index ef4d462bbb..164a378d8f 100644 --- a/SConstruct +++ b/SConstruct @@ -107,6 +107,9 @@ if mysql=='yes': else: main_env.Append(mysql='no') +# Testing +testing=ARGUMENTS.get('testing', 'no') + # xmlrpc xmlrpc_dir=ARGUMENTS.get('xmlrpc', 'none') @@ -184,6 +187,37 @@ build_scripts=[ 'src/authm/SConstruct', ] +if testing=='yes': + main_env.Append(CPPPATH=[ + cwd+'/include/test', + '/usr/include/cppunit/' + ]) + + main_env.Append(LIBPATH=[ + cwd+'/src/test', + ]) + + + main_env.Append(LIBS=[ + 'nebula_test_common', + ]) + + build_scripts.extend([ + 'src/authm/test/SConstruct', + 'src/common/test/SConstruct', + 'src/host/test/SConstruct', + 'src/image/test/SConstruct', + 'src/lcm/test/SConstruct', + 'src/pool/test/SConstruct', + 'src/scheduler/src/pool/test/SConstruct', + 'src/scheduler/src/xml/test/SConstruct', + 'src/template/test/SConstruct', + 'src/test/SConstruct', + 'src/um/test/SConstruct', + 'src/vm/test/SConstruct', + 'src/vnm/test/SConstruct', + ]) + for script in build_scripts: env=main_env.Clone() SConscript(script, exports='env') diff --git a/include/test/OneUnitTest.h b/include/test/OneUnitTest.h index b648bfe0d0..9f4ae3f2eb 100644 --- a/include/test/OneUnitTest.h +++ b/include/test/OneUnitTest.h @@ -209,10 +209,6 @@ public: /* ----------------------------------------------------------------------------- -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, TestClass::suite()); diff --git a/include/test/PoolTest.h b/include/test/PoolTest.h index 6e2e2bc388..8545873066 100644 --- a/include/test/PoolTest.h +++ b/include/test/PoolTest.h @@ -223,10 +223,6 @@ public: }; }; -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - // ----------------------------------------------------------------------------- #endif // POOL_TEST_H_ diff --git a/share/test/do_tests.sh b/share/test/do_tests.sh index 4088aa77bc..4bae670000 100755 --- a/share/test/do_tests.sh +++ b/share/test/do_tests.sh @@ -80,6 +80,21 @@ elif [ "$VAL_CALL" = "yes" ] ; then CALLER="valgrind --tool=callgrind" fi +if [ "$BUILD" = "yes" ] ; then + cd ../.. + scons testing=yes $BUILD_ARGS + + cd $BASE_DIR + exit 0 +fi + +if [ "$CLEAR" = "yes" ] ; then + cd ../.. + scons testing=yes -c + + cd $BASE_DIR +fi + TESTS=`find $TWD_DIR -name test -type d` for i in $TESTS ; do @@ -99,10 +114,7 @@ for i in $TESTS ; do cd $i if [ "$CLEAR" = "yes" ] ; then - scons -c - rm -f callgrind.out* test.db* *.log* memgrid.out* - elif [ "$BUILD" = "yes" ] ; then - scons $BUILD_ARGS + rm -f callgrind.out* test.db* *.log* memgrid.out* *.xml else for j in `ls test*` ; do if [ -x $j ] ; then diff --git a/src/authm/test/AuthManagerTest.cc b/src/authm/test/AuthManagerTest.cc index 8653c5b48b..a72acd3974 100644 --- a/src/authm/test/AuthManagerTest.cc +++ b/src/authm/test/AuthManagerTest.cc @@ -278,11 +278,6 @@ private: /* ************************************************************************* */ /* ************************************************************************* */ - -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, AuthManagerTest::suite()); diff --git a/src/authm/test/SConstruct b/src/authm/test/SConstruct index e1605f0142..990f694446 100644 --- a/src/authm/test/SConstruct +++ b/src/authm/test/SConstruct @@ -15,41 +15,9 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../../" - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - cwd + '/include', - '/usr/include/cppunit/' -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd + '/src/common', - cwd + '/src/template', - cwd + '/src/mad', - cwd + '/src/nebula', - cwd + '/src/authm', - cwd + '/src/sql', - cwd + '/src/log', -]) - -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_template', 'nebula_common', 'nebula_core', @@ -63,30 +31,16 @@ main_env.Append(LIBS=[ 'ssl' ]) -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror" -]) - -# MYSQL -main_env.Append(LIBPATH=["/usr/lib/mysql"]) -main_env.Append(CPPPATH=["/usr/include/mysql"]) - -# libxml2 -main_env.ParseConfig('xml2-config --libs --cflags') - sqlite=ARGUMENTS.get('sqlite', 'yes') if sqlite=='yes': - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) - main_env.Append(LIBS=[ 'sqlite3', ]) + env.Append(CPPFLAGS=["-DSQLITE_DB"]) + env.Append(LIBS=[ 'sqlite3', ]) # MySQL mysql=ARGUMENTS.get('mysql', 'no') if mysql=='yes': - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) - main_env.Append(LIBS=[ 'mysqlclient', ]) + env.Append(CPPFLAGS=["-DMYSQL_DB"]) + env.Append(LIBS=[ 'mysqlclient', ]) -main_env.Program('test','AuthManagerTest.cc') +env.Program('test','AuthManagerTest.cc') # diff --git a/src/common/test/SConstruct b/src/common/test/SConstruct index b4f4c86702..ccb4f22e0b 100644 --- a/src/common/test/SConstruct +++ b/src/common/test/SConstruct @@ -15,36 +15,9 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../../" - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - cwd + '/include', - '/usr/include/cppunit/' -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd + '/src/common', - cwd + '/src/log', -]) - -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_common', 'nebula_log', 'cppunit', @@ -52,17 +25,7 @@ main_env.Append(LIBS=[ 'pthread' ]) -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror" -]) - -# Linking flags -main_env.Append(LDFLAGS=["-g"]) - -main_env.Program('test_sa','single_attribute.cc') -main_env.Program('test_va','vector_attribute.cc') -main_env.Program('test_am','action_manager.cc') -main_env.Program('test_collector','mem_collector.cc') +env.Program('test_sa','single_attribute.cc') +env.Program('test_va','vector_attribute.cc') +env.Program('test_am','action_manager.cc') +env.Program('test_collector','mem_collector.cc') diff --git a/src/common/test/action_manager.cc b/src/common/test/action_manager.cc index 8afd147f13..09768cf313 100644 --- a/src/common/test/action_manager.cc +++ b/src/common/test/action_manager.cc @@ -175,11 +175,6 @@ public: } }; - -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, ActionManagerTest::suite(), diff --git a/src/common/test/mem_collector.cc b/src/common/test/mem_collector.cc index a256677ca4..e58e703cd9 100644 --- a/src/common/test/mem_collector.cc +++ b/src/common/test/mem_collector.cc @@ -95,10 +95,6 @@ public: } }; -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, MemCollectorTest::suite(), diff --git a/src/common/test/single_attribute.cc b/src/common/test/single_attribute.cc index 5f39c193f6..dca06d27b4 100644 --- a/src/common/test/single_attribute.cc +++ b/src/common/test/single_attribute.cc @@ -113,10 +113,6 @@ public: } }; -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, SingleAttributeTest::suite(), diff --git a/src/common/test/vector_attribute.cc b/src/common/test/vector_attribute.cc index 6de066ec7c..4fe857144d 100644 --- a/src/common/test/vector_attribute.cc +++ b/src/common/test/vector_attribute.cc @@ -143,13 +143,8 @@ public: } }; - -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, VectorAttributeTest::suite(), - "vector_attribute"); + "vector_attribute.xml"); } diff --git a/src/host/test/SConstruct b/src/host/test/SConstruct index d3f8669028..8b330ef2fa 100644 --- a/src/host/test/SConstruct +++ b/src/host/test/SConstruct @@ -1,3 +1,5 @@ +# SConstruct for src/host/test + # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -14,193 +16,9 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../.." - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# snippet borrowed from http://dev.gentoo.org/~vapier/scons-blows.txt -# makes scons aware of build related environment variables -if os.environ.has_key('CC'): - main_env['CC'] = os.environ['CC'] -if os.environ.has_key('CFLAGS'): - main_env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) -if os.environ.has_key('CXX'): - main_env['CXX'] = os.environ['CXX'] -if os.environ.has_key('CXXFLAGS'): - main_env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) -if os.environ.has_key('LDFLAGS'): - main_env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - '.', - cwd+'/include', - cwd+'/include/test', - cwd+'/src/hm/test', - '/usr/include/cppunit/' -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd+'/src/common', - cwd+'/src/log', - cwd+'/src/sql', - cwd+'/src/host', - cwd+'/src/mad', - cwd+'/src/nebula', - cwd+'/src/pool', - cwd+'/src/template', - cwd+'/src/vm', - cwd+'/src/vmm', - cwd+'/src/lcm', - cwd+'/src/tm', - cwd+'/src/dm', - cwd+'/src/im', - cwd+'/src/image', - cwd+'/src/rm', - cwd+'/src/vnm', - cwd+'/src/hm', - cwd+'/src/um', - cwd+'/src/authm', - '.', -]) - -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror", -]) - -# Linking flags -main_env.Append(LINKFLAGS=['-g', '-pthread']) - -####################### -# EXTRA CONFIGURATION # -####################### - -# SQLITE -sqlite_dir=ARGUMENTS.get('sqlite_dir', 'none') -if sqlite_dir!='none': - main_env.Append(LIBPATH=[sqlite_dir+"/lib"]) - main_env.Append(CPPPATH=[sqlite_dir+"/include"]) - -sqlite=ARGUMENTS.get('sqlite', 'yes') -if sqlite=='yes': - main_env.Append(sqlite='yes') - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) -else: - main_env.Append(sqlite='no') - -# MySQL -mysql=ARGUMENTS.get('mysql', 'no') -if mysql=='yes': - main_env.Append(mysql='yes') - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) -else: - main_env.Append(mysql='no') - - -# xmlrpc -xmlrpc_dir=ARGUMENTS.get('xmlrpc', 'none') -if xmlrpc_dir!='none': - main_env.Append(LIBPATH=[xmlrpc_dir+"/lib"]) - main_env.Append(CPPPATH=[xmlrpc_dir+"/include"]) - -# build lex/bison -build_parsers=ARGUMENTS.get('parsers', 'no') -if build_parsers=='yes': - main_env.Append(parsers='yes') -else: - main_env.Append(parsers='no') - -if not main_env.GetOption('clean'): - try: - main_env.ParseConfig('../../../share/scons/get_xmlrpc_config server') - main_env.ParseConfig('../../../share/scons/get_xmlrpc_config client') - - if mysql=='yes': - main_env.ParseConfig('mysql_config --cflags --libs') - - except Exception, e: - print "" - print "Error searching for xmlrpc-c libraries. Please check this"+\ - " things:" - print "" - print " * You have installed development libraries for xmlrpc-c. One"+\ - " way to check" - print " this is calling xmlrpc-c-config that is provided with the"+\ - " development" - print " package." - print " * Check that the version of xmlrpc-c is at least 1.06. You"+\ - " can do this also" - print " calling:" - print " $ xmlrpc-c-config --version" - print " * If all this requirements are already met please send log"+\ - " files located in" - print " .xmlrpc_test to the mailing list." - print "" - exit(-1) -else: - main_env.Replace(mysql='yes') - shutil.rmtree('.xmlrpc_test', True) - shutil.rmtree('src/nebula/.xmlrpc_test', True) - shutil.rmtree('src/scheduler/.xmlrpc_test', True) - - -# libxml2 -main_env.ParseConfig('xml2-config --libs --cflags') - - -# Build LCM and DM toguether in a lib - -lib_name='nebula_lcm_dm' - -# Sources to generate the library -source_files=[ - '../../lcm/LifeCycleManager.cc', - '../../lcm/LifeCycleActions.cc', - '../../lcm/LifeCycleStates.cc', - '../../dm/DispatchManager.cc', - '../../dm/DispatchManagerActions.cc', - '../../dm/DispatchManagerStates.cc', -] - -# Build library -main_env.StaticLibrary(lib_name, source_files) - - -# Build a modified Nebula lib - -lib_name='nebula_core_test' - -# Sources to generate the library -source_files=[ - '../../nebula/test/Nebula.cc', - '../../nebula/test/NebulaTest.cc', - '../../nebula/NebulaTemplate.cc', - '../../../include/test/OneUnitTest.cc', -] - -# Build library -main_env.StaticLibrary(lib_name, source_files) - - -# Build daemon -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_core_test', 'nebula_host', @@ -228,16 +46,11 @@ main_env.Append(LIBS=[ ]) # Sources to generate the library -if main_env['sqlite']=='yes': - main_env.Append(LIBS=['sqlite3']) +if env['sqlite']=='yes': + env.Append(LIBS=['sqlite3']) -if main_env['mysql']=='yes': - main_env.Append(LIBS=['mysqlclient']) +if env['mysql']=='yes': + env.Append(LIBS=['mysqlclient']) - -if not main_env.GetOption('clean'): - main_env.ParseConfig('../../../share/scons/get_xmlrpc_config server') - - -main_env.Program('test','HostPoolTest.cc') -main_env.Program('test_hook','HostHookTest.cc') +env.Program('test','HostPoolTest.cc') +env.Program('test_hook','HostHookTest.cc') diff --git a/src/image/test/SConstruct b/src/image/test/SConstruct index 19db958bbc..72f41e714f 100644 --- a/src/image/test/SConstruct +++ b/src/image/test/SConstruct @@ -14,49 +14,9 @@ # limitations under the License. # -------------------------------------------------------------------------- -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../../" - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - cwd + '/include', - cwd + '/include/test', - '/usr/include/cppunit/', -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd + '/src/common', - cwd + '/src/log', - cwd + '/src/nebula', - cwd + '/src/sql', - cwd + '/src/pool', - cwd + '/src/template', - cwd + '/src/vm', - cwd + '/src/hm', - cwd + '/src/mad', - cwd + '/src/vnm', - cwd + '/src/um', - cwd + '/src/authm', - cwd + '/src/image', - '/usr/include/openssl/', -]) - -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_image', 'nebula_um', 'nebula_vm', @@ -76,33 +36,16 @@ main_env.Append(LIBS=[ 'crypto', ]) -# MYSQL -main_env.Append(LIBPATH=["/usr/lib/mysql"]) -main_env.Append(CPPPATH=["/usr/include/mysql"]) - -# libxml2 -main_env.ParseConfig('xml2-config --libs --cflags') - sqlite=ARGUMENTS.get('sqlite', 'yes') if sqlite=='yes': - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) - main_env.Append(LIBS=[ 'sqlite3', ]) + env.Append(CPPFLAGS=["-DSQLITE_DB"]) + env.Append(LIBS=[ 'sqlite3', ]) # MySQL mysql=ARGUMENTS.get('mysql', 'no') if mysql=='yes': - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) - main_env.Append(LIBS=[ 'mysqlclient', ]) + env.Append(CPPFLAGS=["-DMYSQL_DB"]) + env.Append(LIBS=[ 'mysqlclient', ]) -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror" -]) - -# Linking flags -main_env.Append(LDFLAGS=["-g "]) - -main_env.Program('test','ImagePoolTest.cc') +env.Program('test','ImagePoolTest.cc') diff --git a/src/lcm/test/NebulaTestLCM.h b/src/lcm/test/NebulaTestLCM.h index 619c40cf3e..5d4164d745 100644 --- a/src/lcm/test/NebulaTestLCM.h +++ b/src/lcm/test/NebulaTestLCM.h @@ -39,6 +39,29 @@ public: } ~NebulaTestLCM(){}; + + TransferManager* create_tm(VirtualMachinePool* vmpool, + HostPool* hpool) + { + vector tm_mads; + + return new TransferManagerTest(vmpool, hpool, tm_mads); + } + + + VirtualMachineManager* create_vmm(VirtualMachinePool* vmpool, + HostPool* hpool, + time_t timer_period, + time_t poll_period) + { + vector vmm_mads; + return new VirtualMachineManagerTest(vmpool, + hpool, + timer_period, + poll_period, + vmm_mads); + } + }; #endif /*NEBULA_TEST_LCM_H_*/ diff --git a/src/lcm/test/SConstruct b/src/lcm/test/SConstruct index 960836bde2..e5d46c35cf 100644 --- a/src/lcm/test/SConstruct +++ b/src/lcm/test/SConstruct @@ -1,3 +1,5 @@ +# SConstruct for src/lcm/test + # -------------------------------------------------------------------------- # # Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # # # @@ -14,194 +16,12 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../.." - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# snippet borrowed from http://dev.gentoo.org/~vapier/scons-blows.txt -# makes scons aware of build related environment variables -if os.environ.has_key('CC'): - main_env['CC'] = os.environ['CC'] -if os.environ.has_key('CFLAGS'): - main_env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) -if os.environ.has_key('CXX'): - main_env['CXX'] = os.environ['CXX'] -if os.environ.has_key('CXXFLAGS'): - main_env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) -if os.environ.has_key('LDFLAGS'): - main_env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - '.', - cwd+'/include', - cwd+'/include/test', - '/usr/include/cppunit/' -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd+'/src/common', - cwd+'/src/log', - cwd+'/src/sql', - cwd+'/src/host', - cwd+'/src/mad', - cwd+'/src/nebula', - cwd+'/src/pool', - cwd+'/src/template', - cwd+'/src/vm', - cwd+'/src/vmm', - cwd+'/src/lcm', - cwd+'/src/tm', - cwd+'/src/dm', - cwd+'/src/im', - cwd+'/src/image', - cwd+'/src/rm', - cwd+'/src/vnm', - cwd+'/src/hm', - cwd+'/src/um', - cwd+'/src/authm', - '.', -]) - -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror", -]) - -# Linking flags -main_env.Append(LINKFLAGS=['-g', '-pthread']) - -####################### -# EXTRA CONFIGURATION # -####################### - -# SQLITE -sqlite_dir=ARGUMENTS.get('sqlite_dir', 'none') -if sqlite_dir!='none': - main_env.Append(LIBPATH=[sqlite_dir+"/lib"]) - main_env.Append(CPPPATH=[sqlite_dir+"/include"]) - -sqlite=ARGUMENTS.get('sqlite', 'yes') -if sqlite=='yes': - main_env.Append(sqlite='yes') - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) -else: - main_env.Append(sqlite='no') - -# MySQL -mysql=ARGUMENTS.get('mysql', 'no') -if mysql=='yes': - main_env.Append(mysql='yes') - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) -else: - main_env.Append(mysql='no') - - -# xmlrpc -xmlrpc_dir=ARGUMENTS.get('xmlrpc', 'none') -if xmlrpc_dir!='none': - main_env.Append(LIBPATH=[xmlrpc_dir+"/lib"]) - main_env.Append(CPPPATH=[xmlrpc_dir+"/include"]) - -# build lex/bison -build_parsers=ARGUMENTS.get('parsers', 'no') -if build_parsers=='yes': - main_env.Append(parsers='yes') -else: - main_env.Append(parsers='no') - -if not main_env.GetOption('clean'): - try: - main_env.ParseConfig('../../../share/scons/get_xmlrpc_config server') - main_env.ParseConfig('../../../share/scons/get_xmlrpc_config client') - - if mysql=='yes': - main_env.ParseConfig('mysql_config --cflags --libs') - - except Exception, e: - print "" - print "Error searching for xmlrpc-c libraries. Please check this"+\ - " things:" - print "" - print " * You have installed development libraries for xmlrpc-c. One"+\ - " way to check" - print " this is calling xmlrpc-c-config that is provided with the"+\ - " development" - print " package." - print " * Check that the version of xmlrpc-c is at least 1.06. You"+\ - " can do this also" - print " calling:" - print " $ xmlrpc-c-config --version" - print " * If all this requirements are already met please send log"+\ - " files located in" - print " .xmlrpc_test to the mailing list." - print "" - exit(-1) -else: - main_env.Replace(mysql='yes') - shutil.rmtree('.xmlrpc_test', True) - shutil.rmtree('src/nebula/.xmlrpc_test', True) - shutil.rmtree('src/scheduler/.xmlrpc_test', True) - - -# libxml2 -main_env.ParseConfig('xml2-config --libs --cflags') - - -# Build LCM and DM toguether in a lib - -lib_name='nebula_lcm_dm' - -# Sources to generate the library -source_files=[ - '../LifeCycleManager.cc', - '../LifeCycleActions.cc', - '../LifeCycleStates.cc', - '../../dm/DispatchManager.cc', - '../../dm/DispatchManagerActions.cc', - '../../dm/DispatchManagerStates.cc', -] - -# Build library -main_env.StaticLibrary(lib_name, source_files) - - -# Build a modified Nebula lib - -lib_name='nebula_core_test' - -# Sources to generate the library -source_files=[ - '../../nebula/test/Nebula.cc', - '../../nebula/test/NebulaTest.cc', - '../../nebula/NebulaTemplate.cc', - '../../../include/test/OneUnitTest.cc', -] - -# Build library -main_env.StaticLibrary(lib_name, source_files) - - -# Build daemon -main_env.Append(LIBS=[ - 'nebula_lcm_dm', +env.Append(LIBS=[ 'nebula_core_test', + + 'nebula_host', 'nebula_vmm', 'nebula_im', 'nebula_rm', @@ -209,7 +29,6 @@ main_env.Append(LIBS=[ 'nebula_um', 'nebula_mad', 'nebula_template', - 'nebula_host', 'nebula_vm', 'nebula_vnm', 'nebula_image', @@ -220,20 +39,17 @@ main_env.Append(LIBS=[ 'nebula_sql', 'nebula_log', + 'nebula_lcm_dm', + 'crypto', 'cppunit', ]) # Sources to generate the library -if main_env['sqlite']=='yes': - main_env.Append(LIBS=['sqlite3']) +if env['sqlite']=='yes': + env.Append(LIBS=['sqlite3']) -if main_env['mysql']=='yes': - main_env.Append(LIBS=['mysqlclient']) +if env['mysql']=='yes': + env.Append(LIBS=['mysqlclient']) - -if not main_env.GetOption('clean'): - main_env.ParseConfig('../../../share/scons/get_xmlrpc_config server') - - -main_env.Program('test','LifeCycleManagerTest.cc') +env.Program('test','LifeCycleManagerTest.cc') diff --git a/src/pool/test/SConstruct b/src/pool/test/SConstruct index a8c47d0a90..c8fef280fb 100644 --- a/src/pool/test/SConstruct +++ b/src/pool/test/SConstruct @@ -14,40 +14,14 @@ # limitations under the License. # -------------------------------------------------------------------------- -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * - -# This is the absolute path where the project is located -cwd="../../../" - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - cwd + '/include', - '/usr/include/cppunit/', -]) +Import('env') # Library dirs -main_env.Append(LIBPATH=[ - cwd + '/src/common', - cwd + '/src/log', - cwd + '/src/pool', - cwd + '/src/sql', - cwd + '/src/pool/test', - cwd + '/src/nebula', +env.Append(LIBPATH=[ + '.' ]) -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_pool', 'nebula_common', 'nebula_log', @@ -59,29 +33,18 @@ main_env.Append(LIBS=[ 'test_object' ]) -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror" -]) - -# MYSQL -main_env.Append(LIBPATH=["/usr/lib/mysql"]) -main_env.Append(CPPPATH=["/usr/include/mysql"]) - sqlite=ARGUMENTS.get('sqlite', 'yes') if sqlite=='yes': - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) - main_env.Append(LIBS=[ 'sqlite3', ]) + env.Append(CPPFLAGS=["-DSQLITE_DB"]) + env.Append(LIBS=[ 'sqlite3', ]) # MySQL mysql=ARGUMENTS.get('mysql', 'no') if mysql=='yes': - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) - main_env.Append(LIBS=[ 'mysqlclient', ]) + env.Append(CPPFLAGS=["-DMYSQL_DB"]) + env.Append(LIBS=[ 'mysqlclient', ]) -main_env.StaticLibrary('test_object', ['TestPoolSQL.cc', 'TestPoolSQL.h']) -main_env.Program('test','pool.cc') +env.StaticLibrary('test_object', ['TestPoolSQL.cc', 'TestPoolSQL.h']) +env.Program('test','pool.cc') diff --git a/src/pool/test/pool.cc b/src/pool/test/pool.cc index 4cfa297924..5455d79d90 100644 --- a/src/pool/test/pool.cc +++ b/src/pool/test/pool.cc @@ -202,10 +202,6 @@ public: /* ************************************************************************* */ /* ************************************************************************* */ -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, PoolTest::suite()); diff --git a/src/scheduler/src/pool/test/HostXMLTest.cc b/src/scheduler/src/pool/test/HostXMLTest.cc index 5c2cab0f73..d5459717e0 100644 --- a/src/scheduler/src/pool/test/HostXMLTest.cc +++ b/src/scheduler/src/pool/test/HostXMLTest.cc @@ -248,10 +248,6 @@ public: /* ************************************************************************* */ /* ************************************************************************* */ -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, HostXMLTest::suite(), diff --git a/src/scheduler/src/pool/test/SConstruct b/src/scheduler/src/pool/test/SConstruct index bca8de5178..9dd34cb87a 100644 --- a/src/scheduler/src/pool/test/SConstruct +++ b/src/scheduler/src/pool/test/SConstruct @@ -38,7 +38,8 @@ main_env.Append(LIBPATH=[ cwd+'/..', cwd+'/../../xml', cwd+'/../../../../log', - cwd+'/../../../../common' + cwd+'/../../../../common', + cwd+'/../../../../test', ]) # Compile flags @@ -57,7 +58,8 @@ main_env.Append(LIBS=[ 'scheduler_xml', 'scheduler_pool', 'nebula_log', - 'nebula_common' + 'nebula_common', + 'nebula_test_common', ]) main_env.Program('test_vm','VirtualMachineXMLTest.cc') diff --git a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc index 462dbd4858..99ab1cbb1c 100644 --- a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc +++ b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc @@ -302,10 +302,6 @@ public: /* ************************************************************************* */ /* ************************************************************************* */ -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, VirtualMachineXMLTest::suite(), diff --git a/src/scheduler/src/xml/test/ObjectXMLTest.cc b/src/scheduler/src/xml/test/ObjectXMLTest.cc index 90563c086a..4060cc52f1 100644 --- a/src/scheduler/src/xml/test/ObjectXMLTest.cc +++ b/src/scheduler/src/xml/test/ObjectXMLTest.cc @@ -319,10 +319,6 @@ public: /* ************************************************************************* */ /* ************************************************************************* */ -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, ObjectXMLTest::suite()); diff --git a/src/scheduler/src/xml/test/SConstruct b/src/scheduler/src/xml/test/SConstruct index d2cc0af0cd..b8e8d292a0 100644 --- a/src/scheduler/src/xml/test/SConstruct +++ b/src/scheduler/src/xml/test/SConstruct @@ -37,7 +37,8 @@ main_env.Append(CPPPATH=[ main_env.Append(LIBPATH=[ cwd+'/../../../../common', cwd+'/../../../../log', - '../' + '../', + cwd+'/../../../../test', ]) # Compile flags @@ -55,7 +56,8 @@ main_env.Append(LIBS=[ 'cppunit', 'nebula_log', 'scheduler_xml', - 'nebula_common' + 'nebula_common', + 'nebula_test_common', ]) main_env.Program('test_xml','ObjectXMLTest.cc') diff --git a/src/template/test/SConstruct b/src/template/test/SConstruct index c54377f0ec..2ccb2985c7 100644 --- a/src/template/test/SConstruct +++ b/src/template/test/SConstruct @@ -15,38 +15,9 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../../" - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - cwd + '/include', - '/usr/include/cppunit/' -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd + '/src/common', - cwd + '/src/template', - cwd + '/src/nebula', - cwd + '/src/log', -]) - -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_template', 'nebula_common', 'nebula_core', @@ -56,30 +27,16 @@ main_env.Append(LIBS=[ 'pthread' ]) -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror" -]) - -# libxml2 -main_env.ParseConfig('xml2-config --libs --cflags') - -# MYSQL -main_env.Append(LIBPATH=["/usr/lib/mysql"]) -main_env.Append(CPPPATH=["/usr/include/mysql"]) - sqlite=ARGUMENTS.get('sqlite', 'yes') if sqlite=='yes': - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) - main_env.Append(LIBS=[ 'sqlite3', ]) + env.Append(CPPFLAGS=["-DSQLITE_DB"]) + env.Append(LIBS=[ 'sqlite3', ]) # MySQL mysql=ARGUMENTS.get('mysql', 'no') if mysql=='yes': - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) - main_env.Append(LIBS=[ 'mysqlclient', ]) + env.Append(CPPFLAGS=["-DMYSQL_DB"]) + env.Append(LIBS=[ 'mysqlclient', ]) -main_env.Program('test','template.cc') +env.Program('test','template.cc') # diff --git a/src/template/test/template.cc b/src/template/test/template.cc index f6a1d04dac..d755f74653 100644 --- a/src/template/test/template.cc +++ b/src/template/test/template.cc @@ -360,11 +360,6 @@ public: /* ************************************************************************* */ /* ************************************************************************* */ - -bool OneUnitTest::mysql; -SqlDB * OneUnitTest::db = 0; -string OneUnitTest::db_name = "ONE_test_database"; - int main(int argc, char ** argv) { return OneUnitTest::main(argc, argv, TemplateTest::suite()); diff --git a/src/nebula/test/Nebula.cc b/src/test/Nebula.cc similarity index 100% rename from src/nebula/test/Nebula.cc rename to src/test/Nebula.cc diff --git a/src/nebula/test/NebulaTest.cc b/src/test/NebulaTest.cc similarity index 100% rename from src/nebula/test/NebulaTest.cc rename to src/test/NebulaTest.cc diff --git a/include/test/OneUnitTest.cc b/src/test/OneUnitTest.cc similarity index 100% rename from include/test/OneUnitTest.cc rename to src/test/OneUnitTest.cc diff --git a/src/test/SConstruct b/src/test/SConstruct new file mode 100644 index 0000000000..62873681d2 --- /dev/null +++ b/src/test/SConstruct @@ -0,0 +1,63 @@ +# SConstruct for src/test + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +Import('env') + +# Build LCM and DM toguether in a lib +lib_name='nebula_lcm_dm' + +# Sources to generate the library +source_files=[ + '../lcm/LifeCycleManager.cc', + '../lcm/LifeCycleActions.cc', + '../lcm/LifeCycleStates.cc', + '../dm/DispatchManager.cc', + '../dm/DispatchManagerActions.cc', + '../dm/DispatchManagerStates.cc', +] + +# Build library +env.StaticLibrary(lib_name, source_files) + + +# Build a modified Nebula lib +lib_name='nebula_core_test' + +# Sources to generate the library +source_files=[ + 'Nebula.cc', + 'NebulaTest.cc', + '../nebula/NebulaTemplate.cc', +] + +# Build library +env.StaticLibrary(lib_name, source_files) + + +# Build a modified Nebula lib +lib_name='nebula_test_common' + +# Sources to generate the library +source_files=[ + 'OneUnitTest.cc', +] + +# Build library +env.StaticLibrary(lib_name, source_files) + + diff --git a/src/um/test/SConstruct b/src/um/test/SConstruct index e6f5135243..52fcdf95c3 100644 --- a/src/um/test/SConstruct +++ b/src/um/test/SConstruct @@ -14,44 +14,9 @@ # limitations under the License. # -------------------------------------------------------------------------- -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../../" - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - cwd + '/include', - cwd + '/include/test', - '/usr/include/cppunit/', -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd + '/src/common', - cwd + '/src/mad', - cwd + '/src/log', - cwd + '/src/nebula', - cwd + '/src/pool', - cwd + '/src/sql', - cwd + '/src/authm', - cwd + '/src/um', - '/usr/include/openssl/', -]) - -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_um', 'nebula_pool', 'nebula_log', @@ -66,32 +31,15 @@ main_env.Append(LIBS=[ 'crypto' ]) -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror" -]) - -# Linking flags -main_env.Append(LDFLAGS=["-g "]) -main_env.Program('test','UserPoolTest.cc') - -# MYSQL -main_env.Append(LIBPATH=["/usr/lib/mysql"]) -main_env.Append(CPPPATH=["/usr/include/mysql"]) - -# libxml2 -main_env.ParseConfig('xml2-config --libs --cflags') - sqlite=ARGUMENTS.get('sqlite', 'yes') if sqlite=='yes': - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) - main_env.Append(LIBS=[ 'sqlite3', ]) + env.Append(CPPFLAGS=["-DSQLITE_DB"]) + env.Append(LIBS=[ 'sqlite3', ]) # MySQL mysql=ARGUMENTS.get('mysql', 'no') if mysql=='yes': - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) - main_env.Append(LIBS=[ 'mysqlclient', ]) + env.Append(CPPFLAGS=["-DMYSQL_DB"]) + env.Append(LIBS=[ 'mysqlclient', ]) +env.Program('test','UserPoolTest.cc') diff --git a/src/vm/test/SConstruct b/src/vm/test/SConstruct index ff30b8b852..132c1d0b86 100644 --- a/src/vm/test/SConstruct +++ b/src/vm/test/SConstruct @@ -14,49 +14,9 @@ # limitations under the License. # -------------------------------------------------------------------------- -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../../" - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - cwd + '/include', - cwd + '/include/test', - '/usr/include/cppunit/', -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd + '/src/common', - cwd + '/src/log', - cwd + '/src/nebula', - cwd + '/src/sql', - cwd + '/src/pool', - cwd + '/src/template', - cwd + '/src/vm', - cwd + '/src/hm', - cwd + '/src/authm', - cwd + '/src/mad', - cwd + '/src/vnm', - cwd + '/src/um', - cwd + '/src/image', - '/usr/include/openssl/', -]) - -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_um', 'nebula_vm', 'nebula_hm', @@ -76,33 +36,16 @@ main_env.Append(LIBS=[ 'crypto', ]) -# MYSQL -main_env.Append(LIBPATH=["/usr/lib/mysql"]) -main_env.Append(CPPPATH=["/usr/include/mysql"]) - -# libxml2 -main_env.ParseConfig('xml2-config --libs --cflags') - sqlite=ARGUMENTS.get('sqlite', 'yes') if sqlite=='yes': - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) - main_env.Append(LIBS=[ 'sqlite3', ]) + env.Append(CPPFLAGS=["-DSQLITE_DB"]) + env.Append(LIBS=[ 'sqlite3', ]) # MySQL mysql=ARGUMENTS.get('mysql', 'no') if mysql=='yes': - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) - main_env.Append(LIBS=[ 'mysqlclient', ]) + env.Append(CPPFLAGS=["-DMYSQL_DB"]) + env.Append(LIBS=[ 'mysqlclient', ]) -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror" -]) - -# Linking flags -main_env.Append(LDFLAGS=["-g "]) - -main_env.Program('test','VirtualMachinePoolTest.cc') +env.Program('test','VirtualMachinePoolTest.cc') diff --git a/src/vnm/test/SConstruct b/src/vnm/test/SConstruct index cbd1a53e14..70b6c91cd0 100644 --- a/src/vnm/test/SConstruct +++ b/src/vnm/test/SConstruct @@ -14,45 +14,9 @@ # limitations under the License. # -------------------------------------------------------------------------- -import os -import sys -import shutil -sys.path.append("../../../share/scons") -from lex_bison import * +Import('env') -# This is the absolute path where the project is located -cwd="../../../" - -# Environment that will be applied to each scons child -main_env=Environment() -main_env['ENV']['PATH']=os.environ['PATH'] - -# Add builders for flex and bison -add_lex(main_env) -add_bison(main_env) - -# Include dirs -main_env.Append(CPPPATH=[ - cwd + '/include', - cwd + '/include/test', - '/usr/include/cppunit/', -]) - -# Library dirs -main_env.Append(LIBPATH=[ - cwd + '/src/authm', - cwd + '/src/common', - cwd + '/src/mad', - cwd + '/src/nebula', - cwd + '/src/sql', - cwd + '/src/log', - cwd + '/src/pool', - cwd + '/src/template', - cwd + '/src/um', - cwd + '/src/vnm', -]) - -main_env.Append(LIBS=[ +env.Append(LIBS=[ 'nebula_log', 'nebula_um', 'nebula_vnm', @@ -69,33 +33,16 @@ main_env.Append(LIBS=[ 'crypto', ]) -# MYSQL -main_env.Append(LIBPATH=["/usr/lib/mysql"]) -main_env.Append(CPPPATH=["/usr/include/mysql"]) - -# libxml2 -main_env.ParseConfig('xml2-config --libs --cflags') - sqlite=ARGUMENTS.get('sqlite', 'yes') if sqlite=='yes': - main_env.Append(CPPFLAGS=["-DSQLITE_DB"]) - main_env.Append(LIBS=[ 'sqlite3', ]) + env.Append(CPPFLAGS=["-DSQLITE_DB"]) + env.Append(LIBS=[ 'sqlite3', ]) # MySQL mysql=ARGUMENTS.get('mysql', 'no') if mysql=='yes': - main_env.Append(CPPFLAGS=["-DMYSQL_DB"]) - main_env.Append(LIBS=[ 'mysqlclient', ]) + env.Append(CPPFLAGS=["-DMYSQL_DB"]) + env.Append(LIBS=[ 'mysqlclient', ]) -# Compile flags -main_env.Append(CPPFLAGS=[ - "-g", - "-Wall", - "-Werror" -]) - -# Linking flags -main_env.Append(LDFLAGS=["-g "]) - -main_env.Program('test','VirtualNetworkPoolTest.cc') +env.Program('test','VirtualNetworkPoolTest.cc')