From 9087245aedefc8c4ce13c0d8beaa514d182dde7a Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Tue, 6 Mar 2018 14:01:30 +0100
Subject: [PATCH] Fixed 'done' operation on PTC (bug 532060)

Change-Id: Iaf082038e5bb9340a57f49d70a717106b0ff8020
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
---
 mctr2/mctr/MainController.cc                  |  8 +++++---
 mctr2/mctr/MainController.h                   |  4 ++--
 regression_test/commMessage/TcommMessage.ttcn | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/mctr2/mctr/MainController.cc b/mctr2/mctr/MainController.cc
index f7149203c..55c9d6e10 100644
--- a/mctr2/mctr/MainController.cc
+++ b/mctr2/mctr/MainController.cc
@@ -1499,11 +1499,11 @@ void MainController::send_component_status_to_requestor(component_struct *tc,
   case PTC_STARTING:
     if (done_status) {
       send_component_status_ptc(requestor, tc->comp_ref, TRUE,
-        killed_status, tc->return_type, tc->return_value_len,
+        killed_status, tc->local_verdict, tc->return_type, tc->return_value_len,
         tc->return_value);
     } else {
       send_component_status_ptc(requestor, tc->comp_ref, FALSE,
-        killed_status, NULL, 0, NULL);
+        killed_status, tc->local_verdict, NULL, 0, NULL);
     }
     break;
   case PTC_STOPPING_KILLING:
@@ -3595,13 +3595,15 @@ void MainController::send_cancel_done_ptc(component_struct *tc,
 
 void MainController::send_component_status_ptc(component_struct *tc,
   component component_reference, boolean is_done, boolean is_killed,
-  const char *return_type, int return_value_len, const void *return_value)
+  verdicttype local_verdict, const char *return_type, int return_value_len,
+  const void *return_value)
 {
   Text_Buf text_buf;
   text_buf.push_int(MSG_COMPONENT_STATUS);
   text_buf.push_int(component_reference);
   text_buf.push_int(is_done ? 1 : 0);
   text_buf.push_int(is_killed ? 1 : 0);
+  text_buf.push_int(local_verdict);
   text_buf.push_string(return_type);
   text_buf.push_raw(return_value_len, return_value);
   send_message(tc->tc_fd, text_buf);
diff --git a/mctr2/mctr/MainController.h b/mctr2/mctr/MainController.h
index eb9e3ce32..cc8f12ae8 100644
--- a/mctr2/mctr/MainController.h
+++ b/mctr2/mctr/MainController.h
@@ -552,8 +552,8 @@ private:
     component component_reference);
   static void send_component_status_ptc(component_struct *tc,
     component component_reference,
-    boolean is_done, boolean is_killed, const char *return_type,
-    int return_value_len, const void *return_value);
+    boolean is_done, boolean is_killed, verdicttype local_verdict,
+    const char *return_type, int return_value_len, const void *return_value);
   static void send_start(component_struct *tc,
     const qualified_name& function_name, int arg_len, const void *arg_ptr);
   static void send_kill(component_struct *tc);
diff --git a/regression_test/commMessage/TcommMessage.ttcn b/regression_test/commMessage/TcommMessage.ttcn
index 0ab555fcb..129f53156 100644
--- a/regression_test/commMessage/TcommMessage.ttcn
+++ b/regression_test/commMessage/TcommMessage.ttcn
@@ -1568,6 +1568,24 @@ testcase commMessageBehaviorFunctionParams() runs on commMessage_comp1 {
   setverdict(pass);
 }
 
+function f_behavior_empty() runs on C {
+  // does nothing
+}
+
+function f_behavior_done() runs on C {
+  var C comp := C.create;
+  comp.start(f_behavior_empty());
+  comp.done;
+}
+
+// tests the 'done' operation on a PTC
+testcase tc_bug_532060() runs on C {
+  var C comp := C.create;
+  comp.start(f_behavior_done());
+  comp.done;
+  setverdict(pass);
+}
+
 control {
  execute(commMessageIntegerEncode());
  execute(commMessageValue());
@@ -1609,5 +1627,6 @@ control {
  execute(commMessageDualFacedPorts2());
  execute(commMessageReceiveAnyOrOmit());
  execute(commMessageBehaviorFunctionParams());
+ execute(tc_bug_532060());
 }
 }
-- 
GitLab