File: testcontrols.php

package info (click to toggle)
railcontrol 24%2Bdfsg1-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,636 kB
  • sloc: cpp: 40,819; javascript: 2,509; makefile: 144; php: 97; sh: 60
file content (70 lines) | stat: -rwxr-xr-x 1,927 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/php
<?php

include('functions.php');

$socket = startrailcontrol();

// list controls
socket_write($socket, "cla\n");
$data = socket_read($socket, 128);
$numControls = substr_count($data, "\n") - 1;
if ($numControls != 0) {
	stoprailcontrol($socket, "Number of controls at start is not 0");
}

// add virtual control
socket_write($socket, "ac \"Virt\" virt \"\"\n");
$data = explode("\n", socket_read($socket, 128));
if ($data[0] != 'Control "Virt" added') {
	stoprailcontrol($socket, "Unable to add control: $data[0]");
}

// add cs2 control
socket_write($socket, "ac \"First CS2\" virt \"\"\n");
$data = explode("\n", socket_read($socket, 128));
if ($data[0] != 'Control "First CS2" added') {
	stoprailcontrol($socket, "Unable to add control: $data[0]");
}

// add second cs2
socket_write($socket, "ac \"Second CS2\" virt \"\"\n");
$data = explode("\n", socket_read($socket, 128));
if ($data[0] != 'Control "Second CS2" added') {
	stoprailcontrol($socket, "Unable to add control: $data[0]");
}

// list all controls
socket_write($socket, "cla\n");
$data = explode("\n", socket_read($socket, 128));
$numControls = substr_count($data, "\n") - 1;
if ($numControls != 3) {
	stoprailcontrol($socket, "Number of controls at start is not 0");
}

// delete second cs2
socket_write($socket, "dc 3\n");
$data = explode("\n", socket_read($socket, 128));
if ($data[0] != 'Control "Second CS2" deleted') {
	stoprailcontrol($socket, "Unable to add control: $data[0]");
}

// delete first cs2
socket_write($socket, "dc 2\n");
$data = explode("\n", socket_read($socket, 128));
if ($data[0] != 'Control "First CS2" deleted') {
	stoprailcontrol($socket, "Unable to add control: $data[0]");
}

// delete virt
socket_write($socket, "dc 1\n");
$data = explode("\n", socket_read($socket, 128));
if ($data[0] != 'Control "Virt" deleted') {
	stoprailcontrol($socket, "Unable to add control: $data[0]");
}



stoprailcontrol($socket);

?>