1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/******************************************************************************
* Copyright (c) 2000-2021 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Baranyi, Botond
*
******************************************************************************/
// This module contains tests for bug fix 500919.
// Description: If an altstep deactivates itself (more specifically deactivates the
// default variable that executed the altstep), then all of its parameters are deleted,
// and accessing them generally causes dynamic test case errors or segmentation faults.
// The bug fix is only available in Runtime 2.
module TdefaultOperRT2 {
type port PT message {
inout integer
}
with {
extension "internal";
}
type component CT {
var default ct_def;
var integer ct_int;
timer ct_tmr[2];
port PT pt;
}
altstep as_deactivates_itself(in integer x) runs on CT {
var integer copy := x;
[] ct_tmr[x].timeout {
deactivate(ct_def);
if (x != copy) {
setverdict(fail, "Parameter has changed from ", copy, " to ", x);
}
else {
setverdict(pass);
}
}
}
testcase tc_altstep_deactivates_itself() runs on CT {
ct_def := activate(as_deactivates_itself(1));
connect(self:pt, self:pt);
pt.send(1);
ct_tmr[1].start(0.1);
alt {
[] pt.receive(integer:2) {
setverdict(fail, "Invalid alt branch");
}
}
}
altstep as_deactivates_everyone(in integer x, inout integer y) runs on CT {
var integer x_copy := x;
[] ct_tmr[x].timeout {
var integer y_copy := y;
deactivate;
if (x != x_copy) {
setverdict(fail, "Parameter 'x' has changed from ", x_copy, " to ", x);
}
else if (y != y_copy) {
setverdict(fail, "Parameter 'y' has changed from ", y_copy, " to ", y);
}
else {
setverdict(pass);
}
}
}
testcase tc_altstep_deactivates_everyone() runs on CT {
ct_int := 6;
ct_def := activate(as_deactivates_everyone(1, ct_int));
connect(self:pt, self:pt);
pt.send(1);
ct_tmr[1].start(0.1);
alt {
[] pt.receive(integer:2) {
setverdict(fail, "Invalid alt branch");
}
}
}
control {
execute(tc_altstep_deactivates_itself());
execute(tc_altstep_deactivates_everyone());
}
}
|