summaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-08-07 22:05:49 -0700
committerRuss Allbery <rra@stanford.edu>2008-08-07 22:05:49 -0700
commit22a163eb931b98cb0343dacb05fe26bb956b1f47 (patch)
tree40ad4a275fdb17136b329ac169e0acd2f1633503 /php
parent21b5e27b032ec355274049c167a2f51bdb4e1c21 (diff)
Add test for the simplified PHP interface
Diffstat (limited to 'php')
-rw-r--r--php/tests/002.phpt47
1 files changed, 47 insertions, 0 deletions
diff --git a/php/tests/002.phpt b/php/tests/002.phpt
new file mode 100644
index 0000000..8c1666a
--- /dev/null
+++ b/php/tests/002.phpt
@@ -0,0 +1,47 @@
+--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")));
+ $command = array("test", "test");
+ $result = remctl("localhost", 14373, $principal, $command);
+ echo "stdout_len: $result->stdout_len\n";
+ echo "stdout: $result->stdout\n";
+ echo "stderr_len: $result->stderr_len\n";
+ echo "status: $result->status\n";
+ flush();
+
+ $command = array("test", "status", "2");
+ $result = remctl("localhost", 14373, $principal, $command);
+ echo "stdout_len: $result->stdout_len\n";
+ echo "stderr_len: $result->stderr_len\n";
+ echo "status: $result->status\n";
+ flush();
+
+ $command = array("test", "bad-command");
+ $result = remctl("localhost", 14373, $principal, $command);
+ echo "stdout_len: $result->stdout_len\n";
+ echo "stderr_len: $result->stderr_len\n";
+ echo "error: $result->error\n";
+ echo "status: $result->status\n";
+ flush();
+?>
+--EXPECT--
+stdout_len: 12
+stdout: hello world
+
+stderr_len: 0
+status: 0
+stdout_len: 0
+stderr_len: 0
+status: 2
+stdout_len: 0
+stderr_len: 0
+error: Unknown command
+status: 0