aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-11-14 10:21:55 +0100
committerMichael Albinus2017-11-14 10:21:55 +0100
commit8b900e5ba2052898d98f7bd4ff3151389c10ab02 (patch)
tree07a53996657b3df24a98324fcb53e90a152bf08c
parentff7bd84b233888257b4b71214eb0a372168d0bae (diff)
downloademacs-8b900e5ba2052898d98f7bd4ff3151389c10ab02.tar.gz
emacs-8b900e5ba2052898d98f7bd4ff3151389c10ab02.zip
Fix Bug#2928
* test/lisp/net/tramp-tests.el (tramp-test25-file-selinux): Enhance test. (Bug#29287) (tramp-test44-delay-load): Fix for older Emacsen.
-rw-r--r--test/lisp/net/tramp-tests.el117
1 files changed, 76 insertions, 41 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 7a7cf933fa3..a43ac739496 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2921,6 +2921,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2921 ;; Cleanup. 2921 ;; Cleanup.
2922 (ignore-errors (delete-file tmp-name)))))) 2922 (ignore-errors (delete-file tmp-name))))))
2923 2923
2924;; This test is inspired by Bug#29149.
2924(ert-deftest tramp-test24-file-acl () 2925(ert-deftest tramp-test24-file-acl ()
2925 "Check that `file-acl' and `set-file-acl' work proper." 2926 "Check that `file-acl' and `set-file-acl' work proper."
2926 (skip-unless (tramp--test-enabled)) 2927 (skip-unless (tramp--test-enabled))
@@ -2995,8 +2996,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2995 (ignore-errors (delete-file tmp-name1)) 2996 (ignore-errors (delete-file tmp-name1))
2996 (ignore-errors (delete-file tmp-name3)))))) 2997 (ignore-errors (delete-file tmp-name3))))))
2997 2998
2998;; TODO: This test didn't run in reality yet. Pls report if it
2999;; doesn't work as expected.
3000(ert-deftest tramp-test25-file-selinux () 2999(ert-deftest tramp-test25-file-selinux ()
3001 "Check `file-selinux-context' and `set-file-selinux-context'." 3000 "Check `file-selinux-context' and `set-file-selinux-context'."
3002 (skip-unless (tramp--test-enabled)) 3001 (skip-unless (tramp--test-enabled))
@@ -3013,7 +3012,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3013 ;; Both files are remote. 3012 ;; Both files are remote.
3014 (unwind-protect 3013 (unwind-protect
3015 (progn 3014 (progn
3016 ;; Two files with same SELINUX context. 3015 ;; Two files with same SELinux context.
3017 (write-region "foo" nil tmp-name1) 3016 (write-region "foo" nil tmp-name1)
3018 (should (file-exists-p tmp-name1)) 3017 (should (file-exists-p tmp-name1))
3019 (should (file-selinux-context tmp-name1)) 3018 (should (file-selinux-context tmp-name1))
@@ -3023,14 +3022,18 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3023 (equal 3022 (equal
3024 (file-selinux-context tmp-name1) 3023 (file-selinux-context tmp-name1)
3025 (file-selinux-context tmp-name2))) 3024 (file-selinux-context tmp-name2)))
3026 ;; Different permissions mean different SELINUX context. 3025 ;; Check different SELinux context. We cannot support
3027 (set-file-modes tmp-name1 #o777) 3026 ;; different ranges in this test; let's assume the most
3028 (set-file-modes tmp-name2 #o444) 3027 ;; likely one.
3029 (should-not 3028 (let ((context (file-selinux-context tmp-name1)))
3030 (equal 3029 (when (and (string-equal (nth 3 context) "s0")
3031 (file-selinux-context tmp-name1) 3030 (setcar (nthcdr 3 context) "s0:c0")
3032 (file-selinux-context tmp-name2))) 3031 (set-file-selinux-context tmp-name1 context))
3033 ;; Copy SELINUX context. 3032 (should-not
3033 (equal
3034 (file-selinux-context tmp-name1)
3035 (file-selinux-context tmp-name2)))))
3036 ;; Copy SELinux context.
3034 (should 3037 (should
3035 (set-file-selinux-context 3038 (set-file-selinux-context
3036 tmp-name2 (file-selinux-context tmp-name1))) 3039 tmp-name2 (file-selinux-context tmp-name1)))
@@ -3038,7 +3041,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3038 (equal 3041 (equal
3039 (file-selinux-context tmp-name1) 3042 (file-selinux-context tmp-name1)
3040 (file-selinux-context tmp-name2))) 3043 (file-selinux-context tmp-name2)))
3041 ;; An invalid SELINUX context does not harm. 3044 ;; An invalid SELinux context does not harm.
3042 (should-not (set-file-selinux-context tmp-name2 "foo"))) 3045 (should-not (set-file-selinux-context tmp-name2 "foo")))
3043 3046
3044 ;; Cleanup. 3047 ;; Cleanup.
@@ -3047,52 +3050,83 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3047 3050
3048 ;; Remote and local file. 3051 ;; Remote and local file.
3049 (unwind-protect 3052 (unwind-protect
3050 (when (not (or (equal (file-selinux-context temporary-file-directory) 3053 (when (and (not
3051 '(nil nil nil nil)) 3054 (or (equal (file-selinux-context temporary-file-directory)
3052 (tramp--test-windows-nt-or-smb-p))) 3055 '(nil nil nil nil))
3053 ;; Two files with same SELINUX context. 3056 (tramp--test-windows-nt-or-smb-p)))
3057 ;; Both users shall use the same SELinux context.
3058 (string-equal
3059 (let ((default-directory temporary-file-directory))
3060 (shell-command-to-string "id -Z"))
3061 (let ((default-directory
3062 tramp-test-temporary-file-directory))
3063 (shell-command-to-string "id -Z"))))
3064
3065 ;; Two files with same SELinux context.
3054 (write-region "foo" nil tmp-name1) 3066 (write-region "foo" nil tmp-name1)
3055 (should (file-exists-p tmp-name1)) 3067 (should (file-exists-p tmp-name1))
3056 (should (file-selinux-context tmp-name1)) 3068 (should (file-selinux-context tmp-name1))
3057 (copy-file tmp-name1 tmp-name3) 3069 (copy-file tmp-name1 tmp-name3)
3058 (should (file-selinux-context tmp-name3)) 3070 (should (file-selinux-context tmp-name3))
3071 ;; We cannot expect that copying over file system
3072 ;; boundaries keeps SELinux context. So we copy it
3073 ;; explicitely.
3074 (should
3075 (set-file-selinux-context
3076 tmp-name3 (file-selinux-context tmp-name1)))
3059 (should 3077 (should
3060 (equal 3078 (equal
3061 (file-selinux-context tmp-name1) 3079 (file-selinux-context tmp-name1)
3062 (file-selinux-context tmp-name3))) 3080 (file-selinux-context tmp-name3)))
3063 ;; Different permissions mean different SELINUX context. 3081 ;; Check different SELinux context. We cannot support
3064 (set-file-modes tmp-name1 #o777) 3082 ;; different ranges in this test; let's assume the most
3065 (set-file-modes tmp-name3 #o444) 3083 ;; likely one.
3066 (should-not 3084 (let ((context (file-selinux-context tmp-name1)))
3067 (equal 3085 (when (and (string-equal (nth 3 context) "s0")
3068 (file-selinux-context tmp-name1) 3086 (setcar (nthcdr 3 context) "s0:c0")
3069 (file-selinux-context tmp-name3))) 3087 (set-file-selinux-context tmp-name1 context))
3070 ;; Copy SELINUX context. 3088 (should-not
3071 (set-file-selinux-context 3089 (equal
3072 tmp-name3 (file-selinux-context tmp-name1)) 3090 (file-selinux-context tmp-name1)
3091 (file-selinux-context tmp-name3)))))
3092 ;; Copy SELinux context.
3093 (should
3094 (set-file-selinux-context
3095 tmp-name3 (file-selinux-context tmp-name1)))
3073 (should 3096 (should
3074 (equal 3097 (equal
3075 (file-selinux-context tmp-name1) 3098 (file-selinux-context tmp-name1)
3076 (file-selinux-context tmp-name3))) 3099 (file-selinux-context tmp-name3)))
3077 3100
3078 ;; Two files with same SELINUX context. 3101 ;; Two files with same SELinux context.
3079 (delete-file tmp-name1) 3102 (delete-file tmp-name1)
3080 (copy-file tmp-name3 tmp-name1) 3103 (copy-file tmp-name3 tmp-name1)
3081 (should (file-selinux-context tmp-name1)) 3104 (should (file-selinux-context tmp-name1))
3105 ;; We cannot expect that copying over file system
3106 ;; boundaries keeps SELinux context. So we copy it
3107 ;; explicitely.
3108 (should
3109 (set-file-selinux-context
3110 tmp-name1 (file-selinux-context tmp-name3)))
3082 (should 3111 (should
3083 (equal 3112 (equal
3084 (file-selinux-context tmp-name1) 3113 (file-selinux-context tmp-name1)
3085 (file-selinux-context tmp-name3))) 3114 (file-selinux-context tmp-name3)))
3086 ;; Different permissions mean different SELINUX context. 3115 ;; Check different SELinux context. We cannot support
3087 (set-file-modes tmp-name1 #o777) 3116 ;; different ranges in this test; let's assume the most
3088 (set-file-modes tmp-name3 #o444) 3117 ;; likely one.
3089 (should-not 3118 (let ((context (file-selinux-context tmp-name3)))
3090 (equal 3119 (when (and (string-equal (nth 3 context) "s0")
3091 (file-selinux-context tmp-name1) 3120 (setcar (nthcdr 3 context) "s0:c0")
3092 (file-selinux-context tmp-name3))) 3121 (set-file-selinux-context tmp-name3 context))
3093 ;; Copy SELINUX context. 3122 (should-not
3094 (set-file-selinux-context 3123 (equal
3095 tmp-name1 (file-selinux-context tmp-name2)) 3124 (file-selinux-context tmp-name1)
3125 (file-selinux-context tmp-name3)))))
3126 ;; Copy SELinux context.
3127 (should
3128 (set-file-selinux-context
3129 tmp-name1 (file-selinux-context tmp-name3)))
3096 (should 3130 (should
3097 (equal 3131 (equal
3098 (file-selinux-context tmp-name1) 3132 (file-selinux-context tmp-name1)
@@ -3619,7 +3653,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3619 (fboundp 'connection-local-set-profiles))) 3653 (fboundp 'connection-local-set-profiles)))
3620 3654
3621 ;; `connection-local-set-profile-variables' and 3655 ;; `connection-local-set-profile-variables' and
3622 ;; `connection-local-set-profiles' exist since Emacs 26. We don't 3656 ;; `connection-local-set-profiles' exist since Emacs 26.1. We don't
3623 ;; want to see compiler warnings for older Emacsen. 3657 ;; want to see compiler warnings for older Emacsen.
3624 (let ((default-directory tramp-test-temporary-file-directory) 3658 (let ((default-directory tramp-test-temporary-file-directory)
3625 explicit-shell-file-name kill-buffer-query-functions) 3659 explicit-shell-file-name kill-buffer-query-functions)
@@ -3923,8 +3957,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3923 (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory))) 3957 (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory)))
3924 3958
3925 ;; `make-nearby-temp-file' and `temporary-file-directory' exists 3959 ;; `make-nearby-temp-file' and `temporary-file-directory' exists
3926 ;; since Emacs 26. We don't want to see compiler warnings for older 3960 ;; since Emacs 26.1. We don't want to see compiler warnings for
3927 ;; Emacsen. 3961 ;; older Emacsen.
3928 (let ((default-directory tramp-test-temporary-file-directory) 3962 (let ((default-directory tramp-test-temporary-file-directory)
3929 tmp-file) 3963 tmp-file)
3930 ;; The remote host shall know a temporary file directory. 3964 ;; The remote host shall know a temporary file directory.
@@ -4622,7 +4656,8 @@ process sentinels. They shall not disturb each other."
4622 (message \"Tramp loaded: %%s\" (featurep 'tramp)) \ 4656 (message \"Tramp loaded: %%s\" (featurep 'tramp)) \
4623 (file-name-all-completions \"/foo:\" \"/\") \ 4657 (file-name-all-completions \"/foo:\" \"/\") \
4624 (message \"Tramp loaded: %%s\" (featurep 'tramp)))")) 4658 (message \"Tramp loaded: %%s\" (featurep 'tramp)))"))
4625 (dolist (tm '(t nil)) 4659 ;; Tramp doesn't load when `tramp-mode' is nil since Emacs 26.1.
4660 (dolist (tm (if (tramp--test-emacs26-p) '(t nil) '(nil)))
4626 (should 4661 (should
4627 (string-match 4662 (string-match
4628 (format 4663 (format