summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-02-10 04:08:22 -0800
committerKaz Kylheku <kaz@kylheku.com>2020-02-10 04:08:22 -0800
commit559a999fe21f89d0f297cf6feb9a2b01da773400 (patch)
tree43e4f7d1cd5a17dca4b6e1577f72d822f079c4a7 /tests
parentfe9c356178d9668c26448707d491e8d02be2f196 (diff)
downloadtxr-559a999fe21f89d0f297cf6feb9a2b01da773400.tar.gz
txr-559a999fe21f89d0f297cf6feb9a2b01da773400.tar.bz2
txr-559a999fe21f89d0f297cf6feb9a2b01da773400.zip
chmod tests: avoid sticky bit when not available.
On Solaris, we can't set the sticky bit on a non-directory without special privilege. Let's detect whether we can set the sticky bit on our test object. If we can't, then we avoid executing tests that involve the sticky bit. * tests/018/chmod.tl (test-sticky): New variable. (cht): If test-sticky is false, only run the test if none of the inputs contain a 't'.
Diffstat (limited to 'tests')
-rw-r--r--tests/018/chmod.tl43
1 files changed, 25 insertions, 18 deletions
diff --git a/tests/018/chmod.tl b/tests/018/chmod.tl
index 7963f303..ada3f0be 100644
--- a/tests/018/chmod.tl
+++ b/tests/018/chmod.tl
@@ -3,28 +3,35 @@
(defvarl tgt [*args* 0])
+(remove-path tgt)
+(with-stream (s (open-file tgt "w")))
+(umask #o022)
+
+(defvarl test-sticky (progn
+ (chmod tgt s-isvtx)
+ (let ((st (stat tgt)))
+ (plusp (logand s-isvtx st.mode)))))
+
(defmacro mode-bits (st-mode)
^(logand ,st-mode #xFFF))
(defun cht (init mode expected)
- (let ((ini (dec-perm init))
- (exp (dec-perm expected)))
- (chmod tgt ini)
- (let* ((st (stat tgt))
- (m (mode-bits st.mode)))
- (unless (eql m ini)
- (error "failed to set initial mode: expected: ~s, actual: ~s "
- init (enc-perm m))))
- (chmod tgt mode)
- (let* ((st (stat tgt))
- (m (mode-bits st.mode)))
- (unless (eql m exp)
- (error "failed to set mode with ~s: expected ~s, actual ~s"
- mode expected (enc-perm m))))))
-
-(remove-path tgt)
-(with-stream (s (open-file tgt "w")))
-(umask #o022)
+ (when (or test-sticky
+ (not (find #\t `@init@mode@expected`)))
+ (let ((ini (dec-perm init))
+ (exp (dec-perm expected)))
+ (chmod tgt ini)
+ (let* ((st (stat tgt))
+ (m (mode-bits st.mode)))
+ (unless (eql m ini)
+ (error "failed to set initial mode: expected: ~s, actual: ~s "
+ init (enc-perm m))))
+ (chmod tgt mode)
+ (let* ((st (stat tgt))
+ (m (mode-bits st.mode)))
+ (unless (eql m exp)
+ (error "failed to set mode with ~s: expected ~s, actual ~s"
+ mode expected (enc-perm m)))))))
(cht "------------" "a+strwx" "sgtrwxrwxrwx")
(cht "------------" "+strwx" "sgtrwxr-xr-x")