2006-02-21 23:57:14 +01:00
|
|
|
// src/testsuite/test-python_loader.cc - Copyright 2005, 2006, University
|
|
|
|
// of Padova, dept. of Pure and Applied
|
|
|
|
// Mathematics
|
|
|
|
//
|
|
|
|
// This file is part of SGPEMv2.
|
|
|
|
//
|
|
|
|
// This is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// SGPEMv2 is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with SGPEMv2; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
/* This executable tests for workingness of the PythonPolicyManager
|
|
|
|
* class and its closely related cousins. More documentation to be written
|
|
|
|
* here, thanks very much. */
|
|
|
|
|
|
|
|
#include "backend/pyloader/python_policy_manager.hh"
|
2006-02-22 23:57:32 +01:00
|
|
|
#include "backend/process.hh"
|
|
|
|
#include "backend/schedulable_status.hh"
|
|
|
|
#include "backend/schedulable_list.hh"
|
|
|
|
#include "backend/scheduler.hh"
|
2006-02-23 12:29:25 +01:00
|
|
|
#include "standard_io.hh"
|
|
|
|
#include "text_simulation.hh"
|
|
|
|
#include "templates/smartp.hh"
|
|
|
|
|
2006-02-25 13:21:30 +01:00
|
|
|
#include <glibmm/module.h>
|
|
|
|
|
2006-02-22 23:57:32 +01:00
|
|
|
#include <cassert>
|
2006-02-25 13:21:30 +01:00
|
|
|
#include <string>
|
2006-02-21 23:57:14 +01:00
|
|
|
|
|
|
|
int
|
2006-02-23 12:29:25 +01:00
|
|
|
main(int argc, char** argv) {
|
2006-02-21 23:57:14 +01:00
|
|
|
using namespace sgpem;
|
2006-02-25 13:21:30 +01:00
|
|
|
using Glib::Module;
|
2006-02-22 23:57:32 +01:00
|
|
|
|
2006-02-25 13:21:30 +01:00
|
|
|
std::string pyloader_path = Module::build_path(MODDIR, "pyloader");
|
|
|
|
Glib::Module pyloader(pyloader_path);
|
|
|
|
assert(pyloader);
|
|
|
|
|
2006-02-23 12:29:25 +01:00
|
|
|
Glib::thread_init();
|
|
|
|
|
2006-02-22 23:57:32 +01:00
|
|
|
// 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);
|
2006-02-23 12:29:25 +01:00
|
|
|
|
2006-02-25 13:21:30 +01:00
|
|
|
Scheduler::get_instance(); // Forces initialization of scheduler.
|
|
|
|
// Cross fingers (depends if PythonPolicyManager
|
|
|
|
// static object has been initialized before?).
|
|
|
|
|
2006-02-23 12:29:25 +01:00
|
|
|
//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();
|
2006-02-24 11:07:47 +01:00
|
|
|
text_sim.run();
|
|
|
|
exit(0);
|
2006-02-21 23:57:14 +01:00
|
|
|
}
|