|
From: <ma...@us...> - 2012-09-11 16:54:29
|
Revision: 1478
http://scstudio.svn.sourceforge.net/scstudio/?rev=1478&view=rev
Author: madzin
Date: 2012-09-11 16:54:19 +0000 (Tue, 11 Sep 2012)
Log Message:
-----------
Fix a bug in Find Flow on HMSC and modify the tests results due to new output messages
Modified Paths:
--------------
trunk/src/membership/diff_impl.cpp
trunk/src/membership/membership_alg.cpp
trunk/tests/membership/test_bmsc11_2.mpr.result
trunk/tests/membership/test_bmsc11_3.mpr.result
trunk/tests/membership/test_bmsc11_4.mpr.result
trunk/tests/membership/test_bmsc12_3.mpr.result
trunk/tests/membership/test_bmsc12_4.mpr.result
trunk/tests/membership/test_bmsc12_5.mpr.result
trunk/tests/membership/test_bmsc13_3.mpr.result
trunk/tests/membership/test_bmsc14_2.mpr.result
trunk/tests/membership/test_bmsc14_3.mpr.result
trunk/tests/membership/test_bmsc14_4.mpr.result
trunk/tests/membership/test_bmsc15_2.mpr.result
trunk/tests/membership/test_bmsc16_3.mpr.result
trunk/tests/membership/test_bmsc18_2.mpr.result
trunk/tests/membership/test_bmsc18_3.mpr.result
trunk/tests/membership/test_bmsc20_2.mpr.result
trunk/tests/membership/test_bmsc21_3.mpr.result
trunk/tests/membership/test_bmsc21_4.mpr.result
Modified: trunk/src/membership/diff_impl.cpp
===================================================================
--- trunk/src/membership/diff_impl.cpp 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/src/membership/diff_impl.cpp 2012-09-11 16:54:19 UTC (rev 1478)
@@ -34,6 +34,9 @@
bool event_comparison(MembershipContext* c, StrictEventPtr& a, StrictEventPtr b);
+StrictEventPtr get_successor(MembershipContext* c, StrictEventPtr e);
+StrictEventPtr get_predecessor(MembershipContext* c, StrictEventPtr e);
+
BMscPtr bmsc_bmsc_diff(MembershipContext* c, BMscPtr specification, BMscPtr flow);
BMscPtr hmsc_bmsc_diff(MembershipContext* c, HMscPtr specification, BMscPtr flow);
@@ -98,6 +101,7 @@
CoregionAreaPtr a_ca = boost::dynamic_pointer_cast<CoregionArea > (a_area);
CoregionAreaPtr b_ca = boost::dynamic_pointer_cast<CoregionArea > (b_area);
+ //TODO if a_ca is NULL the error message could be wrong
if(a_ca != NULL || b_ca != NULL)
{
c->spec_contain_coregion();
@@ -144,29 +148,11 @@
row++;
- event_a = event_a->get_successor();
+ event_a = get_successor(c, event_a);
+ event_b = get_successor(c, event_b);
- //TODO refactor several times copied
- /* event_b = successor */
- if(event_b->get_successor() == NULL)
- {
- //looking for successor, necessary to look to next area
- EventAreaPtr next_area = event_b->get_area()->get_next();
-
- if(next_area == NULL)
- event_b = NULL;
- else
- {
- StrictOrderAreaPtr next_soa = boost::dynamic_pointer_cast<StrictOrderArea>(next_area);
-
- if(next_soa == NULL)
- throw std::runtime_error("Unexpected bahaviour.");
-
- event_b = next_soa->get_first();
- }
- }
- else
- event_b = event_b->get_successor();
+ if(c->get_spec_contain_coregion())
+ return NULL;
}
int lower, upper;
@@ -215,7 +201,7 @@
if (up != last_d.end())
{
old_a = up->second->getEvent();
- event_a = up->second->getEvent()->get_successor();
+ event_a = get_successor(c, up->second->getEvent());
row = up->second->getLine() + 1;
}
else
@@ -223,7 +209,7 @@
row = 1;
if (start_a != NULL)
- event_a = start_a->get_successor();
+ event_a = get_successor(c, start_a);
else
{
//TODO cover the error message
@@ -253,7 +239,7 @@
row = 1;
if (start_a != NULL)
- event_a = start_a->get_successor();
+ event_a = get_successor(c, start_a);
else
{
//TODO cover the error message
@@ -271,25 +257,7 @@
StrictEventPtr missing = start_b;
for (int i = 0; i < row+k-1; i++)
{
- if(missing->get_successor() == NULL)
- {
- EventAreaPtr next_area = missing->get_area()->get_next();
-
- if(next_area == NULL)
- {
- missing = NULL;
- continue;
- }
-
- StrictOrderAreaPtr next_soa = boost::dynamic_pointer_cast<StrictOrderArea>(next_area);
-
- if(next_soa == NULL)
- throw std::runtime_error("Unexpected behaviour.");
-
- missing = next_soa->get_first();
- }
- else
- missing = missing->get_successor();
+ missing = get_successor(c, missing);
}
//TODO not efficient event traversing from the beginning
@@ -297,11 +265,14 @@
StrictEventPtr location = start_a;
for (int i = 0; i < row-1; i++)
{
- location = location->get_successor();
+ location = get_successor(c, location);
}
if(row <= 0)
location = NULL;
+ if(missing == NULL)
+ throw std::runtime_error("Unexpected behaviour");
+
diff->setLocation(location);
diff->setMessage(missing->get_message(), missing->is_send());
@@ -329,29 +300,7 @@
for (int i = 0; i < rest; i++)
{
if (event_b != NULL)
- {
- //TODO refactoring copied from code block with missing variable
- if(event_b->get_successor() == NULL)
- {
- //looking for successor, necessary to look to next area
- EventAreaPtr next_area = event_b->get_area()->get_next();
-
- if(next_area == NULL)
- {
- event_b = NULL;
- continue;
- }
-
- StrictOrderAreaPtr next_soa = boost::dynamic_pointer_cast<StrictOrderArea>(next_area);
-
- if(next_soa == NULL)
- throw std::runtime_error("Unexpected bahaviour.");
-
- event_b = next_soa->get_first();
- }
- else
- event_b = event_b->get_successor();
- }
+ event_b = get_successor(c, event_b);
}
}
else
@@ -370,30 +319,12 @@
event_b = last_soa->get_last();
}
-
- //the previous bloc is allowed only at first run of cycle
- change_allowed = false;
-
- if(event_b->get_predecessor() == NULL)
- {
- EventAreaPtr previous_area = event_b->get_area()->get_previous();
- CoregionAreaPtr previous_ca = boost::dynamic_pointer_cast<CoregionArea>(previous_area);
-
- if(previous_ca != NULL)
- throw std::runtime_error("Flow contains coregion");
-
- StrictOrderAreaPtr previous_soa;
- previous_soa = boost::dynamic_pointer_cast<StrictOrderArea>(previous_area);
-
- if(previous_soa == NULL)
- event_b = NULL;
- else
- event_b = previous_soa->get_last();
-
- continue;
- }
-
- event_b = event_b->get_predecessor();
+ else
+ {
+ //the previous bloc is allowed only at first run of cycle
+ change_allowed = false;
+ event_b = get_predecessor(c, event_b);
+ }
}
}
@@ -401,61 +332,10 @@
diff->setLine2(col);
script[k] = diff;
-
- bool event_b_was_set;
-
while (event_a != NULL && event_b != NULL && event_comparison(c, event_a, event_b))
{
- event_b_was_set = false;
-
- //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 strict order
- //area after another strict order area.
- //
- //OF COURSE it could happen when a path duplicator is used (HMSC DIFF)
- if(next_soa != NULL)
- {
- event_b = next_soa->get_first();
- event_b_was_set = true;
- }
-
- }
-
- event_a = event_a->get_successor();
-
- if(!event_b_was_set)
- event_b = event_b->get_successor();
-
+ event_a = get_successor(c, event_a);
+ event_b = get_successor(c, event_b);
row++;
col++;
}
@@ -1096,7 +976,7 @@
if(!spec_found || !flow_found)
continue;
- //when the instance of proper name was found in both MSCs (specification, flow)
+ //when the instance of proper name was found in both MSCs (flow, specification)
DifferencePtr diff = instance_diff(c, *flow_it, *spec_it);
if(c->get_spec_contain_coregion())
@@ -2099,3 +1979,67 @@
return NULL;
}
+
+//get successor of the event e, in case the area finished it goes to the next one
+//in case a coregion was found it sets a flag in MembershipContext
+StrictEventPtr get_successor(MembershipContext* c, StrictEventPtr e)
+{
+ if(e == NULL)
+ return NULL;
+
+ if(e->get_successor() == NULL)
+ {
+ EventAreaPtr next_area = e->get_area()->get_next();
+
+ if(next_area == NULL)
+ e = NULL;
+ else
+ {
+ CoregionAreaPtr next_ca = boost::dynamic_pointer_cast<CoregionArea>(next_area);
+
+ if(next_ca != NULL)
+ {
+ //TODO refactoring: throw an exception
+// throw std::runtime_error("Contain coregion");
+ c->spec_contain_coregion();
+ return NULL;
+ }
+
+ StrictOrderAreaPtr next_soa = boost::dynamic_pointer_cast<StrictOrderArea>(next_area);
+
+ if(next_soa == NULL)
+ e = NULL;
+
+ e = next_soa->get_first();
+ }
+ }
+ else
+ e = e->get_successor();
+
+ return e;
+}
+
+StrictEventPtr get_predecessor(MembershipContext* c, StrictEventPtr e)
+{
+ if(e == NULL)
+ return NULL;
+
+ if(e->get_predecessor() == NULL)
+ {
+ EventAreaPtr previous_area = e->get_area()->get_previous();
+ CoregionAreaPtr previous_ca = boost::dynamic_pointer_cast<CoregionArea>(previous_area);
+
+ if(previous_ca != NULL)
+ throw std::runtime_error("Flow contains coregion");
+
+ StrictOrderAreaPtr previous_soa;
+ previous_soa = boost::dynamic_pointer_cast<StrictOrderArea>(previous_area);
+
+ if(previous_soa == NULL)
+ return NULL;
+ else
+ return previous_soa->get_last();
+ }
+
+ return e->get_predecessor();
+}
Modified: trunk/src/membership/membership_alg.cpp
===================================================================
--- trunk/src/membership/membership_alg.cpp 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/src/membership/membership_alg.cpp 2012-09-11 16:54:19 UTC (rev 1478)
@@ -371,8 +371,13 @@
c->set_path(diff_conf->get_path());
c->set_total_diff_amount(diff_conf->get_diff_amount());
}
- else
- throw std::runtime_error("Unexpected behaviour 11.");
+ else
+ {
+ if(!c->get_spec_contain_coregion())
+ throw std::runtime_error("Unexpected behaviour 11.");
+ else
+ break;
+ }
}
if(c->get_hmsc_diff())
Modified: trunk/tests/membership/test_bmsc11_2.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc11_2.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc11_2.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc11_3.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc11_3.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc11_3.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc11_4.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc11_4.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc11_4.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc12_3.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc12_3.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc12_3.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc12_4.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc12_4.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc12_4.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc12_5.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc12_5.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc12_5.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc13_3.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc13_3.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc13_3.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc14_2.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc14_2.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc14_2.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc14_3.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc14_3.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc14_3.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc14_4.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc14_4.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc14_4.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc15_2.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc15_2.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc15_2.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc16_3.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc16_3.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc16_3.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Page_1" not found.
+Flow "Page_1" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc18_2.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc18_2.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc18_2.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "print" not found.
+Flow "print" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc18_3.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc18_3.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc18_3.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "print" not found.
+Flow "print" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc20_2.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc20_2.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc20_2.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Test" not found.
+Flow "Test" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc21_3.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc21_3.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc21_3.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Test" not found.
+Flow "Test" not found. Diff is not available (specification contains coregion).
Modified: trunk/tests/membership/test_bmsc21_4.mpr.result
===================================================================
--- trunk/tests/membership/test_bmsc21_4.mpr.result 2012-09-11 12:34:08 UTC (rev 1477)
+++ trunk/tests/membership/test_bmsc21_4.mpr.result 2012-09-11 16:54:19 UTC (rev 1478)
@@ -1 +1 @@
-Flow "Test" not found.
+Flow "Test" not found. Diff is not available (specification contains coregion).
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|