- Fix compilation of test-history

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@515 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-03-09 11:37:09 +00:00
parent 92e6f3be2b
commit 0c2cba8bbe
6 changed files with 169 additions and 98 deletions

View File

@ -1,3 +1,46 @@
2006-03-09 10:49 tchernobog
* trunk/Makefile.am, trunk/src/backend/global_settings.cc,
trunk/src/backend/global_settings.hh,
trunk/src/backend/pyloader/python_policy_manager.cc,
trunk/src/builtin-policies/fcfs.py,
trunk/src/builtin-policies/sjf.py, trunk/src/main.cc,
trunk/src/parse_opts.cc,
trunk/src/testsuite/test-python_loader.cc: - Add copyright notices
to existing builtin python policies - Implement system to
dinamically pass plugins and policies search paths to the sgpemv2
binary and tests (class GlobalSettings) - Drastically reduce usage
of hardcoded paths in code except as default overridable values
2006-03-09 05:19 matrevis
* trunk/src/testsuite/test-history.cc,
trunk/src/testsuite/test-stepforward.cc: - added some test drafts
2006-03-08 16:57 matrevis
* trunk/src/testsuite/test-parse_command.cc: - Added draft of test
code for Frontend Unit testing
2006-03-08 16:47 tchernobog
* trunk/ChangeLog, trunk/Makefile.am,
trunk/src/backend/pyloader/python_policy.hh,
trunk/src/backend/pyloader/python_policy_manager.cc,
trunk/src/backend/pyloader/python_policy_manager.hh,
trunk/src/main.cc, trunk/src/testsuite/python_loader_configure.py,
trunk/src/testsuite/python_loader_get_time_slice.py,
trunk/src/testsuite/python_loader_is_preemptive.py,
trunk/src/testsuite/python_loader_sort_queue.py,
trunk/src/testsuite/test-python_loader.cc: - Give facelift to
test_loader. Still to be finished.
2006-03-08 15:50 johnny
* trunk/config/libtool-labunipd-sgpemfix.patch: - How to spend two
hours tracking a bug of Unipd's laboratory broken distribution
(how fscking unbelievable!)
2006-03-08 12:49 tchernobog 2006-03-08 12:49 tchernobog
* trunk/src/templates/smartp.hh, trunk/src/templates/smartp.tcc: - * trunk/src/templates/smartp.hh, trunk/src/templates/smartp.tcc: -

View File

@ -324,7 +324,35 @@ policies_PYTHON = \
# DEJATOOL = src/testsuite/example-test.exp # DEJATOOL = src/testsuite/example-test.exp
noinst_PROGRAMS = src/testsuite/test-python_loader noinst_PROGRAMS = \
src/testsuite/test-history \
src/testsuite/test-python_loader
# disable :
# src/testsuite/test-parse_command
# src/testsuite/test-stepforward
src_testsuite_test_history_CPPFLAGS = \
-I@top_srcdir@/src \
$(GLIBMM_CFLAGS)
src_testsuite_test_history_LDFLAGS = \
src/backend/libbackend.la \
$(GLIBMM_LIBS)
src_testsuite_test_history_SOURCES = \
src/testsuite/test-history.cc
#src_testsuite_test_parse_command_CPPFLAGS = \
# -I@top_srcdir@/src \
# $(GLIBMM_CFLAGS)
#src_testsuite_test_parse_command_LDFLAGS = \
# src/backend/libbackend.la \
# $(GLIBMM_LIBS)
#src_testsuite_test_parse_command_SOURCES = \
# src/testsuite/test-parse_command.cc
src_testsuite_test_python_loader_CPPFLAGS = \ src_testsuite_test_python_loader_CPPFLAGS = \
-I@top_srcdir@/src \ -I@top_srcdir@/src \
@ -336,7 +364,7 @@ src_testsuite_test_python_loader_DEPENDENCIES = \
src_testsuite_test_python_loader_LDFLAGS = \ src_testsuite_test_python_loader_LDFLAGS = \
src/backend/libbackend.la \ src/backend/libbackend.la \
src/backend/pyloader/libpyloader.la \ src/backend/pyloader/libpyloader.la \
$(GTKMM_LIBS) $(GTHREAD_LIBS) $(GLIBMM_LIBS) $(GTHREAD_LIBS)
src_testsuite_test_python_loader_SOURCES = \ src_testsuite_test_python_loader_SOURCES = \
src/testsuite/test-python_loader.cc \ src/testsuite/test-python_loader.cc \
src/standard_io.cc \ src/standard_io.cc \
@ -349,6 +377,21 @@ noinst_PYTHON += src/testsuite/python_loader_configure.py \
src/testsuite/python_loader_is_preemptive.py \ src/testsuite/python_loader_is_preemptive.py \
src/testsuite/python_loader_get_time_slice.py src/testsuite/python_loader_get_time_slice.py
# advice: get dummy_policy from the somewhere in the repository, and compile it in.
#src_testsuite_test_stepforward_CPPFLAGS = \
# -I@top_srcdir@/src \
# $(GLIBMM_CFLAGS)
#src_testsuite_test_stepforward_LDFLAGS = \
# src/backend/libbackend.la \
# $(GLIBMM_LIBS)
#src_testsuite_test_stepforward_SOURCES = \
# src/testsuite/test-stepforward.cc
# Workaround an automake bug that leaves behind some files # Workaround an automake bug that leaves behind some files
# while it's finishing the distcheck target # while it's finishing the distcheck target
CLEANFILES += src/testsuite/.libs/test-python_loader CLEANFILES += \
src/testsuite/.libs/test-python_loader \
src/testsuite/.libs/test-history

