- Added draft of test code for Frontend Unit testing
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@510 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
6a0bf4f444
commit
8afcc2edbb
|
@ -0,0 +1,136 @@
|
||||||
|
// src/testsuite/test-parse_command.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 parseCommand method in the
|
||||||
|
* classTextSimulation class and the StandardIO class. */
|
||||||
|
|
||||||
|
#include "backend/standard_io.hh"
|
||||||
|
#include "backend/text_simulation.hh"
|
||||||
|
#include "backend/templates/smartp.hh"
|
||||||
|
|
||||||
|
#include <glibmm/module.h>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "gettext.h"
|
||||||
|
|
||||||
|
#include "glibmm/ustring.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "slice.hh"
|
||||||
|
#include "observed_subject.hh"
|
||||||
|
#include "schedulable_list.hh"
|
||||||
|
#include "schedulable_status.hh"
|
||||||
|
#include "../templates/smartp.hh"
|
||||||
|
|
||||||
|
namespace sgpem
|
||||||
|
{
|
||||||
|
|
||||||
|
/* History stub: every public method does nothing except printing
|
||||||
|
in std::cout the signature and the parameters. */
|
||||||
|
|
||||||
|
class History;
|
||||||
|
|
||||||
|
class SG_DLLEXPORT History : public ObservedSubject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time)
|
||||||
|
{
|
||||||
|
std::cout << "get_scheduled_at" << time;
|
||||||
|
}
|
||||||
|
memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const
|
||||||
|
{
|
||||||
|
std::cout << "get_simulation_status_at" << time;
|
||||||
|
}
|
||||||
|
int get_current_time() const
|
||||||
|
{
|
||||||
|
std::cout << "getCurrentTime";
|
||||||
|
}
|
||||||
|
void enqueue_slice(const sgpem::SchedulableList& status)
|
||||||
|
{
|
||||||
|
std::cout << "enqueue_slice";
|
||||||
|
}
|
||||||
|
void truncate_at(int instant)
|
||||||
|
{
|
||||||
|
std::cout << "TruncateAt" << instant;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following method is not used by the user interface
|
||||||
|
|
||||||
|
static History& get_instance();
|
||||||
|
};
|
||||||
|
|
||||||
|
}//~ namespace sgpem
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char** argv) {
|
||||||
|
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.
|
||||||
|
// Cross fingers (depends if PythonPolicyManager
|
||||||
|
// static object has been initialized before?).
|
||||||
|
|
||||||
|
//the textual simulation
|
||||||
|
TextSimulation text_sim;
|
||||||
|
History::get_instance().attach(&text_sim);
|
||||||
|
|
||||||
|
//textual IO
|
||||||
|
memory::smart_ptr<IOManager> io(new StandardIO());
|
||||||
|
text_sim.add_io_device(io);
|
||||||
|
text_sim.update();
|
||||||
|
text_sim.run();
|
||||||
|
exit(0);
|
||||||
|
}
|
Loading…
Reference in New Issue