Subject: bug#43252: 27.1; DBus properties lack type hints or overrides

From: Hugh Daschbach <[email-masked]>
Date: Mon, 28 Sep 2020 16:17:53 -0700

Michael Albinus writes:

> Hugh Daschbach <[email-masked]> writes:
>
> Hi Hugh,
>
> Could you, pls, move the dbus-call-method timeout test into a test of
> its own, dbus-test04-call-method-timeout? And the other test might be
> called dbus-test07-introspect-timeout.

Sure.  I've attached a draft for your review.

>> Timestamps (perhaps optional) would be useful, I think.
>
> Added. In case of method-return and error messages, I've added also the
> time difference to the corresponding method-call.

Nice.

> And while I'm there, I've added also links between serial numbers. That
> is, if you click on the serial number of a message-return or error
> message, you jump to the corresponding methoid-call. And vice-versa.

That's awesome.  Great feature.

Cheers,
Hugh

>From 454a9f4505bde8068675dfdf58658f752f561729 Mon Sep 17 00:00:00 2001
From: Hugh Daschbach <[email-masked]>
Date: Mon, 28 Sep 2020 12:44:34 -0700
Subject: [PATCH 3/4] Add D-Bus timeout tests.

* test/lisp/net/dbus-tests.el: Add timeout tests.
(dbus-test04-call-method-timeout, dbus-test07-introspection-timeout):
New tests.
---
 test/lisp/net/dbus-tests.el | 38 +++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/test/lisp/net/dbus-tests.el b/test/lisp/net/dbus-tests.el
index 28dcdd95c00..308f22eb6cc 100644
--- a/test/lisp/net/dbus-tests.el
+++ b/test/lisp/net/dbus-tests.el
@@ -581,6 +581,28 @@ dbus-test04-register-method
     ;; Cleanup.
     (dbus-unregister-service :session dbus--test-service)))
 
+(ert-deftest dbus-test04-call-method-timeout ()
+  "Verify `dbus-call-method' request timeout."
+  :tags '(:expensive-test)
+  (skip-unless dbus--test-enabled-session-bus)
+  (dbus-ignore-errors (dbus-unregister-service :session dbus--test-service))
+  (dbus-register-service :session dbus--test-service)
+
+  (unwind-protect
+      (let ((start (current-time)))
+        ;; Test timeout override for method call.
+        (should-error
+         (dbus-call-method
+          :session dbus--test-service dbus--test-path
+          dbus-interface-introspectable "Introspect" :timeout 2500)
+         :type 'dbus-error)
+
+        (should
+         (< 2.4 (float-time (time-since start)) 2.7)))
+
+        (dbus-unregister-service :session dbus--test-service)))
+
+
 (defvar dbus--test-signal-received nil
   "Received signal value in `dbus--test-signal-handler'.")
 
@@ -1709,6 +1731,22 @@ dbus-test07-introspection
 
     (dbus-unregister-service :session dbus--test-service)))
 
+(ert-deftest dbus-test07-introspection-timeout ()
+  "Verify introspection request timeouts."
+  :tags '(:expensive-test)
+  (skip-unless dbus--test-enabled-session-bus)
+  (dbus-ignore-errors (dbus-unregister-service :session dbus--test-service))
+  (dbus-register-service :session dbus--test-service)
+
+  (unwind-protect
+      (let ((start (current-time)))
+        (dbus-introspect-xml :session dbus--test-service dbus--test-path)
+        ;; Introspection internal timeout is one second.
+        (should
+         (< 1.0 (float-time (time-since start)))))
+
+        (dbus-unregister-service :session dbus--test-service)))
+
 (defun dbus-test-all (&optional interactive)
   "Run all tests for \\[dbus]."
   (interactive "p")
-- 
2.28.0