- 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
This commit is contained in:
parent
ef733b37e8
commit
ec3361cb84
4 changed files with 82 additions and 51 deletions
|
@ -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 "
|
||||
|
|
|
@ -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 <Python.h>
|
||||
|
@ -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<IOManager> 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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue