summaryrefslogtreecommitdiff
path: root/test/lisp/net/tramp-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp/net/tramp-tests.el')
-rw-r--r--test/lisp/net/tramp-tests.el188
1 files changed, 147 insertions, 41 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 49d506bdd9e..24dfee55134 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -33,12 +33,17 @@
;; remote host, set this environment variable to "/dev/null" or
;; whatever is appropriate on your system.
+;; For slow remote connections, `tramp-test41-asynchronous-requests'
+;; might be too heavy. Setting $REMOTE_PARALLEL_PROCESSES to a proper
+;; value less than 10 could help.
+
;; A whole test run can be performed calling the command `tramp-test-all'.
;;; Code:
(require 'dired)
(require 'ert)
+(require 'ert-x)
(require 'tramp)
(require 'vc)
(require 'vc-bzr)
@@ -53,8 +58,15 @@
(defvar tramp-copy-size-limit)
(defvar tramp-persistency-file-name)
(defvar tramp-remote-process-environment)
-;; Suppress nasty messages.
-(fset 'shell-command-sentinel 'ignore)
+
+;; Beautify batch mode.
+(when noninteractive
+ ;; Suppress nasty messages.
+ (fset 'shell-command-sentinel 'ignore)
+ ;; We do not want to be interrupted.
+ (eval-after-load 'tramp-gvfs
+ '(fset 'tramp-gvfs-handler-askquestion
+ (lambda (_message _choices) '(t nil 0)))))
;; There is no default value on w32 systems, which could work out of the box.
(defconst tramp-test-temporary-file-directory
@@ -1862,6 +1874,23 @@ This checks also `file-name-as-directory', `file-name-directory',
(insert-file-contents tmp-name)
(should (string-equal (buffer-string) "34")))
+ ;; Check message.
+ ;; Macro `ert-with-message-capture' was introduced in Emacs 26.1.
+ (with-no-warnings (when (symbol-plist 'ert-with-message-capture)
+ (let ((tramp-message-show-message t))
+ (dolist (noninteractive '(nil t))
+ (dolist (visit '(nil t "string" no-message))
+ (ert-with-message-capture tramp--test-messages
+ (write-region "foo" nil tmp-name nil visit)
+ ;; We must check the last line. There could be
+ ;; other messages from the progress reporter.
+ (should
+ (string-match
+ (if (and (null noninteractive)
+ (or (eq visit t) (null visit) (stringp visit)))
+ (format "^Wrote %s\n\\'" tmp-name) "^\\'")
+ tramp--test-messages))))))))
+
;; Do not overwrite if excluded.
(cl-letf (((symbol-function 'y-or-n-p) (lambda (_prompt) t)))
(write-region "foo" nil tmp-name nil nil nil 'mustbenew))
@@ -1919,7 +1948,9 @@ This checks also `file-name-as-directory', `file-name-directory',
;; Copy file to directory.
(unwind-protect
- (progn
+ ;; FIXME: This fails on my QNAP server, see
+ ;; /share/Web/owncloud/data/owncloud.log
+ (unless (tramp--test-owncloud-p)
(write-region "foo" nil source)
(should (file-exists-p source))
(make-directory target)
@@ -1940,7 +1971,11 @@ This checks also `file-name-as-directory', `file-name-directory',
;; Copy directory to existing directory.
(unwind-protect
- (progn
+ ;; FIXME: This fails on my QNAP server, see
+ ;; /share/Web/owncloud/data/owncloud.log
+ (unless (and (tramp--test-owncloud-p)
+ (or (not (file-remote-p source))
+ (not (file-remote-p target))))
(make-directory source)
(should (file-directory-p source))
(write-region "foo" nil (expand-file-name "foo" source))
@@ -1961,7 +1996,10 @@ This checks also `file-name-as-directory', `file-name-directory',
;; Copy directory/file to non-existing directory.
(unwind-protect
- (progn
+ ;; FIXME: This fails on my QNAP server, see
+ ;; /share/Web/owncloud/data/owncloud.log
+ (unless
+ (and (tramp--test-owncloud-p) (not (file-remote-p source)))
(make-directory source)
(should (file-directory-p source))
(write-region "foo" nil (expand-file-name "foo" source))
@@ -2047,7 +2085,9 @@ This checks also `file-name-as-directory', `file-name-directory',
;; Rename directory to existing directory.
(unwind-protect
- (progn
+ ;; FIXME: This fails on my QNAP server, see
+ ;; /share/Web/owncloud/data/owncloud.log
+ (unless (tramp--test-owncloud-p)
(make-directory source)
(should (file-directory-p source))
(write-region "foo" nil (expand-file-name "foo" source))
@@ -2069,7 +2109,9 @@ This checks also `file-name-as-directory', `file-name-directory',
;; Rename directory/file to non-existing directory.
(unwind-protect
- (progn
+ ;; FIXME: This fails on my QNAP server, see
+ ;; /share/Web/owncloud/data/owncloud.log
+ (unless (tramp--test-owncloud-p)
(make-directory source)
(should (file-directory-p source))
(write-region "foo" nil (expand-file-name "foo" source))
@@ -2718,9 +2760,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(file-symlink-p tmp-name2)))
;; `tmp-name3' is a local file name. Therefore, the link
;; target remains unchanged, even if quoted.
- (make-symbolic-link tmp-name1 tmp-name3)
- (should
- (string-equal tmp-name1 (file-symlink-p tmp-name3)))
+ ;; `make-symbolic-link' might not be permitted on w32 systems.
+ (unless (tramp--test-windows-nt)
+ (make-symbolic-link tmp-name1 tmp-name3)
+ (should
+ (string-equal tmp-name1 (file-symlink-p tmp-name3))))
;; Check directory as newname.
(make-directory tmp-name4)
(should-error
@@ -2822,15 +2866,17 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(tramp-compat-file-name-quote
(concat (file-remote-p tmp-name2) "/penguin:motd:"))))
;; `tmp-name3' is a local file name.
- (make-symbolic-link tmp-name1 tmp-name3)
- (should (file-symlink-p tmp-name3))
- (should-not (string-equal tmp-name3 (file-truename tmp-name3)))
- ;; `file-truename' returns a quoted file name for `tmp-name3'.
- ;; We must unquote it.
- (should
- (string-equal
- (tramp-compat-file-name-unquote (file-truename tmp-name1))
- (tramp-compat-file-name-unquote (file-truename tmp-name3)))))
+ ;; `make-symbolic-link' might not be permitted on w32 systems.
+ (unless (tramp--test-windows-nt)
+ (make-symbolic-link tmp-name1 tmp-name3)
+ (should (file-symlink-p tmp-name3))
+ (should-not (string-equal tmp-name3 (file-truename tmp-name3)))
+ ;; `file-truename' returns a quoted file name for `tmp-name3'.
+ ;; We must unquote it.
+ (should
+ (string-equal
+ (tramp-compat-file-name-unquote (file-truename tmp-name1))
+ (tramp-compat-file-name-unquote (file-truename tmp-name3))))))
;; Cleanup.
(ignore-errors
@@ -2877,9 +2923,15 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(tramp--test-ignore-make-symbolic-link-error
(make-symbolic-link tmp-name2 tmp-name1)
(should (file-symlink-p tmp-name1))
- (make-symbolic-link tmp-name1 tmp-name2)
- (should (file-symlink-p tmp-name2))
- (should-error (file-truename tmp-name1) :type 'file-error))
+ (if (tramp-smb-file-name-p tramp-test-temporary-file-directory)
+ ;; The symlink command of `smbclient' detects the
+ ;; cycle already.
+ (should-error
+ (make-symbolic-link tmp-name1 tmp-name2)
+ :type 'file-error)
+ (make-symbolic-link tmp-name1 tmp-name2)
+ (should (file-symlink-p tmp-name2))
+ (should-error (file-truename tmp-name1) :type 'file-error)))
;; Cleanup.
(ignore-errors
@@ -3773,11 +3825,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(vc-register
(list (car vc-handled-backends)
(list (file-name-nondirectory tmp-name2))))
- ;; `vc-register' has changed its arguments in Emacs 25.1.
- (error
- (vc-register
- nil (list (car vc-handled-backends)
- (list (file-name-nondirectory tmp-name2))))))
+ ;; `vc-register' has changed its arguments in Emacs
+ ;; 25.1. Let's skip it for older Emacsen.
+ (error (skip-unless (>= emacs-major-version 25))))
;; vc-git uses an own process sentinel, Tramp's sentinel
;; for flushing the cache isn't used.
(dired-uncache (concat (file-remote-p default-directory) "/"))
@@ -3915,9 +3965,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(expand-file-name
(format
"%s~"
- ;; This is taken from `make-backup-file-name-1'.
+ ;; This is taken from `make-backup-file-name-1'. We
+ ;; call `convert-standard-filename', because on MS
+ ;; Windows the (local) colons must be replaced by
+ ;; exclamation marks.
(subst-char-in-string
- ?/ ?! (replace-regexp-in-string "!" "!!" tmp-name1)))
+ ?/ ?!
+ (replace-regexp-in-string
+ "!" "!!" (convert-standard-filename tmp-name1))))
tmp-name2)))))
;; The backup directory is created.
(should (file-directory-p tmp-name2)))
@@ -3938,9 +3993,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(expand-file-name
(format
"%s~"
- ;; This is taken from `make-backup-file-name-1'.
+ ;; This is taken from `make-backup-file-name-1'. We
+ ;; call `convert-standard-filename', because on MS
+ ;; Windows the (local) colons must be replaced by
+ ;; exclamation marks.
(subst-char-in-string
- ?/ ?! (replace-regexp-in-string "!" "!!" tmp-name1)))
+ ?/ ?!
+ (replace-regexp-in-string
+ "!" "!!" (convert-standard-filename tmp-name1))))
tmp-name2)))))
;; The backup directory is created.
(should (file-directory-p tmp-name2)))
@@ -3962,9 +4022,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(expand-file-name
(format
"%s~"
- ;; This is taken from `make-backup-file-name-1'.
+ ;; This is taken from `make-backup-file-name-1'. We
+ ;; call `convert-standard-filename', because on MS
+ ;; Windows the (local) colons must be replaced by
+ ;; exclamation marks.
(subst-char-in-string
- ?/ ?! (replace-regexp-in-string "!" "!!" tmp-name1)))
+ ?/ ?!
+ (replace-regexp-in-string
+ "!" "!!" (convert-standard-filename tmp-name1))))
tmp-name2)))))
;; The backup directory is created.
(should (file-directory-p tmp-name2)))
@@ -4053,6 +4118,11 @@ This does not support external Emacs calls."
(string-equal
"mock" (file-remote-p tramp-test-temporary-file-directory 'method)))
+(defun tramp--test-owncloud-p ()
+ "Check, whether the owncloud method is used."
+ (string-equal
+ "owncloud" (file-remote-p tramp-test-temporary-file-directory 'method)))
+
(defun tramp--test-rsync-p ()
"Check, whether the rsync method is used.
This does not support special file names."
@@ -4065,6 +4135,10 @@ This does not support special file names."
(tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
'tramp-sh-file-name-handler))
+(defun tramp--test-windows-nt ()
+ "Check, whether the locale host runs MS Windows."
+ (eq system-type 'windows-nt))
+
(defun tramp--test-windows-nt-and-batch ()
"Check, whether the locale host runs MS Windows in batch mode.
This does not support special characters."
@@ -4482,6 +4556,7 @@ process sentinels. They shall not disturb each other."
;; seconds, and we send a SIGUSR1 signal after 300 seconds.
(with-timeout (300 (tramp--test-timeout-handler))
(define-key special-event-map [sigusr1] 'tramp--test-timeout-handler)
+ (tramp--test-instrument-test-case (if (getenv "EMACS_HYDRA_CI") 10 0)
(let* (;; For the watchdog.
(default-directory (expand-file-name temporary-file-directory))
(watchdog
@@ -4497,8 +4572,13 @@ process sentinels. They shall not disturb each other."
(inhibit-message t)
;; Do not run delayed timers.
(timer-max-repeats 0)
- ;; Number of asynchronous processes for test.
- (number-proc 10)
+ ;; Number of asynchronous processes for test. Tests on
+ ;; some machines handle less parallel processes.
+ (number-proc
+ (or
+ (ignore-errors
+ (string-to-number (getenv "REMOTE_PARALLEL_PROCESSES")))
+ 10))
;; On hydra, timings are bad.
(timer-repeat
(cond
@@ -4528,11 +4608,16 @@ process sentinels. They shall not disturb each other."
(default-directory tmp-name)
(file
(buffer-name (nth (random (length buffers)) buffers))))
+ (tramp--test-message
+ "Start timer %s %s" file (current-time-string))
(funcall timer-operation file)
;; Adjust timer if it takes too much time.
(when (> (- (float-time) time) timer-repeat)
(setq timer-repeat (* 1.5 timer-repeat))
- (setf (timer--repeat-delay timer) timer-repeat)))))))
+ (setf (timer--repeat-delay timer) timer-repeat)
+ (tramp--test-message "Increase timer %s" timer-repeat))
+ (tramp--test-message
+ "Stop timer %s %s" file (current-time-string)))))))
;; Create temporary buffers. The number of buffers
;; corresponds to the number of processes; it could be
@@ -4559,14 +4644,20 @@ process sentinels. They shall not disturb each other."
(set-process-filter
proc
(lambda (proc string)
+ (tramp--test-message
+ "Process filter %s %s %s" proc string (current-time-string))
(with-current-buffer (process-buffer proc)
(insert string))
(unless (zerop (length string))
+ (dired-uncache (process-get proc 'foo))
(should (file-attributes (process-get proc 'foo))))))
;; Add process sentinel.
(set-process-sentinel
proc
(lambda (proc _state)
+ (tramp--test-message
+ "Process sentinel %s %s" proc (current-time-string))
+ (dired-uncache (process-get proc 'foo))
(should-not (file-attributes (process-get proc 'foo)))))))
;; Send a string. Use a random order of the buffers. Mix
@@ -4579,7 +4670,10 @@ process sentinels. They shall not disturb each other."
(proc (get-buffer-process buf))
(file (process-get proc 'foo))
(count (process-get proc 'bar)))
+ (tramp--test-message
+ "Start action %d %s %s" count buf (current-time-string))
;; Regular operation prior process action.
+ (dired-uncache file)
(if (= count 0)
(should-not (file-attributes file))
(should (file-attributes file)))
@@ -4588,10 +4682,15 @@ process sentinels. They shall not disturb each other."
(accept-process-output proc 0.1 nil 0)
;; Give the watchdog a chance.
(read-event nil nil 0.01)
+ (tramp--test-message
+ "Continue action %d %s %s" count buf (current-time-string))
;; Regular operation post process action.
+ (dired-uncache file)
(if (= count 2)
(should-not (file-attributes file))
(should (file-attributes file)))
+ (tramp--test-message
+ "Stop action %d %s %s" count buf (current-time-string))
(process-put proc 'bar (1+ count))
(unless (process-live-p proc)
(setq buffers (delq buf buffers))))))
@@ -4599,6 +4698,7 @@ process sentinels. They shall not disturb each other."
;; Checks. All process output shall exists in the
;; respective buffers. All created files shall be
;; deleted.
+ (tramp--test-message "Check %s" (current-time-string))
(dolist (buf buffers)
(with-current-buffer buf
(should (string-equal (format "%s\n" buf) (buffer-string)))))
@@ -4613,7 +4713,7 @@ process sentinels. They shall not disturb each other."
(ignore-errors (delete-process (get-buffer-process buf)))
(ignore-errors (kill-buffer buf)))
(ignore-errors (cancel-timer timer))
- (ignore-errors (delete-directory tmp-name 'recursive))))))
+ (ignore-errors (delete-directory tmp-name 'recursive)))))))
;; This test is inspired by Bug#29163.
(ert-deftest tramp-test42-auto-load ()
@@ -4629,7 +4729,8 @@ process sentinels. They shall not disturb each other."
(shell-command-to-string
(format
"%s -batch -Q -L %s --eval %s"
- (expand-file-name invocation-name invocation-directory)
+ (shell-quote-argument
+ (expand-file-name invocation-name invocation-directory))
(mapconcat 'shell-quote-argument load-path " -L ")
(shell-quote-argument code)))))))
@@ -4661,7 +4762,8 @@ process sentinels. They shall not disturb each other."
(shell-command-to-string
(format
"%s -batch -Q -L %s --eval %s"
- (expand-file-name invocation-name invocation-directory)
+ (shell-quote-argument
+ (expand-file-name invocation-name invocation-directory))
(mapconcat 'shell-quote-argument load-path " -L ")
(shell-quote-argument (format code tm)))))))))
@@ -4684,7 +4786,8 @@ process sentinels. They shall not disturb each other."
(shell-command-to-string
(format
"%s -batch -Q -L %s --eval %s"
- (expand-file-name invocation-name invocation-directory)
+ (shell-quote-argument
+ (expand-file-name invocation-name invocation-directory))
(mapconcat 'shell-quote-argument load-path " -L ")
(shell-quote-argument code))))))))
@@ -4711,7 +4814,8 @@ process sentinels. They shall not disturb each other."
(shell-command-to-string
(format
"%s -batch -Q -L %s -l tramp-sh --eval %s"
- (expand-file-name invocation-name invocation-directory)
+ (shell-quote-argument
+ (expand-file-name invocation-name invocation-directory))
(mapconcat 'shell-quote-argument load-path " -L ")
(shell-quote-argument code)))))))
@@ -4778,6 +4882,8 @@ Since it unloads Tramp, it shall be the last test to run."
;; * Work on skipped tests. Make a comment, when it is impossible.
;; * Fix `tramp-test05-expand-file-name-relative' in `expand-file-name'.
;; * Fix `tramp-test06-directory-file-name' for `ftp'.
+;; * Investigate, why `tramp-test11-copy-file' and `tramp-test12-rename-file'
+;; do not work properly for `owncloud'.
;; * Fix `tramp-test29-start-file-process' on MS Windows (`process-send-eof'?).
;; * Fix `tramp-test30-interrupt-process', timeout doesn't work reliably.
;; * Fix Bug#16928 in `tramp-test41-asynchronous-requests'.