- Merged branch 0.3-r556--SPLIT_PYLOADER_CONFIG back into trunk
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@561 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
c6d4f5fd27
commit
51f0d7fbe7
36 changed files with 849 additions and 48 deletions
20
plugins/pyloader/testsuite/python_loader_configure.py
Normal file
20
plugins/pyloader/testsuite/python_loader_configure.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
class python_loader_configure(Policy) :
|
||||
def __init__(self):
|
||||
pass;
|
||||
|
||||
def configure(self):
|
||||
print "[II] Entering willingly an endless loop."
|
||||
while True:
|
||||
pass
|
||||
|
||||
def is_preemptive(self):
|
||||
return False
|
||||
|
||||
def get_time_slice(self):
|
||||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
pass
|
21
plugins/pyloader/testsuite/python_loader_get_time_slice.py
Normal file
21
plugins/pyloader/testsuite/python_loader_get_time_slice.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
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):
|
||||
print "[II] Entering willingly an endless loop."
|
||||
while True:
|
||||
pass
|
||||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
pass
|
21
plugins/pyloader/testsuite/python_loader_is_preemptive.py
Normal file
21
plugins/pyloader/testsuite/python_loader_is_preemptive.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
class python_loader_is_preemptive(Policy) :
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
||||
def is_preemptive(self):
|
||||
print "[II] Entering willingly an endless loop."
|
||||
while True:
|
||||
pass
|
||||
return False
|
||||
|
||||
def get_time_slice(self):
|
||||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
pass
|
20
plugins/pyloader/testsuite/python_loader_sort_queue.py
Normal file
20
plugins/pyloader/testsuite/python_loader_sort_queue.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
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):
|
||||
print "[II] Entering willingly an endless loop."
|
||||
while True:
|
||||
pass
|
112
plugins/pyloader/testsuite/test-python_loader.cc
Normal file
112
plugins/pyloader/testsuite/test-python_loader.cc
Normal file
|
@ -0,0 +1,112 @@
|
|||
// 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 "../python_policy_manager.hh"
|
||||
#include "../python_policy.hh"
|
||||
#include "global_settings.hh"
|
||||
#include "schedulable_list.hh"
|
||||
#include "scheduler.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
|
||||
#include <Python.h>
|
||||
#include <glibmm/module.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// FIXME: Eeeeh? Why does this work without explicit namespace resolving?
|
||||
// Is there some using declaration in included HEADERS?? Aaaaagh!
|
||||
|
||||
class TestPythonPolicyManager : public PythonPolicyManager {
|
||||
public:
|
||||
void test_init(const char* policy_name) {
|
||||
init();
|
||||
_python_policy = std::auto_ptr<PythonPolicy>(new PythonPolicy(policy_name));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
// Add argv[1] as the directory to search for uninstalled policies
|
||||
sgpem::GlobalSettings::instance().add_policies_dir(argv[1]);
|
||||
|
||||
// Self-register itself to Scheduler, however we don't care about it
|
||||
TestPythonPolicyManager polman;
|
||||
|
||||
try
|
||||
{
|
||||
polman.test_init("python_loader_configure");
|
||||
polman.get_policy().configure();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
{
|
||||
cout << "configure: Caught UserInterruptException" << endl;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
polman.test_init("python_loader_is_preemptive");
|
||||
polman.get_policy().is_pre_emptive();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
{
|
||||
cout << "is_preemptive: Caught UserInterruptException" << endl;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue