autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/1] tests: add test for AS_EXECUTABLE_P


From: Eric Blake
Subject: [PATCH 2/1] tests: add test for AS_EXECUTABLE_P
Date: Sat, 25 Feb 2012 07:16:38 -0700

Now that this is public, we should regression test it.

* tests/m4sh.at (AS@&address@hidden): New test.

Signed-off-by: Eric Blake <address@hidden>
---
 tests/m4sh.at |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/tests/m4sh.at b/tests/m4sh.at
index e9da403..38667e4 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -552,6 +552,58 @@ AT_CLEANUP



+## ----------------- ##
+## AS_EXECUTABLE_P.  ##
+## ----------------- ##
+
+# Check for executable regular files.
+AT_SETUP([AS@&address@hidden)
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+
+if AS_EXECUTABLE_P([/]); then
+  echo fail
+else
+  echo 1
+fi
+cat > foo.sh <<\EOF || AS_EXIT([1])
+#/bin/sh
+exit 0
+EOF
+# File systems like FAT tend to fake executable permissions on all files.
+# At this point, foo.sh should be executable iff permissions are faked.
+AS_EXECUTABLE_P([foo.sh])
+st1=$?
+(./foo.sh) >/dev/null 2>&1
+st2=$?
+case $st1:$st2 in
+  1:126 | 0:0 ) echo 2 ;;
+  *) echo "fail ($st1:$st2)" ;;
+esac
+# Now things better be executable
+chmod a+x foo.sh || AS_EXIT([2])
+mkdir 'two  spaces' || AS_EXIT([3])
+'two  spaces'/../foo.sh || AS_EXIT([4])
+if AS_EXECUTABLE_P(["two  spaces/../foo.sh"]); then
+  echo 3
+else
+  echo fail
+fi
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([$CONFIG_SHELL ./script], [],
+[[1
+2
+3
+]])
+
+AT_CLEANUP
+
+
+
 ## --------- ##
 ## AS_EXIT.  ##
 ## --------- ##
-- 
1.7.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]