summaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-08-07 22:14:11 -0700
committerRuss Allbery <rra@stanford.edu>2008-08-07 22:14:11 -0700
commitddcedd2bec0c3852552cbb8b952708c06af1e267 (patch)
treec7730002dd6ec2107f3f999ce93f30d4d0cb67e0 /php
parent22a163eb931b98cb0343dacb05fe26bb956b1f47 (diff)
Add a test case for the PHP advanced interface
Diffstat (limited to 'php')
-rw-r--r--php/tests/003.phpt75
1 files changed, 75 insertions, 0 deletions
diff --git a/php/tests/003.phpt b/php/tests/003.phpt
new file mode 100644
index 0000000..c3a354d
--- /dev/null
+++ b/php/tests/003.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Check basic remctl API
+--SKIPIF--
+<?php
+ if (!extension_load("remctl)) print "skip";
+ if (!file_exists("remctl-test.pid")) print "skip";
+?>
+--FILE--
+<?php
+ $fh = fopen("remctl-test.princ", "r");
+ $principal = rtrim(fread($fh, filesize("remctl-test.princ")));
+ $r = remctl_new();
+ if ($r == null) {
+ echo "remctl_new failed\n";
+ exit(2);
+ }
+ echo "Created object\n";
+ if (!remctl_open($r, "localhost", 14373, $principal)) {
+ echo "remctl_open failed\n";
+ exit(2);
+ }
+ echo "Opened connection\n";
+ $args = array("test", "test");
+ if (!remctl_command($r, $args)) {
+ echo "remctl_command failed\n";
+ exit(2);
+ }
+ echo "Sent command\n";
+ $output = remctl_output($r);
+ echo "1: $output->type\n";
+ echo "1: (stream $output->stream) $output->data\n";
+ $output = remctl_output($r);
+ echo "2: $output->type\n";
+ echo "2: $output->status\n";
+ $output = remctl_output($r);
+ echo "3: $output->type\n";
+
+ $args = array("test", "status", "2");
+ if (!remctl_command($r, $args)) {
+ echo "remctl_command failed\n";
+ exit(2);
+ }
+ echo "Sent status command\n";
+ $output = remctl_output($r);
+ echo "1: $output->type\n";
+ echo "1: $output->status\n";
+
+ $args = array("test", "bad-command");
+ if (!remctl_command($r, $args)) {
+ echo "remctl_command failed\n";
+ exit(2);
+ }
+ echo "Sent bad command\n";
+ $output = remctl_output($r);
+ echo "1: $output->type\n";
+ echo "1: $output->data\n";
+ echo "1: $output->error\n";
+?>
+--EXPECT--
+Created object
+Opened connection
+Sent command
+1: output
+1: (stream 1) hello world
+
+2: status
+2: 0
+3: done
+Sent status command
+1: status
+1: 2
+Sent bad command
+1: error
+1: Unknown command
+1: 5