diff options
| author | Michael Albinus | 2019-06-10 17:53:15 +0200 |
|---|---|---|
| committer | Michael Albinus | 2019-06-10 17:53:15 +0200 |
| commit | 03b66d23a863835484267a8085bb9112d9bdecae (patch) | |
| tree | 5fe4734a0d8367d7ed8c2f334028125617ef8163 | |
| parent | fb39d31e45ec766421f3ba3e5792b5f0365741c2 (diff) | |
| download | emacs-03b66d23a863835484267a8085bb9112d9bdecae.tar.gz emacs-03b66d23a863835484267a8085bb9112d9bdecae.zip | |
Make tramp-test43-asynchronous-requests working, again
* test/lisp/net/tramp-tests.el (tramp-list-tramp-buffers):
Declare `tramp-list-tramp-buffers'.
(tramp--test-ignore-make-symbolic-link-error)
(tramp--test-ignore-add-name-to-file-error): Improve declaration.
(tramp--test-with-proper-process-name-and-buffer): New macro.
(tramp-test43-asynchronous-requests): Use the macro for timer,
process filter and process sentinel. Comment the remote file
operation in the timer. Remove further async events. Accept
output from all processes.
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 117 |
1 files changed, 77 insertions, 40 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 38f9af230a3..9bdd708c92d 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -55,6 +55,7 @@ | |||
| 55 | (declare-function tramp-get-remote-path "tramp-sh") | 55 | (declare-function tramp-get-remote-path "tramp-sh") |
| 56 | (declare-function tramp-get-remote-perl "tramp-sh") | 56 | (declare-function tramp-get-remote-perl "tramp-sh") |
| 57 | (declare-function tramp-get-remote-stat "tramp-sh") | 57 | (declare-function tramp-get-remote-stat "tramp-sh") |
| 58 | (declare-function tramp-list-tramp-buffers "tramp-cmds") | ||
| 58 | (declare-function tramp-method-out-of-band-p "tramp-sh") | 59 | (declare-function tramp-method-out-of-band-p "tramp-sh") |
| 59 | (declare-function tramp-smb-get-localname "tramp-smb") | 60 | (declare-function tramp-smb-get-localname "tramp-smb") |
| 60 | (defvar auto-save-file-name-transforms) | 61 | (defvar auto-save-file-name-transforms) |
| @@ -2962,7 +2963,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." | |||
| 2962 | ;; support symbolic links at all. | 2963 | ;; support symbolic links at all. |
| 2963 | (defmacro tramp--test-ignore-make-symbolic-link-error (&rest body) | 2964 | (defmacro tramp--test-ignore-make-symbolic-link-error (&rest body) |
| 2964 | "Run BODY, ignoring \"make-symbolic-link not supported\" file error." | 2965 | "Run BODY, ignoring \"make-symbolic-link not supported\" file error." |
| 2965 | (declare (indent defun) (debug t)) | 2966 | (declare (indent defun) (debug (body))) |
| 2966 | `(condition-case err | 2967 | `(condition-case err |
| 2967 | (progn ,@body) | 2968 | (progn ,@body) |
| 2968 | ((error quit debug) | 2969 | ((error quit debug) |
| @@ -3175,7 +3176,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 3175 | ;; Method "smb" could run into "NT_STATUS_REVISION_MISMATCH" error. | 3176 | ;; Method "smb" could run into "NT_STATUS_REVISION_MISMATCH" error. |
| 3176 | (defmacro tramp--test-ignore-add-name-to-file-error (&rest body) | 3177 | (defmacro tramp--test-ignore-add-name-to-file-error (&rest body) |
| 3177 | "Run BODY, ignoring \"error with add-name-to-file\" file error." | 3178 | "Run BODY, ignoring \"error with add-name-to-file\" file error." |
| 3178 | (declare (indent defun) (debug t)) | 3179 | (declare (indent defun) (debug (body))) |
| 3179 | `(condition-case err | 3180 | `(condition-case err |
| 3180 | (progn ,@body) | 3181 | (progn ,@body) |
| 3181 | ((error quit debug) | 3182 | ((error quit debug) |
| @@ -5483,6 +5484,37 @@ Use the `ls' command." | |||
| 5483 | (defconst tramp--test-asynchronous-requests-timeout 300 | 5484 | (defconst tramp--test-asynchronous-requests-timeout 300 |
| 5484 | "Timeout for `tramp-test43-asynchronous-requests'.") | 5485 | "Timeout for `tramp-test43-asynchronous-requests'.") |
| 5485 | 5486 | ||
| 5487 | (defmacro tramp--test-with-proper-process-name-and-buffer (proc &rest body) | ||
| 5488 | "Set \"process-name\" and \"process-buffer\" connection properties. | ||
| 5489 | This is needed in timer functions as well as process filters and sentinels." | ||
| 5490 | (declare (indent 1) (debug (processp body))) | ||
| 5491 | `(let* ((v (tramp-get-connection-property ,proc "vector" nil)) | ||
| 5492 | (pname (tramp-get-connection-property v "process-name" nil)) | ||
| 5493 | (pbuffer (tramp-get-connection-property v "process-buffer" nil))) | ||
| 5494 | (tramp--test-message | ||
| 5495 | "tramp--test-with-proper-process-name-and-buffer before %s %s" | ||
| 5496 | (tramp-get-connection-property v "process-name" nil) | ||
| 5497 | (tramp-get-connection-property v "process-buffer" nil)) | ||
| 5498 | (if (process-name ,proc) | ||
| 5499 | (tramp-set-connection-property v "process-name" (process-name ,proc)) | ||
| 5500 | (tramp-flush-connection-property v "process-name")) | ||
| 5501 | (if (process-buffer ,proc) | ||
| 5502 | (tramp-set-connection-property | ||
| 5503 | v "process-buffer" (process-buffer ,proc)) | ||
| 5504 | (tramp-flush-connection-property v "process-buffer")) | ||
| 5505 | (tramp--test-message | ||
| 5506 | "tramp--test-with-proper-process-name-and-buffer changed %s %s" | ||
| 5507 | (tramp-get-connection-property v "process-name" nil) | ||
| 5508 | (tramp-get-connection-property v "process-buffer" nil)) | ||
| 5509 | (unwind-protect | ||
| 5510 | (progn ,@body) | ||
| 5511 | (if pname | ||
| 5512 | (tramp-set-connection-property v "process-name" pname) | ||
| 5513 | (tramp-flush-connection-property v "process-name")) | ||
| 5514 | (if pbuffer | ||
| 5515 | (tramp-set-connection-property v "process-buffer" pbuffer) | ||
| 5516 | (tramp-flush-connection-property v "process-buffer"))))) | ||
| 5517 | |||
| 5486 | ;; This test is inspired by Bug#16928. | 5518 | ;; This test is inspired by Bug#16928. |
| 5487 | (ert-deftest tramp-test43-asynchronous-requests () | 5519 | (ert-deftest tramp-test43-asynchronous-requests () |
| 5488 | "Check parallel asynchronous requests. | 5520 | "Check parallel asynchronous requests. |
| @@ -5532,10 +5564,10 @@ process sentinels. They shall not disturb each other." | |||
| 5532 | ((getenv "EMACS_HYDRA_CI") 10) | 5564 | ((getenv "EMACS_HYDRA_CI") 10) |
| 5533 | (t 1))) | 5565 | (t 1))) |
| 5534 | ;; We must distinguish due to performance reasons. | 5566 | ;; We must distinguish due to performance reasons. |
| 5535 | (timer-operation | 5567 | ;; (timer-operation |
| 5536 | (cond | 5568 | ;; (cond |
| 5537 | ((tramp--test-mock-p) #'vc-registered) | 5569 | ;; ((tramp--test-mock-p) #'vc-registered) |
| 5538 | (t #'file-attributes))) | 5570 | ;; (t #'file-attributes))) |
| 5539 | ;; This is when all timers start. We check inside the | 5571 | ;; This is when all timers start. We check inside the |
| 5540 | ;; timer function, that we don't exceed timeout. | 5572 | ;; timer function, that we don't exceed timeout. |
| 5541 | (timer-start (current-time)) | 5573 | (timer-start (current-time)) |
| @@ -5553,25 +5585,31 @@ process sentinels. They shall not disturb each other." | |||
| 5553 | (run-at-time | 5585 | (run-at-time |
| 5554 | 0 timer-repeat | 5586 | 0 timer-repeat |
| 5555 | (lambda () | 5587 | (lambda () |
| 5556 | (when (> (- (time-to-seconds) (time-to-seconds timer-start)) | 5588 | (tramp--test-with-proper-process-name-and-buffer |
| 5557 | tramp--test-asynchronous-requests-timeout) | 5589 | (get-buffer-process |
| 5558 | (tramp--test-timeout-handler)) | 5590 | (tramp-get-buffer |
| 5559 | (when buffers | 5591 | (tramp-dissect-file-name |
| 5560 | (let ((time (float-time)) | 5592 | tramp-test-temporary-file-directory))) |
| 5561 | (default-directory tmp-name) | 5593 | (when (> (- (time-to-seconds) (time-to-seconds timer-start)) |
| 5562 | (file | 5594 | tramp--test-asynchronous-requests-timeout) |
| 5563 | (buffer-name (nth (random (length buffers)) buffers)))) | 5595 | (tramp--test-timeout-handler)) |
| 5564 | (tramp--test-message | 5596 | (when buffers |
| 5565 | "Start timer %s %s" file (current-time-string)) | 5597 | (let ((time (float-time)) |
| 5566 | (funcall timer-operation file) | 5598 | (default-directory tmp-name) |
| 5567 | ;; Adjust timer if it takes too much time. | 5599 | (file |
| 5568 | (tramp--test-message | 5600 | (buffer-name |
| 5569 | "Stop timer %s %s" file (current-time-string)) | 5601 | (nth (random (length buffers)) buffers)))) |
| 5570 | (when (> (- (float-time) time) timer-repeat) | 5602 | (tramp--test-message |
| 5571 | (setq timer-repeat (* 1.5 timer-repeat)) | 5603 | "Start timer %s %s" file (current-time-string)) |
| 5572 | (setf (timer--repeat-delay timer) timer-repeat) | 5604 | ;; (funcall timer-operation file) |
| 5573 | (tramp--test-message | 5605 | (tramp--test-message |
| 5574 | "Increase timer %s" timer-repeat))))))) | 5606 | "Stop timer %s %s" file (current-time-string)) |
| 5607 | ;; Adjust timer if it takes too much time. | ||
| 5608 | (when (> (- (float-time) time) timer-repeat) | ||
| 5609 | (setq timer-repeat (* 1.1 timer-repeat)) | ||
| 5610 | (setf (timer--repeat-delay timer) timer-repeat) | ||
| 5611 | (tramp--test-message | ||
| 5612 | "Increase timer %s" timer-repeat)))))))) | ||
| 5575 | 5613 | ||
| 5576 | ;; Create temporary buffers. The number of buffers | 5614 | ;; Create temporary buffers. The number of buffers |
| 5577 | ;; corresponds to the number of processes; it could be | 5615 | ;; corresponds to the number of processes; it could be |
| @@ -5598,27 +5636,28 @@ process sentinels. They shall not disturb each other." | |||
| 5598 | (set-process-filter | 5636 | (set-process-filter |
| 5599 | proc | 5637 | proc |
| 5600 | (lambda (proc string) | 5638 | (lambda (proc string) |
| 5601 | (tramp--test-message | 5639 | (tramp--test-with-proper-process-name-and-buffer proc |
| 5602 | "Process filter %s %s %s" proc string (current-time-string)) | 5640 | (tramp--test-message |
| 5603 | (with-current-buffer (process-buffer proc) | 5641 | "Process filter %s %s %s" |
| 5604 | (insert string)) | 5642 | proc string (current-time-string)) |
| 5605 | (when (< (process-get proc 'bar) 2) | 5643 | (with-current-buffer (process-buffer proc) |
| 5606 | (dired-uncache (process-get proc 'foo)) | 5644 | (insert string)) |
| 5607 | (should (file-attributes (process-get proc 'foo)))))) | 5645 | (when (< (process-get proc 'bar) 2) |
| 5646 | (dired-uncache (process-get proc 'foo)) | ||
| 5647 | (should (file-attributes (process-get proc 'foo))))))) | ||
| 5608 | ;; Add process sentinel. It shall not perform remote | 5648 | ;; Add process sentinel. It shall not perform remote |
| 5609 | ;; operations, triggering Tramp processes. This blocks. | 5649 | ;; operations, triggering Tramp processes. This blocks. |
| 5610 | (set-process-sentinel | 5650 | (set-process-sentinel |
| 5611 | proc | 5651 | proc |
| 5612 | (lambda (proc _state) | 5652 | (lambda (proc _state) |
| 5613 | (tramp--test-message | 5653 | (tramp--test-with-proper-process-name-and-buffer proc |
| 5614 | "Process sentinel %s %s" proc (current-time-string)))))) | 5654 | (tramp--test-message |
| 5655 | "Process sentinel %s %s" proc (current-time-string))))))) | ||
| 5615 | 5656 | ||
| 5616 | ;; Send a string to the processes. Use a random order of | 5657 | ;; Send a string to the processes. Use a random order of |
| 5617 | ;; the buffers. Mix with regular operation. | 5658 | ;; the buffers. Mix with regular operation. |
| 5618 | (let ((buffers (copy-sequence buffers))) | 5659 | (let ((buffers (copy-sequence buffers))) |
| 5619 | (while buffers | 5660 | (while buffers |
| 5620 | ;; Activate timer. | ||
| 5621 | (sit-for 0.01 'nodisp) | ||
| 5622 | (let* ((buf (nth (random (length buffers)) buffers)) | 5661 | (let* ((buf (nth (random (length buffers)) buffers)) |
| 5623 | (proc (get-buffer-process buf)) | 5662 | (proc (get-buffer-process buf)) |
| 5624 | (file (process-get proc 'foo)) | 5663 | (file (process-get proc 'foo)) |
| @@ -5632,9 +5671,7 @@ process sentinels. They shall not disturb each other." | |||
| 5632 | (should (file-attributes file))) | 5671 | (should (file-attributes file))) |
| 5633 | ;; Send string to process. | 5672 | ;; Send string to process. |
| 5634 | (process-send-string proc (format "%s\n" (buffer-name buf))) | 5673 | (process-send-string proc (format "%s\n" (buffer-name buf))) |
| 5635 | (while (accept-process-output proc 0 nil 0)) | 5674 | (while (accept-process-output nil 0)) |
| 5636 | ;; Give the watchdog a chance. | ||
| 5637 | (read-event nil nil 0.01) | ||
| 5638 | (tramp--test-message | 5675 | (tramp--test-message |
| 5639 | "Continue action %d %s %s" count buf (current-time-string)) | 5676 | "Continue action %d %s %s" count buf (current-time-string)) |
| 5640 | ;; Regular operation post process action. | 5677 | ;; Regular operation post process action. |
| @@ -5864,8 +5901,8 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 5864 | ;; * Fix `tramp-test29-start-file-process' and | 5901 | ;; * Fix `tramp-test29-start-file-process' and |
| 5865 | ;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?). | 5902 | ;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?). |
| 5866 | ;; * Implement `tramp-test31-interrupt-process' for `adb'. | 5903 | ;; * Implement `tramp-test31-interrupt-process' for `adb'. |
| 5867 | ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. Looks | 5904 | ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. A remote |
| 5868 | ;; like it is resolved now. Remove `:unstable' tag? | 5905 | ;; file name operation cannot run in the timer. Remove `:unstable' tag? |
| 5869 | 5906 | ||
| 5870 | (provide 'tramp-tests) | 5907 | (provide 'tramp-tests) |
| 5871 | ;;; tramp-tests.el ends here | 5908 | ;;; tramp-tests.el ends here |