sgpemv2/src/testsuite/test-python_loader.cc

84 lines
2.6 KiB
C++
Raw Normal View History

// 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"
#include "backend/process.hh"
#include "backend/schedulable_status.hh"
#include "backend/schedulable_list.hh"
#include "backend/scheduler.hh"
#include "standard_io.hh"
#include "start_gui.hh"
#include "text_simulation.hh"
#include "templates/smartp.hh"
#include <cassert>
int
main(int argc, char** argv) {
using namespace sgpem;
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);
PythonPolicyManager* ppm = PythonPolicyManager::get_instance();
ppm->init();
Policy& pol = ppm->get_policy();
Scheduler::get_instance().set_policy(&pol);
//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();
//grafical IO
start_gui(argc, argv, text_sim);
}