86 lines
1.9 KiB
Bash
Executable File
86 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
# End-to-end test for ollie-kde Phase 2
|
|
# Run this while the daemon is running: make run
|
|
set -e
|
|
|
|
SERVICE="org.ollie.SessionManager"
|
|
PATH_OBJ="/org/ollie/SessionManager"
|
|
IFACE="org.ollie.SessionManager"
|
|
|
|
call() {
|
|
dbus-send --session --dest=$SERVICE --type=method_call --print-reply \
|
|
$PATH_OBJ "$IFACE.$1" "${@:2}"
|
|
}
|
|
|
|
echo "=== ListBackends ==="
|
|
call ListBackends
|
|
|
|
echo ""
|
|
echo "=== ListAgents ==="
|
|
call ListAgents
|
|
|
|
echo ""
|
|
echo "=== CreateSession ==="
|
|
RESULT=$(dbus-send --session --dest=$SERVICE --type=method_call --print-reply \
|
|
$PATH_OBJ $IFACE.CreateSession \
|
|
string:"$HOME" string:"" string:"" string:"default")
|
|
echo "$RESULT"
|
|
SESSION_ID=$(echo "$RESULT" | grep 'string "' | head -1 | sed 's/.*string "//;s/"//')
|
|
echo "Session ID: $SESSION_ID"
|
|
|
|
if [ -z "$SESSION_ID" ]; then
|
|
echo "FAIL: no session created"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== GetState ==="
|
|
call GetState string:"$SESSION_ID"
|
|
|
|
echo ""
|
|
echo "=== GetConfig ==="
|
|
call GetConfig string:"$SESSION_ID"
|
|
|
|
echo ""
|
|
echo "=== Submit prompt ==="
|
|
call Submit string:"$SESSION_ID" string:"Say hello in exactly 5 words."
|
|
|
|
echo ""
|
|
echo "=== Waiting 5s for response... ==="
|
|
sleep 5
|
|
|
|
echo ""
|
|
echo "=== GetState (should be idle) ==="
|
|
call GetState string:"$SESSION_ID"
|
|
|
|
echo ""
|
|
echo "=== GetChat (offset 0) ==="
|
|
dbus-send --session --dest=$SERVICE --type=method_call --print-reply \
|
|
$PATH_OBJ $IFACE.GetChat \
|
|
string:"$SESSION_ID" int64:0
|
|
|
|
echo ""
|
|
echo "=== GetUsage ==="
|
|
call GetUsage string:"$SESSION_ID"
|
|
|
|
echo ""
|
|
echo "=== GetCost ==="
|
|
call GetCost string:"$SESSION_ID"
|
|
|
|
echo ""
|
|
echo "=== GetContext (first 200 chars) ==="
|
|
CONTEXT=$(dbus-send --session --dest=$SERVICE --type=method_call --print-reply \
|
|
$PATH_OBJ $IFACE.GetContext string:"$SESSION_ID" 2>&1)
|
|
echo "$CONTEXT" | head -5
|
|
|
|
echo ""
|
|
echo "=== KillSession ==="
|
|
call KillSession string:"$SESSION_ID"
|
|
|
|
echo ""
|
|
echo "=== ListSessions (should be empty) ==="
|
|
call ListSessions
|
|
|
|
echo ""
|
|
echo "=== DONE ==="
|