|
From: <ma...@us...> - 2012-01-18 02:25:43
|
Revision: 1294
http://scstudio.svn.sourceforge.net/scstudio/?rev=1294&view=rev
Author: madzin
Date: 2012-01-18 02:25:36 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
Fix bug in find flow algorithm. Algorithm crashed when the diff part should work with coregion. The functionality was not added but a message is printed to the user (Diff is not available).
Modified Paths:
--------------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/membership_alg.cpp
trunk/src/membership/membership_base.h
trunk/tests/diff/CMakeLists.txt
trunk/tests/diff/TODO
Added Paths:
-----------
trunk/tests/diff/coregion.mpr
trunk/tests/diff/coregion_flow.mpr
trunk/tests/diff/coregion_flow.mpr.result
trunk/tests/diff/flow12_2.mpr.result2
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2012-01-16 18:07:50 UTC (rev 1293)
+++ trunk/src/membership/diff_impl.cpp 2012-01-18 02:25:36 UTC (rev 1294)
@@ -73,7 +73,7 @@
* parameters: a - specification
* b - flow
*/
-MscPtr MembershipAlg::diff(MscPtr specification, std::vector<MscPtr>& msc_flows)
+MscPtr MembershipAlg::diff(MembershipContext* c, MscPtr specification, std::vector<MscPtr>& msc_flows)
{
if(msc_flows.size() > 1)
{
@@ -97,8 +97,6 @@
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc> (specification);
- MembershipContext* c = new MembershipContext();
- c->set_mem(this);
c->set_diff_type(MESSAGE);
BMscPtr result = NULL;
@@ -112,12 +110,16 @@
else
result = bmsc_bmsc_diff(c, bmsc, flow);
- delete c;
return result;
}
-//Instance "a" - flow
-//Instance "b" - specification
+/*
+ Instance "a" - flow
+ Instance "b" - specification
+
+ Method can return NULL in case the specification contains coregion,
+ could be recognized by MembershipContext attribute.
+*/
DifferencePtr instance_diff(MembershipContext* c, InstancePtr a, InstancePtr b)
{
std::vector<StrictEventPtr> a_ordering;
@@ -128,6 +130,15 @@
EventAreaPtr a_area = a->get_first();
EventAreaPtr b_area = b->get_first();
+ CoregionAreaPtr a_ca = boost::dynamic_pointer_cast<CoregionArea > (a_area);
+ CoregionAreaPtr b_ca = boost::dynamic_pointer_cast<CoregionArea > (b_area);
+
+ if(a_ca != NULL || b_ca != NULL)
+ {
+ c->spec_contain_coregion();
+ return NULL;
+ }
+
StrictOrderAreaPtr a_soa = boost::dynamic_pointer_cast<StrictOrderArea > (a_area);
StrictOrderAreaPtr b_soa = boost::dynamic_pointer_cast<StrictOrderArea > (b_area);
@@ -315,6 +326,43 @@
while (event_a != NULL && event_b != NULL && event_comparison(c, event_a, event_b))
{
+ //check the coregion area in flow
+ if(event_a->get_successor() == NULL)
+ {
+ EventAreaPtr next_area = event_a->get_area()->get_next();
+ CoregionAreaPtr next_ca = boost::dynamic_pointer_cast<CoregionArea>(next_area);
+
+ if(next_ca != NULL)
+ throw std::runtime_error("Flow contains coregion");
+
+ StrictOrderAreaPtr next_soa = boost::dynamic_pointer_cast<StrictOrderArea>(next_area);
+
+ //this would never happen due to there is no reason to have string order
+ //area after another string order area.
+ if(next_soa != NULL)
+ throw std::runtime_error("Unexpected behaviour");
+ }
+
+ //check the coregion area in specification
+ if(event_b->get_successor() == NULL)
+ {
+ EventAreaPtr next_area = event_b->get_area()->get_next();
+ CoregionAreaPtr next_ca = boost::dynamic_pointer_cast<CoregionArea>(next_area);
+
+ if(next_ca != NULL)
+ {
+ c->spec_contain_coregion();
+ return NULL;
+ }
+
+ StrictOrderAreaPtr next_soa = boost::dynamic_pointer_cast<StrictOrderArea>(next_area);
+
+ //this would never happen due to there is no reason to have string order
+ //area after another string order area.
+ if(next_soa != NULL)
+ throw std::runtime_error("Unexpected behaviour");
+ }
+
event_a = event_a->get_successor();
event_b = event_b->get_successor();
row++;
@@ -912,6 +960,14 @@
//when some instance of the specification is not contained in the flow
if(!flow_found)
{
+ CoregionAreaPtr spec_ca = boost::dynamic_pointer_cast<CoregionArea> ((*spec_it)->get_first());
+
+ if(spec_ca != NULL)
+ {
+ c->spec_contain_coregion();
+ return NULL;
+ }
+
StrictOrderAreaPtr s_e_a = boost::dynamic_pointer_cast<StrictOrderArea> ((*spec_it)->get_first());
StrictEventPtr s_e = s_e_a==NULL ? NULL : s_e_a->get_first();
DifferencePtr old_diff = NULL;
@@ -946,6 +1002,9 @@
//when the instance of proper name was found in both MSCs (specification, flow)
DifferencePtr diff = instance_diff(c, *flow_it, *spec_it);
+ if(c->get_spec_contain_coregion())
+ return NULL;
+
if(diff != NULL)
diff_map.insert(std::make_pair((*flow_it)->get_label(), diff));
}
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2012-01-16 18:07:50 UTC (rev 1293)
+++ trunk/src/membership/membership_alg.cpp 2012-01-18 02:25:36 UTC (rev 1294)
@@ -158,8 +158,23 @@
std::vector<MscPtr> flows;
flows.push_back(bmsc_f);
- result = diff(bmsc, flows);
+ result = diff(c, bmsc, flows);
+ //print an error in case the specification contains coregion
+ if(c->get_spec_contain_coregion())
+ {
+ std::wstring msg = L"Flow \"" + bmsc_f->get_label() + L"\" not found";
+
+ msg += L".\n";
+ msg += L"Diff is not available (due to a coregion in the specification).";
+
+ print_report(RS_ERROR, msg);
+
+ c->clear_attributed_events();
+ delete c;
+ return NULL;
+ }
+
if(result != NULL)
{
std::wstring message;
@@ -221,7 +236,7 @@
}
}
- print_report(RS_ERROR, L"Find flow algorithm cannot recognize an MSC type of specification.");
+ print_report(RS_ERROR, L"Find flow algorithm cannot recognize an MSC type of the specification.");
return NULL;
}
@@ -630,6 +645,8 @@
bool coregion_strict(MembershipContext* c, std::vector<Event*>& node_events, std::vector<Event*>& b_events,
enum check_type type)
{
+ c->spec_contain_coregion();
+
if(type == receive_ordering)
return coregion_strict_receive_ordering(c, node_events, b_events);
Modified: trunk/src/membership/membership_base.h
===================================================================
--- trunk/src/membership/membership_base.h 2012-01-16 18:07:50 UTC (rev 1293)
+++ trunk/src/membership/membership_base.h 2012-01-18 02:25:36 UTC (rev 1294)
@@ -276,6 +276,7 @@
std::vector<std::pair<TimeConstraintPtr, HMscNodePtr> > not_full_covered_intervals; //! intervals in specification which are not full covered
std::stack<HMscNodePtr> path; //! store information about the path if the flow meets the specification
bool print_path; //! store whether the path will be printed
+ bool contain_spec_coregion; //! store whether the specification contains coregion
MembershipResultPtr result;
@@ -296,6 +297,7 @@
{
max_id = 0;
print_path = true;
+ contain_spec_coregion = false;
diff_type = NOT_DIFF;
checking_time_mode = NO_TIME;
result = NULL;
@@ -558,6 +560,16 @@
return print_path;
}
+ void spec_contain_coregion(bool value=true)
+ {
+ contain_spec_coregion = value;
+ }
+
+ bool get_spec_contain_coregion()
+ {
+ return contain_spec_coregion;
+ }
+
//TODO upravit aby nedochadzalo k tolkemu kopirovaniu
void update_result()
{
@@ -1299,7 +1311,7 @@
MscPtr find_flow(MscPtr msc, MscPtr bmsc, std::vector<std::wstring> instances,
std::vector<std::pair<std::wstring, std::vector<MscPtr> > >& messages);
//! Make diff between specification and flow
- MscPtr diff(MscPtr specification, std::vector<MscPtr>& flows);
+ MscPtr diff(MembershipContext* c, MscPtr specification, std::vector<MscPtr>& flows);
public:
Modified: trunk/tests/diff/CMakeLists.txt
===================================================================
--- trunk/tests/diff/CMakeLists.txt 2012-01-16 18:07:50 UTC (rev 1293)
+++ trunk/tests/diff/CMakeLists.txt 2012-01-18 02:25:36 UTC (rev 1294)
@@ -43,4 +43,5 @@
ADD_DIFF_TEST(spec11.mpr flow11.mpr 1)
ADD_DIFF_TEST(spec12.mpr flow12_1.mpr 1)
ADD_DIFF_TEST(spec12.mpr flow12_2.mpr 1)
+ADD_DIFF_TEST(coregion.mpr coregion_flow.mpr 0)
Modified: trunk/tests/diff/TODO
===================================================================
--- trunk/tests/diff/TODO 2012-01-16 18:07:50 UTC (rev 1293)
+++ trunk/tests/diff/TODO 2012-01-18 02:25:36 UTC (rev 1294)
@@ -1,2 +1,4 @@
not minimal results:
./diff_test spec11.mpr flow11.mpr 1
+
+flow12_2.mpr.result2
Added: trunk/tests/diff/coregion.mpr
===================================================================
--- trunk/tests/diff/coregion.mpr (rev 0)
+++ trunk/tests/diff/coregion.mpr 2012-01-18 02:25:36 UTC (rev 1294)
@@ -0,0 +1,15 @@
+mscdocument Drawing1;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+concurrent;
+in NAME,0 from B;
+out NAME,1 to B;
+endconcurrent;
+endinstance;
+B: instance;
+out NAME,0 to A;
+in NAME,1 from A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/coregion_flow.mpr
===================================================================
--- trunk/tests/diff/coregion_flow.mpr (rev 0)
+++ trunk/tests/diff/coregion_flow.mpr 2012-01-18 02:25:36 UTC (rev 1294)
@@ -0,0 +1,11 @@
+mscdocument Drawing3;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+in NAME,0 from B;
+endinstance;
+B: instance;
+out NAME,0 to A;
+endinstance;
+endmsc;
Added: trunk/tests/diff/coregion_flow.mpr.result
===================================================================
--- trunk/tests/diff/coregion_flow.mpr.result (rev 0)
+++ trunk/tests/diff/coregion_flow.mpr.result 2012-01-18 02:25:36 UTC (rev 1294)
@@ -0,0 +1,3 @@
+Flow "Page_1" not found.
+Diff is not available (due to a coregion in the specification).
+OK: HMSC doesn't contain bMSC
Added: trunk/tests/diff/flow12_2.mpr.result2
===================================================================
--- trunk/tests/diff/flow12_2.mpr.result2 (rev 0)
+++ trunk/tests/diff/flow12_2.mpr.result2 2012-01-18 02:25:36 UTC (rev 1294)
@@ -0,0 +1,31 @@
+OK: HMSC contains bMSC
+
+mscdocument msc_diff;
+msc Page_1;
+inst A;
+inst B;
+A: instance;
+out a,0 to B;
+/* REMOVED */
+/* REMOVED */
+out a,1 to B;
+/* ADDED */
+/* ADDED */
+out a,2 to B;
+/* REMOVED */
+/* REMOVED */
+out a,3 to B;
+endinstance;
+B: instance;
+/* REMOVED */
+/* REMOVED */
+in a,1 from A;
+/* REMOVED */
+/* REMOVED */
+in a,3 from A;
+in a,0 from A;
+/* ADDED */
+/* ADDED */
+in a,2 from A;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|