- Give facelift to test_loader. Still to be finished.
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@509 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
d462f6d1d3
commit
6a0bf4f444
11 changed files with 145 additions and 37 deletions
19
src/testsuite/python_loader_configure.py
Normal file
19
src/testsuite/python_loader_configure.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
class python_loader_configure(Policy) :
|
||||
def __init__(self):
|
||||
pass;
|
||||
|
||||
def configure(self):
|
||||
while True:
|
||||
pass
|
||||
|
||||
def is_preemptive(self):
|
||||
return False
|
||||
|
||||
def get_time_slice(self):
|
||||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
pass
|
20
src/testsuite/python_loader_get_time_slice.py
Normal file
20
src/testsuite/python_loader_get_time_slice.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
class python_loader_get_time_slice(Policy) :
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def is_preemptive(self):
|
||||
return False
|
||||
|
||||
def get_time_slice(self):
|
||||
while True:
|
||||
pass
|
||||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
pass
|
20
src/testsuite/python_loader_is_preemptive.py
Normal file
20
src/testsuite/python_loader_is_preemptive.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
class python_loader_is_preemptive(Policy) :
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def is_preemptive(self):
|
||||
while True:
|
||||
pass
|
||||
return False
|
||||
|
||||
def get_time_slice(self):
|
||||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
pass
|
19
src/testsuite/python_loader_sort_queue.py
Normal file
19
src/testsuite/python_loader_sort_queue.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
class python_loader_sort_queue(Policy) :
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def is_preemptive(self):
|
||||
return False
|
||||
|
||||
def get_time_slice(self):
|
||||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
while True:
|
||||
pass
|
|
@ -23,6 +23,7 @@
|
|||
* here, thanks very much. */
|
||||
|
||||
#include "backend/pyloader/python_policy_manager.hh"
|
||||
#include "backend/pyloader/python_policy.hh"
|
||||
#include "backend/process.hh"
|
||||
#include "backend/schedulable_status.hh"
|
||||
#include "backend/schedulable_list.hh"
|
||||
|
@ -31,49 +32,42 @@
|
|||
#include "text_simulation.hh"
|
||||
#include "templates/smartp.hh"
|
||||
|
||||
#include <Python.h>
|
||||
#include <glibmm/module.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
class TestPythonPolicyManager : public PythonPolicyManager {
|
||||
public:
|
||||
void test_init(const char* policy_name) {
|
||||
init();
|
||||
PyRun_SimpleString("import sys\n"
|
||||
"sys.path[:0] = [ '" MODDIR "', '" POLDIR "' ]\n");
|
||||
_python_policy = std::auto_ptr<PythonPolicy>(new PythonPolicy(policy_name));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv) {
|
||||
using namespace sgpem;
|
||||
using Glib::Module;
|
||||
|
||||
std::string pyloader_path = Module::build_path(MODDIR, "pyloader");
|
||||
Glib::Module pyloader(pyloader_path);
|
||||
assert(pyloader);
|
||||
|
||||
Glib::thread_init();
|
||||
|
||||
// Create an INITIAL STATE
|
||||
Process p1("P1", 0,5,1);
|
||||
Process p2("P2", 0,5,2);
|
||||
Process p3("P3", 5,3,3);
|
||||
Process p4("P4", 6,2,3);
|
||||
Process p5("P5", 1,2,3);
|
||||
Process p6("P6", 10,2,1);
|
||||
|
||||
SchedulableStatus ss1(p1);
|
||||
SchedulableStatus ss2(p2);
|
||||
SchedulableStatus ss3(p3);
|
||||
SchedulableStatus ss4(p4);
|
||||
SchedulableStatus ss5(p5);
|
||||
SchedulableStatus ss6(p6);
|
||||
|
||||
|
||||
SchedulableList initial;
|
||||
initial.add_at_bottom(ss1);
|
||||
initial.add_at_bottom(ss2);
|
||||
initial.add_at_bottom(ss3);
|
||||
initial.add_at_bottom(ss4);
|
||||
initial.add_at_bottom(ss5);
|
||||
initial.add_at_bottom(ss6);
|
||||
|
||||
History::get_instance().enqueue_slice(initial);
|
||||
|
||||
Scheduler::get_instance(); // Forces initialization of scheduler.
|
||||
// Cross fingers (depends if PythonPolicyManager
|
||||
// static object has been initialized before?).
|
||||
// Cross fingers
|
||||
|
||||
//the textual simulation
|
||||
TextSimulation text_sim;
|
||||
|
@ -83,6 +77,21 @@ main(int argc, char** argv) {
|
|||
memory::smart_ptr<IOManager> io(new StandardIO());
|
||||
text_sim.add_io_device(io);
|
||||
text_sim.update();
|
||||
|
||||
// Self-register itself to Scheduler
|
||||
TestPythonPolicyManager polman;
|
||||
|
||||
polman.test_init("python_loader_configure");
|
||||
text_sim.run();
|
||||
|
||||
polman.test_init("python_loader_is_preemptive");
|
||||
text_sim.run();
|
||||
|
||||
polman.test_init("python_loader_get_time_slice");
|
||||
text_sim.run();
|
||||
|
||||
polman.test_init("python_loader_sort_queue");
|
||||
text_sim.run();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue