]> git.eshelyaron.com Git - emacs.git/commitdiff
Add test for Bug#27009 in tramp-tests.el
authorMichael Albinus <michael.albinus@gmx.de>
Tue, 23 May 2017 07:25:03 +0000 (09:25 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Tue, 23 May 2017 07:25:03 +0000 (09:25 +0200)
* 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.

lisp/net/tramp-sh.el
lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index 9b001a90e78e83248015fa3bbcf0ae9390d01d9e..999de8e850466540cee7a7a980efe62ff6b59e8f 100644 (file)
@@ -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.
index 5b1e478db04d7687b702728cc90833898e718c8c..70abb89194de866800ce411e0b1343ff2003b4d3 100644 (file)
@@ -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'
index 49c32dbaaf22092f755f79cef1aaa3487c571497..0106807a9ac81be09420bbcc1e7d9bcc13cee76c 100644 (file)
@@ -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.