- 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:
tchernobog 2006-03-09 22:20:55 +00:00
parent ef733b37e8
commit ec3361cb84
4 changed files with 82 additions and 51 deletions

View file

@ -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);
}