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
|
module PIPEasp_Templates {
import from PIPEasp_PortType all;
import from PIPEasp_Types all;
template (value) ASP_PExecute ts_PExecute(template (value) charstring command,
template (value) charstring stdin) := {
command := command,
stdin := stdin
}
template (present) ASP_PResult tr_PResult(template (present) charstring stdout,
template (present) charstring stderr,
template (present) integer code) := {
stdout := stdout,
stderr := stderr,
code := code
}
template (value) ASP_PExecuteBackground ts_ExecBg(charstring cmd) := {
command := cmd
}
template (present) ASP_PStdout tr_Stdout(template (present) charstring line) := {
stdout := line
}
template (present) ASP_PStderr tr_Stderr(template (present) charstring line) := {
stderr := line
}
template (value) ASP_PStdin ts_Stdin(template (value) charstring line) := {
stdin :=line
}
/* Ignore output from stderr: */
altstep as_ignore_stderr(PIPEasp_PT pt) {
[] pt.receive(tr_Stderr(?)) { repeat; }
}
/* User should map(component_name:PIPE, system:PIPE) before using this function. */
function f_PIPEasp_exec_sync_PResult(PIPEasp_PT pt,
charstring cmdline,
template (present) ASP_PResult res_exp := tr_PResult(?,?,0),
float time_out := 10.0) return ASP_PResult {
var ASP_PResult res;
timer t;
if (time_out > 0.0) {
t.start(time_out);
}
log ("Executing: ", cmdline);
pt.send(ts_PExecute(cmdline, ""));
alt {
[] pt.receive(res_exp) -> value res;
[time_out > 0.0] t.timeout {
setverdict(fail, "Timeout: ", cmdline);
mtc.stop;
}
}
log ("Result: ", res);
return res;
}
function f_PIPEasp_exec_sync(PIPEasp_PT pt,
charstring cmdline,
template (present) integer rc := 0) return ASP_PResult {
return f_PIPEasp_exec_sync_PResult(pt, cmdline, tr_PResult(?, ?, rc));
}
}
|