| 1 | --TEST-- |
|---|
| 2 | Check full remctl API |
|---|
| 3 | --SKIPIF-- |
|---|
| 4 | <?php |
|---|
| 5 | if (!file_exists("remctl-test.pid")) |
|---|
| 6 | echo "skip remctld not running"; |
|---|
| 7 | ?> |
|---|
| 8 | --FILE-- |
|---|
| 9 | <?php |
|---|
| 10 | $fh = fopen("remctl-test.princ", "r"); |
|---|
| 11 | $principal = rtrim(fread($fh, filesize("remctl-test.princ"))); |
|---|
| 12 | $r = remctl_new(); |
|---|
| 13 | if ($r == null) { |
|---|
| 14 | echo "remctl_new failed\n"; |
|---|
| 15 | exit(2); |
|---|
| 16 | } |
|---|
| 17 | echo "Created object\n"; |
|---|
| 18 | if (!remctl_open($r, "localhost", 14373, $principal)) { |
|---|
| 19 | echo "remctl_open failed\n"; |
|---|
| 20 | exit(2); |
|---|
| 21 | } |
|---|
| 22 | echo "Opened connection\n"; |
|---|
| 23 | $args = array("test", "test"); |
|---|
| 24 | if (!remctl_command($r, $args)) { |
|---|
| 25 | echo "remctl_command failed\n"; |
|---|
| 26 | exit(2); |
|---|
| 27 | } |
|---|
| 28 | echo "Sent command\n"; |
|---|
| 29 | $output = remctl_output($r); |
|---|
| 30 | echo "1: $output->type\n"; |
|---|
| 31 | echo "1: (stream $output->stream) $output->data\n"; |
|---|
| 32 | $output = remctl_output($r); |
|---|
| 33 | echo "2: $output->type\n"; |
|---|
| 34 | echo "2: $output->status\n"; |
|---|
| 35 | $output = remctl_output($r); |
|---|
| 36 | echo "3: $output->type\n"; |
|---|
| 37 | |
|---|
| 38 | $args = array("test", "status", "2"); |
|---|
| 39 | if (!remctl_command($r, $args)) { |
|---|
| 40 | echo "remctl_command failed\n"; |
|---|
| 41 | exit(2); |
|---|
| 42 | } |
|---|
| 43 | echo "Sent status command\n"; |
|---|
| 44 | $output = remctl_output($r); |
|---|
| 45 | echo "1: $output->type\n"; |
|---|
| 46 | echo "1: $output->status\n"; |
|---|
| 47 | |
|---|
| 48 | $args = array("test", "bad-command"); |
|---|
| 49 | if (!remctl_command($r, $args)) { |
|---|
| 50 | echo "remctl_command failed\n"; |
|---|
| 51 | exit(2); |
|---|
| 52 | } |
|---|
| 53 | echo "Sent bad command\n"; |
|---|
| 54 | $output = remctl_output($r); |
|---|
| 55 | echo "1: $output->type\n"; |
|---|
| 56 | echo "1: $output->data\n"; |
|---|
| 57 | echo "1: $output->error\n"; |
|---|
| 58 | remctl_close($r); |
|---|
| 59 | ?> |
|---|
| 60 | --EXPECT-- |
|---|
| 61 | Created object |
|---|
| 62 | Opened connection |
|---|
| 63 | Sent command |
|---|
| 64 | 1: output |
|---|
| 65 | 1: (stream 1) hello world |
|---|
| 66 | |
|---|
| 67 | 2: status |
|---|
| 68 | 2: 0 |
|---|
| 69 | 3: done |
|---|
| 70 | Sent status command |
|---|
| 71 | 1: status |
|---|
| 72 | 1: 2 |
|---|
| 73 | Sent bad command |
|---|
| 74 | 1: error |
|---|
| 75 | 1: Unknown command |
|---|
| 76 | 1: 5 |
|---|