summaryrefslogtreecommitdiff
path: root/examples/redis-unstable/tests/support/cli.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/redis-unstable/tests/support/cli.tcl')
-rw-r--r--examples/redis-unstable/tests/support/cli.tcl36
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/redis-unstable/tests/support/cli.tcl b/examples/redis-unstable/tests/support/cli.tcl
new file mode 100644
index 0000000..a080823
--- /dev/null
+++ b/examples/redis-unstable/tests/support/cli.tcl
@@ -0,0 +1,36 @@
1proc rediscli_tls_config {testsdir} {
2 set tlsdir [file join $testsdir tls]
3 set cert [file join $tlsdir client.crt]
4 set key [file join $tlsdir client.key]
5 set cacert [file join $tlsdir ca.crt]
6
7 if {$::tls} {
8 return [list --tls --cert $cert --key $key --cacert $cacert]
9 } else {
10 return {}
11 }
12}
13
14# Returns command line for executing redis-cli
15proc rediscli {host port {opts {}}} {
16 set cmd [list src/redis-cli -h $host -p $port]
17 lappend cmd {*}[rediscli_tls_config "tests"]
18 lappend cmd {*}$opts
19 return $cmd
20}
21
22# Returns command line for executing redis-cli with a unix socket address
23proc rediscli_unixsocket {unixsocket {opts {}}} {
24 return [list src/redis-cli -s $unixsocket {*}$opts]
25}
26
27# Run redis-cli with specified args on the server of specified level.
28# Returns output broken down into individual lines.
29proc rediscli_exec {level args} {
30 set cmd [rediscli_unixsocket [srv $level unixsocket] $args]
31 set fd [open "|$cmd" "r"]
32 set ret [lrange [split [read $fd] "\n"] 0 end-1]
33 close $fd
34
35 return $ret
36}