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. */
|
|
|
|
|
2006-04-06 21:01:13 +02:00
|
|
|
#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"
|
2006-02-23 12:29:25 +01:00
|
|
|
|
2006-03-08 17:47:39 +01:00
|
|
|
#include <Python.h>
|
2006-02-25 13:21:30 +01:00
|
|
|
#include <glibmm/module.h>
|
|
|
|
|
2006-02-22 23:57:32 +01:00
|
|
|
#include <cassert>
|
2006-03-09 11:49:41 +01:00
|
|
|
#include <iostream>
|
2006-02-25 13:21:30 +01:00
|
|
|
#include <string>
|
2006-02-21 23:57:14 +01:00
|
|
|
|
2006-03-09 11:49:41 +01:00
|
|
|
// FIXME: Eeeeh? Why does this work without explicit namespace resolving?
|
|
|
|
// Is there some using declaration in included HEADERS?? Aaaaagh!
|
|
|
|
|
2006-03-08 17:47:39 +01:00
|
|
|
class TestPythonPolicyManager : public PythonPolicyManager {
|
|
|
|
public:
|
|
|
|
void test_init(const char* policy_name) {
|
|
|
|
init();
|
|
|
|
_python_policy = std::auto_ptr<PythonPolicy>(new PythonPolicy(policy_name));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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-03-09 23:20:55 +01:00
|
|
|
using namespace std;
|
|
|
|
|
2006-03-09 11:49:41 +01:00
|
|
|
if(argc != 2) {
|
|
|
|
std::cout << "[EE] Usage:\n\t" << argv[0] <<
|
|
|
|
" path/to/uninstalled/policies" << std::endl;
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
else
|
2006-03-09 22:56:16 +01:00
|
|
|
// Add argv[1] as the directory to search for uninstalled policies
|
2006-03-09 11:49:41 +01:00
|
|
|
sgpem::GlobalSettings::instance().add_policies_dir(argv[1]);
|
2006-03-09 23:20:55 +01:00
|
|
|
|
|
|
|
// Self-register itself to Scheduler, however we don't care about it
|
2006-03-08 17:47:39 +01:00
|
|
|
TestPythonPolicyManager polman;
|
|
|
|
|
2006-03-09 23:20:55 +01:00
|
|
|
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;
|
|
|
|
}
|
2006-03-08 17:47:39 +01:00
|
|
|
|
2006-03-09 23:20:55 +01:00
|
|
|
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;
|
|
|
|
}
|
2006-03-08 17:47:39 +01:00
|
|
|
|
|
|
|
|
2006-03-09 23:20:55 +01:00
|
|
|
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;
|
|
|
|
}
|
2006-03-08 17:47:39 +01:00
|
|
|
|
2006-02-24 11:07:47 +01:00
|
|
|
exit(0);
|
2006-02-21 23:57:14 +01:00
|
|
|
}
|