View File

@ -24,13 +24,13 @@ using namespace sgpem;
using namespace memory; using namespace memory;
//History::instance; //static object //History::instance; //static object
History History::_instance(10); //dummy parameter History* History::_instance = 0;
/** /**
The constructor sets _total_time_elapsed to -1: this permits to insert the INITIAL STATUS The constructor sets _total_time_elapsed to -1: this permits to insert the INITIAL STATUS
of the simulation which must begin at instant -1 and live for 1 instant. of the simulation which must begin at instant -1 and live for 1 instant.
*/ */
History::History(int) //private constructor. The parameter is discarded History::History() //private constructor. The parameter is discarded
:_total_time_elapsed(-1) :_total_time_elapsed(-1)
{} {}
@ -38,7 +38,9 @@ History::History(int) //private constructor. The parameter is discarded
History& History&
History::get_instance() History::get_instance()
{ {
return _instance; if(!_instance)
_instance = new History();
return *_instance;
} }

View File

@ -55,32 +55,32 @@ namespace sgpem
\param time The inquired time instant. \param time The inquired time instant.
\return The Schedulable object running at the given time. \return The Schedulable object running at the given time.
*/ */
memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time) const; virtual memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time) const;
/** /**
Gets the status of simulation at the specified time. Gets the status of simulation at the specified time.
\param time The inquired time instant. \param time The inquired time instant.
\return The list of Schedulable status objects at the specified time. \return The list of Schedulable status objects at the specified time.
*/ */
memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const; virtual memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const;
/** /**
Gets the current time. Gets the current time.
\return The current history time. \return The current history time.
*/ */
int get_current_time() const; virtual int get_current_time() const;
/** /**
Sets the status of simulation at the current time. Sets the status of simulation at the current time.
\param status The list of \ref Schedulable status objects at the current time. \param status The list of \ref Schedulable status objects at the current time.
*/ */
void enqueue_slice(const sgpem::SchedulableList& status); virtual void enqueue_slice(const sgpem::SchedulableList& status);
/** /**
Remove all data in History following the specified time. Remove all data in History following the specified time.
\param instant Desired cutting time. \param instant Desired cutting time.
*/ */
void truncate_at(int instant); virtual void truncate_at(int instant);
/** /**
@ -89,9 +89,11 @@ namespace sgpem
*/ */
static History& get_instance(); static History& get_instance();
protected:
History(); //private constructor. The parameter is discarded
static History* _instance;
private: private:
History(int); //private constructor. The parameter is discarded
static History _instance;
int _total_time_elapsed; int _total_time_elapsed;
std::vector<sgpem::Slice> _slices; std::vector<sgpem::Slice> _slices;
}; };

