about summary refs log tree commit diff
path: root/Test/P01privileged.ztst
diff options
context:
space:
mode:
authorJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2022-04-12 16:56:18 +0900
committerJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2022-04-12 16:56:18 +0900
commit06e5ec914fdedac6446e02c9427a1706dda9c505 (patch)
treeaddf373faf77728f9276179e681eb5f7ea9f7b38 /Test/P01privileged.ztst
parent3622551e0270372cc3b0b6e974d85ab1288a2aa7 (diff)
downloadzsh-06e5ec914fdedac6446e02c9427a1706dda9c505.tar.gz
zsh-06e5ec914fdedac6446e02c9427a1706dda9c505.tar.xz
zsh-06e5ec914fdedac6446e02c9427a1706dda9c505.zip
50013: skip %test if a chunk in %prep fails
Only %test is skipped if a chunk in %prep returns nonzero. Both %test
and %clean are skipped if ZTST_unimplemented is set in a chunk of %prep.
ZTST_cleanup is run in both cases.
Diffstat (limited to 'Test/P01privileged.ztst')
-rw-r--r--Test/P01privileged.ztst23
1 files changed, 12 insertions, 11 deletions
diff --git a/Test/P01privileged.ztst b/Test/P01privileged.ztst
index 7c4a1be35..5d45c1a4c 100644
--- a/Test/P01privileged.ztst
+++ b/Test/P01privileged.ztst
@@ -26,23 +26,23 @@
 
 %prep
 
-  # Mind your empty lines here. The logic in this %prep section is somewhat
-  # complex compared to most others; to avoid lots of nested/duplicated
-  # conditions we need to make sure that this all gets executed as a single
-  # function from which we can return early
+  # If ZTST_unimplemented is set to non-null in a chunk then all the
+  # remaining chunks (and all of %test and %clean sections) will be skipped.
   [[ $EUID == 0 || -n $ZSH_TEST_UNPRIVILEGED_UID$ZSH_TEST_UNPRIVILEGED_GID ]] || {
     ZTST_unimplemented='PRIVILEGED tests require super-user privileges (or env var)'
-    return 1
+    return 0
   }
+
   (( $+commands[perl] )) || { # @todo Eliminate this dependency with a C wrapper?
     ZTST_unimplemented='PRIVILEGED tests require Perl'
-    return 1
+    return 0
   }
+
   grep -qE '#define HAVE_SETRES?UID' $ZTST_testdir/../config.h || {
     ZTST_unimplemented='PRIVILEGED tests require setreuid()/setresuid()'
-    return 1
+    return 0
   }
-  #
+
   ruid= euid= rgid= egid=
   #
   if [[ -n $ZSH_TEST_UNPRIVILEGED_UID ]]; then
@@ -76,13 +76,14 @@
   #
   [[ -n $ruid && -n $euid ]] || {
     ZTST_unimplemented='PRIVILEGED tests require unprivileged UID:EUID'
-    return 1
+    return 0
   }
+
   [[ -n $rgid || -n $egid ]] || {
     ZTST_unimplemented='PRIVILEGED tests require unprivileged GID:EGID'
-    return 1
+    return 0
   }
-  #
+
   print -ru$ZTST_fd \
     "Using unprivileged UID $ruid, EUID $euid, GID $rgid, EGID $egid"
   #