// 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/pyloader/python_policy.hh" #include "backend/process.hh" #include "backend/schedulable_status.hh" #include "backend/schedulable_list.hh" #include "backend/scheduler.hh" #include "standard_io.hh" #include "text_simulation.hh" #include "templates/smartp.hh" #include #include #include #include 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(new PythonPolicy(policy_name)); } }; int main(int argc, char** argv) { using namespace sgpem; using Glib::Module; 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 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); }