55
55
(declare-function tramp-get-remote-path "tramp-sh")
56
56
(declare-function tramp-get-remote-perl "tramp-sh")
57
57
(declare-function tramp-get-remote-stat "tramp-sh")
58
+ (declare-function tramp-list-tramp-buffers "tramp-cmds")
58
59
(declare-function tramp-method-out-of-band-p "tramp-sh")
59
60
(declare-function tramp-smb-get-localname "tramp-smb")
60
61
(defvar auto-save-file-name-transforms)
@@ -2962,7 +2963,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2962
2963
;; support symbolic links at all.
2963
2964
(defmacro tramp--test-ignore-make-symbolic-link-error (&rest body)
2964
2965
"Run BODY, ignoring \"make-symbolic-link not supported\" file error."
2965
- (declare (indent defun) (debug t ))
2966
+ (declare (indent defun) (debug (body) ))
2966
2967
`(condition-case err
2967
2968
(progn ,@body)
2968
2969
((error quit debug)
@@ -3175,7 +3176,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
3175
3176
;; Method "smb" could run into "NT_STATUS_REVISION_MISMATCH" error.
3176
3177
(defmacro tramp--test-ignore-add-name-to-file-error (&rest body)
3177
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
3180
`(condition-case err
3180
3181
(progn ,@body)
3181
3182
((error quit debug)
@@ -5483,6 +5484,37 @@ Use the `ls' command."
5483
5484
(defconst tramp--test-asynchronous-requests-timeout 300
5484
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
5518
;; This test is inspired by Bug#16928.
5487
5519
(ert-deftest tramp-test43-asynchronous-requests ()
5488
5520
"Check parallel asynchronous requests.
@@ -5532,10 +5564,10 @@ process sentinels. They shall not disturb each other."
5532
5564
((getenv "EMACS_HYDRA_CI") 10)
5533
5565
(t 1)))
5534
5566
;; We must distinguish due to performance reasons.
5535
- (timer-operation
5536
- (cond
5537
- ((tramp--test-mock-p) #'vc-registered)
5538
- (t #'file-attributes)))
5567
+ ;; (timer-operation
5568
+ ;; (cond
5569
+ ;; ((tramp--test-mock-p) #'vc-registered)
5570
+ ;; (t #'file-attributes)))
5539
5571
;; This is when all timers start. We check inside the
5540
5572
;; timer function, that we don't exceed timeout.
5541
5573
(timer-start (current-time))
@@ -5553,25 +5585,31 @@ process sentinels. They shall not disturb each other."
5553
5585
(run-at-time
5554
5586
0 timer-repeat
5555
5587
(lambda ()
5556
- (when (> (- (time-to-seconds) (time-to-seconds timer-start))
5557
- tramp--test-asynchronous-requests-timeout)
5558
- (tramp--test-timeout-handler))
5559
- (when buffers
5560
- (let ((time (float-time ))
5561
- (default-directory tmp-name )
5562
- (file
5563
- (buffer-name (nth (random (length buffers)) buffers)) ))
5564
- (tramp--test-message
5565
- "Start timer %s %s" file (current -time-string ))
5566
- (funcall timer-operation file )
5567
- ;; Adjust timer if it takes too much time.
5568
- (tramp--test-message
5569
- "Stop timer %s %s" file (current-time-string ))
5570
- (when (> (- (float-time) time) timer-repeat)
5571
- (setq timer-repeat (* 1.5 timer-repeat ))
5572
- (setf (timer--repeat-delay timer) timer-repeat )
5588
+ (tramp--test-with-proper-process-name-and-buffer
5589
+ (get-buffer-process
5590
+ (tramp-get-buffer
5591
+ (tramp-dissect-file-name
5592
+ tramp-test-temporary-file-directory) ))
5593
+ (when (> (- (time-to-seconds) (time-to-seconds timer-start) )
5594
+ tramp--test-asynchronous-requests-timeout)
5595
+ (tramp--test-timeout-handler ))
5596
+ (when buffers
5597
+ (let ((time (float -time))
5598
+ (default-directory tmp-name )
5599
+ (file
5600
+ (buffer-name
5601
+ (nth (random (length buffers)) buffers)) ))
5602
+ (tramp--test-message
5603
+ "Start timer %s %s" file (current-time-string ))
5604
+ ;; (funcall timer-operation file )
5573
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
5614
;; Create temporary buffers. The number of buffers
5577
5615
;; corresponds to the number of processes; it could be
@@ -5598,27 +5636,28 @@ process sentinels. They shall not disturb each other."
5598
5636
(set-process-filter
5599
5637
proc
5600
5638
(lambda (proc string)
5601
- (tramp--test-message
5602
- "Process filter %s %s %s" proc string (current-time-string))
5603
- (with-current-buffer (process-buffer proc)
5604
- (insert string))
5605
- (when (< (process-get proc 'bar) 2)
5606
- (dired-uncache (process-get proc 'foo))
5607
- (should (file-attributes (process-get proc 'foo))))))
5639
+ (tramp--test-with-proper-process-name-and-buffer proc
5640
+ (tramp--test-message
5641
+ "Process filter %s %s %s"
5642
+ proc string (current-time-string))
5643
+ (with-current-buffer (process-buffer proc)
5644
+ (insert string))
5645
+ (when (< (process-get proc 'bar) 2)
5646
+ (dired-uncache (process-get proc 'foo))
5647
+ (should (file-attributes (process-get proc 'foo)))))))
5608
5648
;; Add process sentinel. It shall not perform remote
5609
5649
;; operations, triggering Tramp processes. This blocks.
5610
5650
(set-process-sentinel
5611
5651
proc
5612
5652
(lambda (proc _state)
5613
- (tramp--test-message
5614
- "Process sentinel %s %s" proc (current-time-string))))))
5653
+ (tramp--test-with-proper-process-name-and-buffer proc
5654
+ (tramp--test-message
5655
+ "Process sentinel %s %s" proc (current-time-string)))))))
5615
5656
5616
5657
;; Send a string to the processes. Use a random order of
5617
5658
;; the buffers. Mix with regular operation.
5618
5659
(let ((buffers (copy-sequence buffers)))
5619
5660
(while buffers
5620
- ;; Activate timer.
5621
- (sit-for 0.01 'nodisp)
5622
5661
(let* ((buf (nth (random (length buffers)) buffers))
5623
5662
(proc (get-buffer-process buf))
5624
5663
(file (process-get proc 'foo))
@@ -5632,9 +5671,7 @@ process sentinels. They shall not disturb each other."
5632
5671
(should (file-attributes file)))
5633
5672
;; Send string to process.
5634
5673
(process-send-string proc (format "%s\n" (buffer-name buf)))
5635
- (while (accept-process-output proc 0 nil 0))
5636
- ;; Give the watchdog a chance.
5637
- (read-event nil nil 0.01)
5674
+ (while (accept-process-output nil 0))
5638
5675
(tramp--test-message
5639
5676
"Continue action %d %s %s" count buf (current-time-string))
5640
5677
;; Regular operation post process action.
@@ -5864,8 +5901,8 @@ Since it unloads Tramp, it shall be the last test to run."
5864
5901
;; * Fix `tramp-test29-start-file-process' and
5865
5902
;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?).
5866
5903
;; * Implement `tramp-test31-interrupt-process' for `adb'.
5867
- ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. Looks
5868
- ;; like it is resolved now . Remove `:unstable' tag?
5904
+ ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. A remote
5905
+ ;; file name operation cannot run in the timer . Remove `:unstable' tag?
5869
5906
5870
5907
(provide 'tramp-tests)
5871
5908
;;; tramp-tests.el ends here
0 commit comments