From ec3361cb84ef4f13384adef956bce3e4703fa35d Mon Sep 17 00:00:00 2001 From: tchernobog Date: Thu, 9 Mar 2006 22:20:55 +0000 Subject: [PATCH] - Make test-python_loader a unit test instead of an integration test git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@520 3ecf2c5c-341e-0410-92b4-d18e462d057c --- ChangeLog | 33 +++++++++++ Makefile.am | 6 +- src/backend/pyloader/python_policy.cc | 9 +-- src/testsuite/test-python_loader.cc | 85 ++++++++++++++------------- 4 files changed, 82 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 646ed07..43717ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2006-03-09 21:56 tchernobog + + * trunk/Makefile.am, trunk/src/backend/observed_subject.hh, + trunk/src/backend/pyloader/python_policy.cc, + trunk/src/backend/scheduler.cc, trunk/src/backend/scheduler.hh, + trunk/src/simulation.cc, trunk/src/simulation.hh, + trunk/src/testsuite/python_loader_configure.py, + trunk/src/testsuite/python_loader_get_time_slice.py, + trunk/src/testsuite/python_loader_is_preemptive.py, + trunk/src/testsuite/python_loader_sort_queue.py, + trunk/src/testsuite/test-python_loader.cc, + trunk/src/text_simulation.cc: - Update test-python_loader, do not + link to libpyloader anymore - TODO: sigsegv (due to an hidden + vtable?) + +2006-03-09 21:02 tchernobog + + * trunk/Makefile.am, trunk/configure.ac: - Add support for + conditional compilation of tests + +2006-03-09 16:25 matrevis + + * trunk/src/testsuite/test-history.cc, + trunk/src/testsuite/test-stepforward.cc: - ArthurDent - Test + completato codice del test di history + +2006-03-09 11:37 tchernobog + + * trunk/ChangeLog, trunk/Makefile.am, trunk/src/backend/history.cc, + trunk/src/backend/history.hh, trunk/src/testsuite/test-history.cc, + trunk/src/testsuite/test-parse_command.cc: - Fix compilation of + test-history + 2006-03-09 10:49 tchernobog * trunk/Makefile.am, trunk/src/backend/global_settings.cc, diff --git a/Makefile.am b/Makefile.am index 518795b..d4ac491 100644 --- a/Makefile.am +++ b/Makefile.am @@ -373,11 +373,7 @@ src_testsuite_test_python_loader_LDFLAGS = \ src_testsuite_test_python_loader_SOURCES = \ src/testsuite/test-python_loader.cc \ src/backend/pyloader/python_policy.cc \ - src/backend/pyloader/python_policy_manager.cc \ - src/standard_io.cc \ - src/text_simulation.cc \ - src/observer.cc \ - src/simulation.cc + src/backend/pyloader/python_policy_manager.cc noinst_PYTHON += src/testsuite/python_loader_configure.py \ src/testsuite/python_loader_sort_queue.py \ diff --git a/src/backend/pyloader/python_policy.cc b/src/backend/pyloader/python_policy.cc index 92c30b7..5017b8a 100644 --- a/src/backend/pyloader/python_policy.cc +++ b/src/backend/pyloader/python_policy.cc @@ -160,6 +160,8 @@ PythonPolicy::wait_unlock() const throw(UserInterruptException) int i = 0; // We give the sort_queue() three seconds max time, then... // we shot it stone dead! Bang. + std::cout << "waiting unlock" << std::endl; + bool still_locked; do { @@ -172,11 +174,10 @@ PythonPolicy::wait_unlock() const throw(UserInterruptException) Py_DECREF(retval); if(i++ > 120) - { - - PyThreadState_Clear(_save); + { + PyThreadState_Clear(_save); PyEval_RestoreThread(_save); - + //Py_UNBLOCK_THREADS; throw UserInterruptException("User-defined policy is " diff --git a/src/testsuite/test-python_loader.cc b/src/testsuite/test-python_loader.cc index 40367cd..672fd80 100644 --- a/src/testsuite/test-python_loader.cc +++ b/src/testsuite/test-python_loader.cc @@ -24,13 +24,10 @@ #include "backend/pyloader/python_policy_manager.hh" #include "backend/pyloader/python_policy.hh" -#include "backend/process.hh" #include "backend/global_settings.hh" -#include "backend/schedulable_status.hh" #include "backend/schedulable_list.hh" #include "backend/scheduler.hh" -#include "standard_io.hh" -#include "text_simulation.hh" +#include "backend/user_interrupt_exception.hh" #include "templates/smartp.hh" #include @@ -55,7 +52,8 @@ public: int main(int argc, char** argv) { using namespace sgpem; - + using namespace std; + if(argc != 2) { std::cout << "[EE] Usage:\n\t" << argv[0] << " path/to/uninstalled/policies" << std::endl; @@ -64,49 +62,52 @@ main(int argc, char** argv) { else // Add argv[1] as the directory to search for uninstalled policies sgpem::GlobalSettings::instance().add_policies_dir(argv[1]); - - Glib::thread_init(); - // Create an INITIAL STATE - Process p1("P1", 0,5,1); - - SchedulableStatus ss1(p1); - - SchedulableList initial; - initial.add_at_bottom(ss1); - - History::get_instance().enqueue_slice(initial); - - Scheduler::get_instance(); // Forces initialization of scheduler. - // Cross fingers - - //the textual simulation - TextSimulation text_sim; - History::get_instance().attach(&text_sim); - - //textual IO - memory::smart_ptr io(new StandardIO()); - text_sim.add_io_device(io); - text_sim.update(); - - // Self-register itself to Scheduler + // Self-register itself to Scheduler, however we don't care about it TestPythonPolicyManager polman; - polman.test_init("python_loader_configure"); - text_sim.run(); - text_sim.stop(); + try + { + polman.test_init("python_loader_configure"); + polman.get_policy().configure(); + } + catch(UserInterruptException e) + { + cout << "configure: Caught UserInterruptException" << endl; + } + - polman.test_init("python_loader_is_preemptive"); - text_sim.run(); - text_sim.stop(); + try + { + polman.test_init("python_loader_is_preemptive"); + polman.get_policy().is_pre_emptive(); + } + catch(UserInterruptException e) + { + cout << "is_preemptive: Caught UserInterruptException" << endl; + } - polman.test_init("python_loader_get_time_slice"); - text_sim.run(); - text_sim.stop(); + try + { + polman.test_init("python_loader_get_time_slice"); + polman.get_policy().get_time_slice(); + } + catch(UserInterruptException e) + { + cout << "get_time_slice: Caught UserInterruptException" << endl; + } - polman.test_init("python_loader_sort_queue"); - text_sim.run(); - text_sim.stop(); + + try + { + SchedulableList sl; + polman.test_init("python_loader_sort_queue"); + polman.get_policy().sort_queue(Scheduler::event_schedulable_arrival); + } + catch(UserInterruptException e) + { + cout << "sort_queue: Caught UserInterruptException" << endl; + } exit(0); }