View File

@ -36,6 +36,7 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include "backend/history.hh"
#include "backend/process.hh" #include "backend/process.hh"
#include "backend/slice.hh" #include "backend/slice.hh"
#include "backend/observed_subject.hh" #include "backend/observed_subject.hh"
@ -43,16 +44,15 @@
#include "backend/schedulable_status.hh" #include "backend/schedulable_status.hh"
#include "templates/smartp.hh" #include "templates/smartp.hh"
using namespace sgpem;
using namespace std;
class HistoryTester class HistoryTester
{ {
public:
public: HistoryTester(SchedulableList sl)
: _history_length(-1), _internal_schedulable_list(sl)
HistoryTester(SchedulableList sl) : _history_length(-1), _internal_schedulable_list(sl) {}
{
}
/** this method gets a sequence of operations as a parameter and performs them /** this method gets a sequence of operations as a parameter and performs them
* checking for incongruences. * checking for incongruences.
@ -63,17 +63,17 @@ class HistoryTester
// prints the test sequence // prints the test sequence
std::cout << commands_sequence << endl; std::cout << commands_sequence << endl;
// executes the test sequence // executes the test sequence
for (int i = 0; i < commands_sequence.length() && i < 400; i++) for (unsigned int i = 0; i < commands_sequence.length() && i < 400; i++)
{ {
switch(commands_sequence[i]) switch(commands_sequence[i])
{ {
case E: case 'E':
_insert(_internal_schedulable_list); _insert(_internal_schedulable_list);
break; break;
case R: case 'R':
_randomize(_internal_schedulable_list); _randomize(_internal_schedulable_list);
break; break;
case T: case 'T':
_truncate(); _truncate();
break; break;
default: default:
@ -103,11 +103,11 @@ class HistoryTester
for (int i = 0; i <= _history_length; i++) for (int i = 0; i <= _history_length; i++)
{ {
// watch out here, it's if (NOT ...) operator != was not available. // watch out here, it's if (NOT ...) operator != was not available.
if (!(History::get_instance().get_simulation_status_at(i) == *_get_simulation_status_at[i])) if (!(*History::get_instance().get_simulation_status_at(i) == *_get_simulation_status_at[i]))
{ {
std::cout << "get_simulation_status_at"; std::cout << "get_simulation_status_at";
} }
if (History::get_instance().get_scheduled_at(i) != *_get_scheduled_at[i]) if (!(*History::get_instance().get_scheduled_at(i) == *_get_scheduled_at[i]))
{ {
std::cout << "get_simulation_status_at"; std::cout << "get_simulation_status_at";
} }
@ -120,8 +120,8 @@ class HistoryTester
History::get_instance().enqueue_slice(status); History::get_instance().enqueue_slice(status);
_history_length = _history_length + 1; _history_length = _history_length + 1;
// I hope the copy constructor is available.. // I hope the copy constructor is available..
_get_simulation_status_at[history_length] = new SchedulableList(status); _get_simulation_status_at[_history_length] = new SchedulableList(status);
_get_scheduled_at[history_length] = new SchedulableStatus(*(status.top())); _get_scheduled_at[_history_length] = new SchedulableStatus(*(status.top()));
return; return;
} }
@ -140,34 +140,35 @@ class HistoryTester
status.swap(9, 4); status.swap(9, 4);
status.swap(4, 5); status.swap(4, 5);
status.swap(7, 1); status.swap(7, 1);
for (int i = 0; i <= status.size(); i++) for (unsigned int i = 0; i <= status.size(); i++)
{ {
status.get_item_at(i).give_cpu_time(1); // FIXME: These methods aren't implemented!!
status.get_item_at(i).set_last_scheduled(_history_length); //status.get_item_at(i).give_cpu_time(1);
status.get_item_at(i).set_state(1<<(i%4)); //status.get_item_at(i).set_last_scheduled(_history_length);
//status.get_item_at(i).set_state(1<<(i%4));
} }
return; return;
} }
void _truncate() void _truncate()
{ {
delete _get_simulation_status_at[history_length] delete _get_simulation_status_at[_history_length];
delete _get_scheduled_at[history_length] delete _get_scheduled_at[_history_length];
_history_length = _history_length - 1; _history_length = _history_length - 1;
History::get_instance().truncate_at(history_length); History::get_instance().truncate_at(_history_length);
return; return;
} }
} };
int int
main(int argc, char** argv) { main(int argc, char** argv)
{
using namespace sgpem; using namespace sgpem;
using Glib::Module; using Glib::Module;
std::string command(ERERERT); // the sequence of commands to test std::string command("ERERERT"); // the sequence of commands to test
// sets up the test data // sets up the test data
Process p1("P1", 1,5,1); Process p1("P1", 1,5,1);

View File

@ -21,11 +21,9 @@
/* This executable tests for workingness of the parseCommand method in the /* This executable tests for workingness of the parseCommand method in the
* classTextSimulation class and the StandardIO class. */ * classTextSimulation class and the StandardIO class. */
#include "backend/standard_io.hh" #include "standard_io.hh"
#include "backend/text_simulation.hh" #include "text_simulation.hh"
#include "backend/templates/smartp.hh" #include "templates/smartp.hh"
#include <glibmm/module.h>
#include <cassert> #include <cassert>
#include <string> #include <string>
@ -38,94 +36,76 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include "slice.hh" #include "backend/process.hh"
#include "observed_subject.hh" #include "backend/slice.hh"
#include "schedulable_list.hh" #include "backend/observed_subject.hh"
#include "schedulable_status.hh" #include "backend/schedulable_list.hh"
#include "../templates/smartp.hh" #include "backend/schedulable_status.hh"
namespace sgpem namespace sgpem
{ {
/* History stub: every public method does nothing except printing /* History stub: every public method does nothing except printing
in std::cout the signature and the parameters. */ in std::cout the signature and the parameters. */
class History; class TestHistory : public History
class SG_DLLEXPORT History : public ObservedSubject
{ {
public: public:
memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time) memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time)
{ {
std::cout << "get_scheduled_at" << time; std::cout << "get_scheduled_at" << time;
return History::get_scheduled_at(time);
} }
memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const
{ {
std::cout << "get_simulation_status_at" << time; std::cout << "get_simulation_status_at" << time;
return History::get_simulation_status_at(time);
} }
int get_current_time() const int get_current_time() const
{ {
std::cout << "getCurrentTime"; std::cout << "getCurrentTime";
return History::get_current_time();
} }
void enqueue_slice(const sgpem::SchedulableList& status) void enqueue_slice(const sgpem::SchedulableList& status)
{ {
std::cout << "enqueue_slice"; std::cout << "enqueue_slice";
History::enqueue_slice(status);
} }
void truncate_at(int instant) void truncate_at(int instant)
{ {
std::cout << "TruncateAt" << instant; std::cout << "TruncateAt" << instant;
History::truncate_at(instant);
} }
// The following method is not used by the user interface // The following method is not used by the user interface
static History& get_instance(); static History& get_instance();
private:
static TestHistory* _instance;
}; };
TestHistory* TestHistory::_instance = 0;
History&
TestHistory::get_instance()
{
if(!_instance)
_instance = new TestHistory();
return *_instance;
}
}//~ namespace sgpem }//~ namespace sgpem
int int
main(int argc, char** argv) { main(int, char**) {
using namespace sgpem; using namespace sgpem;
using Glib::Module;
std::string pyloader_path = Module::build_path(MODDIR, "pyloader");
Glib::Module pyloader(pyloader_path);
assert(pyloader);
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);
Scheduler::get_instance(); // Forces initialization of scheduler. Scheduler::get_instance(); // Forces initialization of scheduler.
// Cross fingers (depends if PythonPolicyManager // Cross fingers (depends if PythonPolicyManager
// static object has been initialized before?). // static object has been initialized before?).
//the textual simulation //initialize history
TextSimulation text_sim; TestHistory::get_instance();
History::get_instance().attach(&text_sim);
//textual IO //textual IO
memory::smart_ptr<IOManager> io(new StandardIO()); memory::smart_ptr<IOManager> io(new StandardIO());