diff --git a/configure.ac b/configure.ac index e17d682a3..025aa84e5 100644 --- a/configure.ac +++ b/configure.ac @@ -52,8 +52,10 @@ AC_ARG_ENABLE([agent], AM_CONDITIONAL([ENABLE_AGENT], [test "x$enable_agent" = "xyes"]) AM_COND_IF([ENABLE_AGENT], [AC_CONFIG_FILES([test/agent/Makefile - test/agent/pre-inst-env:test/agent/build-aux/pre-inst-env.in], - [chmod +x test/agent/pre-inst-env])]) + test/agent/pre-inst-env:test/agent/build-aux/pre-inst-env.in + test/agent/scenarios/bulk-calls/run-scenario], + [chmod +x test/agent/pre-inst-env + chmod +x test/agent/scenarios/bulk-calls/run-scenario])]) AC_ARG_ENABLE([tracepoints], AS_HELP_STRING([--enable-tracepoints], [Enable tracepoints])) diff --git a/test/agent/scenarios/bulk-calls/agent.scm b/test/agent/scenarios/bulk-calls/agent.scm deleted file mode 120000 index cdbbefc24..000000000 --- a/test/agent/scenarios/bulk-calls/agent.scm +++ /dev/null @@ -1 +0,0 @@ -../../agent.scm \ No newline at end of file diff --git a/test/agent/scenarios/bulk-calls/jami b/test/agent/scenarios/bulk-calls/jami deleted file mode 120000 index 897b09130..000000000 --- a/test/agent/scenarios/bulk-calls/jami +++ /dev/null @@ -1 +0,0 @@ -../../jami/ \ No newline at end of file diff --git a/test/agent/scenarios/bulk-calls/run-scenario b/test/agent/scenarios/bulk-calls/run-scenario.in old mode 100755 new mode 100644 similarity index 71% rename from test/agent/scenarios/bulk-calls/run-scenario rename to test/agent/scenarios/bulk-calls/run-scenario.in index 92f565b34..948dd4a54 --- a/test/agent/scenarios/bulk-calls/run-scenario +++ b/test/agent/scenarios/bulk-calls/run-scenario.in @@ -1,5 +1,7 @@ #!/bin/sh +agent_dir="@abs_top_srcdir@/test/agent" + tmp_alice=$(mktemp --tmpdir --directory "jami-bulk-calls.XXXXXXXXXX") tmp_bob=$(mktemp --tmpdir --directory "jami-bulk-calls.XXXXXXXXXX") @@ -13,7 +15,7 @@ export XDG_CACHE_HOME="$tmp_bob" export XDG_DATA_HOME="$tmp_bob" export JAMI_LOG_FILE="bob.log" -./scenario.scm "bob" > bob-guile.txt 2>&1 & +agent -e main -s $agent_dir/scenarios/bulk-calls/scenario.scm "bob" > bob-guile.txt 2>&1 & bob_pid=$! @@ -23,7 +25,7 @@ export XDG_CONFIG_HOME="$tmp_alice" export XDG_CACHE_HOME="$tmp_alice" export XDG_DATA_HOME="$tmp_alice" export JAMI_LOG_FILE="alice.log" -./scenario.scm "alice" "$bob_id" > alice-guile.txt 2>&1 +agent -e main -s $agent_dir/scenarios/bulk-calls/scenario.scm "alice" "$bob_id" > alice-guile.txt 2>&1 wait $bob_pid diff --git a/test/agent/scenarios/bulk-calls/scenario.scm b/test/agent/scenarios/bulk-calls/scenario.scm old mode 100755 new mode 100644 index bf7ca2394..8bd62e29e --- a/test/agent/scenarios/bulk-calls/scenario.scm +++ b/test/agent/scenarios/bulk-calls/scenario.scm @@ -1,6 +1,3 @@ -#!/usr/bin/env -S ./agent.exe --no-auto-compile -e main -s -!# - ;;; Commentary: ;;; ;;; This scenario tests calling a peer in a single registration. @@ -54,26 +51,30 @@ (make-exception (make-exception-with-message "Can't make friend with bob")))) - ;; Wait for Bob to install call handlers. - (sleep (* 2 GRACE-PERIOD)) + (define (call-bob timeout) + (let ((this-call-id "")) + (jami:with-signal-sync + 'state-changed + (lambda (account-id call-id state code) + (and (string= account-id (agent:account-id me)) + (string= call-id this-call-id) + (string= state "CURRENT"))) + timeout + (set! this-call-id (agent:call-friend me bob-id))) + this-call-id)) - (let loop ([cnt 1]) + ;; Synchronize with bob a first time. + (jami:info "Alice sending call #~a" 1) + (call:hang-up (agent:account-id me) + (call-bob #f)) + + (let loop ((cnt 2)) (when (<= cnt CALL-COUNT) (jami:info "Alice sending call #~a" cnt) - (let ([this-call-id ""]) - (jami:with-signal-sync - 'state-changed - (lambda (account-id call-id state code) - (and (string= account-id (agent:account-id me)) - (string= call-id this-call-id) - (string= state "CURRENT"))) - GRACE-PERIOD - (set! this-call-id (agent:call-friend me bob-id))) - + (let ((call-id (call-bob GRACE-PERIOD))) (sleep GRACE-PERIOD) - (call:hang-up (agent:account-id me) this-call-id) + (call:hang-up (agent:account-id me) call-id) (sleep GRACE-PERIOD)) - (loop (1+ cnt))))) (define (bob) @@ -88,7 +89,7 @@ (jami:with-signal-sync 'incoming-trust-request (lambda (account-id conversation-id peer-id payload received) - (let ([sync? (string= account-id (agent:account-id me))]) + (let ((sync? (string= account-id (agent:account-id me)))) (when sync? (jami:info "accepting trust request: ~a ~a" account-id peer-id) (account:accept-trust-request account-id peer-id)) @@ -96,9 +97,9 @@ ;; Accept all incoming calls with media. - (let ([mtx (make-recursive-mutex)] - [cnd (make-condition-variable)] - [received 0]) + (let ((mtx (make-recursive-mutex)) + (cnd (make-condition-variable)) + (received 0)) (with-mutex mtx (jami:with-signal 'incoming-call/media @@ -110,21 +111,21 @@ (jami:info "Bob has received: ~a calls" received) (when (= received CALL-COUNT) (signal-condition-variable cnd))))) - (let ([success? + (let ((success? (wait-condition-variable - cnd mtx (+ (current-time) (* 4 GRACE-PERIOD CALL-COUNT)))]) + cnd mtx (+ (current-time) (* 4 GRACE-PERIOD CALL-COUNT))))) (jami:info "Summary: ~a%" (* 100 (/ received CALL-COUNT))) (exit success?)))))) (define (main args) (match (cdr args) - [("alice" bob-id) (alice bob-id)] - [("bob") (bob)] - [_ + (("alice" bob-id) (alice bob-id)) + (("bob") (bob)) + (_ (jami:error "Invalid arguments: ~a" args) - (jami:error "Usage: ~a alice|bob [ARG]\n" (car args)) - (exit EXIT_FAILURE)]) + (jami:error "Usage: ~a alice|bob (ARG)\n" (car args)) + (exit EXIT_FAILURE))) (jami:info "bye bye") diff --git a/test/agent/scenarios/peer-monitor/run-scenario b/test/agent/scenarios/peer-monitor/run-scenario deleted file mode 100755 index 5c24ae9c7..000000000 --- a/test/agent/scenarios/peer-monitor/run-scenario +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -tmp=$(mktemp --tmpdir --directory "jami-peer-monitor.XXXXXXXXXX") - -export XDG_CONFIG_HOME="$tmp" -export XDG_CACHE_HOME="$tmp" -export XDG_DATA_HOME="$tmp" -export GUILE_AUTO_COMPILE=0 -export JAMI_LOG_FILE="$1.log" - -./scenario.scm $@ - -rm -rf "$tmp" -