- Fix compilation of test-python_loader (which doesn't f*ckin' work).
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@781 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
984d390f3f
commit
95ef5eba53
|
@ -25,8 +25,10 @@
|
|||
#include "../python_policy_manager.hh"
|
||||
#include "../python_policy.hh"
|
||||
|
||||
#include "simulation.hh"
|
||||
#include "global_preferences.hh"
|
||||
#include "ready_queue.hh"
|
||||
#include "policies_gatekeeper.hh"
|
||||
#include "simulation.hh"
|
||||
#include "scheduler.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
|
||||
|
@ -37,51 +39,59 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// FIXME: Eeeeh? Why does this work without explicit namespace resolving?
|
||||
// Is there some using declaration in included HEADERS?? Aaaaagh!
|
||||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
class TestPythonPolicyManager : public PythonPolicyManager
|
||||
static Policy*
|
||||
find_pol_by_name(const vector<Policy*>& pols, const Glib::ustring& name)
|
||||
{
|
||||
public:
|
||||
void test_init(const char* policy_name)
|
||||
{
|
||||
init();
|
||||
_python_policy = new PythonPolicy(policy_name);
|
||||
|
||||
}
|
||||
|
||||
Policy& get_policy()
|
||||
{
|
||||
return *_python_policy;
|
||||
}
|
||||
};
|
||||
vector<Policy*>::const_iterator it = pols.begin();
|
||||
for( ; it != pols.end(); it++)
|
||||
if((*it)->get_name() == name)
|
||||
return *it;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
int successes = 0;
|
||||
|
||||
if(argc != 2)
|
||||
{
|
||||
std::cout << "[EE] Usage:\n\t" << argv[0] <<
|
||||
" path/to/uninstalled/policies" << std::endl;
|
||||
" path/to/uninstalled/test/policies" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
// Add argv[1] as the directory to search for uninstalled policies
|
||||
sgpem::GlobalPreferences::get_instance().add_policies_dir(argv[1]);
|
||||
|
||||
// Self-register itself to Scheduler, however we don't care about it
|
||||
TestPythonPolicyManager polman;
|
||||
// Self-register itself to PoliciesGatekeeper, however we don't care about it
|
||||
PythonPolicyManager polman;
|
||||
|
||||
Simulation& sim = Simulation::get_instance();
|
||||
History& his = sim.get_history();
|
||||
PoliciesGatekeeper& pgk = PoliciesGatekeeper::get_instance();
|
||||
|
||||
const std::vector<Policy*>& policies = polman.get_avail_policies();
|
||||
|
||||
// Print out avail policies
|
||||
cout << "These are the policies I found:" << endl;
|
||||
vector<Policy*>::const_iterator it = policies.begin();
|
||||
for(; it != policies.end(); it++)
|
||||
cout << "\t * " << (*it)->get_name() << endl;
|
||||
|
||||
try
|
||||
{
|
||||
polman.test_init("python_loader_configure");
|
||||
polman.get_policy().configure();
|
||||
Policy* pol = find_pol_by_name(policies, "python_loader_configure");
|
||||
assert(pol != NULL);
|
||||
|
||||
// FIXME : Maybe activating a policy only to configure it is an overkill?
|
||||
// Who gives a fuck about it?
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->configure();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
{
|
||||
|
@ -92,8 +102,10 @@ main(int argc, char** argv)
|
|||
|
||||
try
|
||||
{
|
||||
polman.test_init("python_loader_is_preemptive");
|
||||
polman.get_policy().is_pre_emptive();
|
||||
Policy* pol = find_pol_by_name(policies, "python_loader_is_preemptive");
|
||||
assert(pol != NULL);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->is_pre_emptive();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
{
|
||||
|
@ -101,10 +113,13 @@ main(int argc, char** argv)
|
|||
successes++;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
polman.test_init("python_loader_get_time_slice");
|
||||
polman.get_policy().get_time_slice();
|
||||
Policy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
|
||||
assert(pol != NULL);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->get_time_slice();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
{
|
||||
|
@ -113,11 +128,13 @@ main(int argc, char** argv)
|
|||
}
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
ReadyQueue sl;
|
||||
polman.test_init("python_loader_sort_queue");
|
||||
polman.get_policy().sort_queue();
|
||||
Policy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
|
||||
assert(pol != NULL);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->sort_queue();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ using memory::smart_ptr;
|
|||
|
||||
|
||||
// ---------------
|
||||
// For all your evil-doers on Earth, this is your punishment!
|
||||
// For all you evil-doers on Earth, this is your mighty punishment!
|
||||
|
||||
template<typename T>
|
||||
static bool deep_remove(std::vector<T*>& v, const T& obj)
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "policies_gatekeeper.hh"
|
||||
#include <glibmm/timer.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "smartp.tcc"
|
||||
|
||||
using namespace std;
|
||||
|
|
Loading…
Reference in New Issue