Commit 107e60f4 authored by Michael Albinus's avatar Michael Albinus

Add test for Bug#27009 in tramp-tests.el

* lisp/net/tramp-sh.el (tramp-compute-multi-hops):
Check `tramp-file-name-real-host' for being a local host.

* lisp/net/tramp.el (tramp-postfix-host-regexp): Fix docstring.

* test/lisp/net/tramp-tests.el (tramp-test-temporary-file-directory):
Declare default host for mock method.
(tramp-test29-environment-variables-and-port-numbers): New test.
parent ad2f52a1
......@@ -4546,7 +4546,7 @@ Goes through the list `tramp-inline-compress-commands'."
;; host name.
(let* ((v (car target-alist))
(method (tramp-file-name-method v))
(host (tramp-file-name-host v)))
(host (tramp-file-name-real-host v)))
(unless
(or
;; There are multi-hops.
......
......@@ -837,7 +837,7 @@ Used in `tramp-make-tramp-file-name'."
(defun tramp-postfix-host-regexp ()
"Regexp matching delimiter between host names and localnames.
nDerived from `tramp-postfix-host-format'."
Derived from `tramp-postfix-host-format'."
(regexp-quote (tramp-postfix-host-format)))
(defconst tramp-localname-regexp ".*$"
......@@ -4396,6 +4396,8 @@ Only works for Bourne-like shells."
;; * Use also port to distinguish connections. This is needed for
;; different hosts sitting behind a single router (distinguished by
;; different port numbers). (Tzvi Edelman)
;; Also needed for different systems serve SSH on different ports of
;; the same IP address. (Bug#27009)
;;
;; * Refactor code from different handlers. Start with
;; *-process-file. One idea is to generalize `tramp-send-command'
......
......@@ -67,6 +67,9 @@
(tramp-remote-shell "/bin/sh")
(tramp-remote-shell-args ("-c"))
(tramp-connection-timeout 10)))
(add-to-list
'tramp-default-host-alist
`("\\`mock\\'" nil ,(system-name)))
(format "/mock::%s" temporary-file-directory)))
"Temporary directory for Tramp tests.")
......@@ -2920,6 +2923,42 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(regexp-quote envvar)
(funcall this-shell-command-to-string "set")))))))))
;; This test is inspired by Bug#27009.
(ert-deftest tramp-test29-environment-variables-and-port-numbers ()
"Check that two connections with separate ports are different."
;; Mark as failed until bug has been fixed.
:expected-result :failed
(skip-unless (tramp--test-enabled))
;; We test it only for the mock-up connection; otherwise there might
;; be problems with the used ports.
(skip-unless
(and
(eq tramp-syntax 'default)
(string-equal
"mock" (file-remote-p tramp-test-temporary-file-directory 'method))))
;; We force a reconnect, in order to have a clean environment.
(dolist (dir
`(,tramp-test-temporary-file-directory
"/mock:localhost#11111:" "/mock:localhost#22222:"))
(tramp-cleanup-connection
(tramp-dissect-file-name dir) 'keep-debug 'keep-password))
(dolist (port '(11111 22222))
(let* ((default-directory
(format "/mock:localhost#%d:%s" port temporary-file-directory))
(shell-file-name "/bin/sh")
(envvar (concat "VAR_" (upcase (md5 (current-time-string)))))
;; We cannot use `process-environment', because this would
;; be applied in `process-file'.
(tramp-remote-process-environment
(cons
(format "%s=%d" envvar port) tramp-remote-process-environment)))
(should
(string-equal
(number-to-string port)
(shell-command-to-string (format "echo -n $%s" envvar)))))))
;; The functions were introduced in Emacs 26.1.
(ert-deftest tramp-test30-explicit-shell-file-name ()
"Check that connection-local `explicit-shell-file-name' is set."
......@@ -3766,6 +3805,8 @@ Since it unloads Tramp, it shall be the last test to run."
;; * Fix `tramp-test05-expand-file-name-relative' in `expand-file-name'.
;; * Fix `tramp-test06-directory-file-name' for `ftp'.
;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?).
;; * Fix Bug#27009. Set expected error of
;; `tramp-test29-environment-variables-and-port-numbers'.
;; * Fix Bug#16928. Set expected error of `tramp-test36-asynchronous-requests'.
;; * Fix `tramp-test38-unload' (Not all symbols are unbound). Set
;; expected error.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment