[2/9] zdtm: don't use find to get executable files

Submitted by Andrei Vagin on Sept. 29, 2017, 10:41 p.m.

Details

Message ID 20170929224145.6764-2-avagin@openvz.org
State Accepted
Series "Series without cover letter"
Commit 36002c2ed746ce2929470a797d83957e860d9715
Headers show

Commit Message

Andrei Vagin Sept. 29, 2017, 10:41 p.m.
From: Andrei Vagin <avagin@virtuozzo.com>

find: unrecognized: -executable
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 test/zdtm.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm.py b/test/zdtm.py
index 2e37087f5..b48301f03 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -1530,16 +1530,25 @@  class launcher:
 
 def all_tests(opts):
 	desc = eval(open(opts['set'] + '.desc').read())
-	lst = subprocess.Popen(['find', desc['dir'], '-type', 'f', '-executable'],
-			stdout = subprocess.PIPE)
+
+	files = []
+	mask = stat.S_IFREG | stat.S_IXUSR
+	for d in os.walk(desc['dir']):
+		for f in d[2]:
+			fp = os.path.join(d[0], f)
+			st = os.lstat(fp)
+			if (st.st_mode & mask) != mask:
+				continue
+			if stat.S_IFMT(st.st_mode) in [stat.S_IFLNK, stat.S_IFSOCK]:
+				continue
+			files.append(fp)
 	excl = map(lambda x: os.path.join(desc['dir'], x), desc['exclude'])
 	tlist = filter(lambda x:
 			not x.endswith('.checkskip') and
 			not x.endswith('.hook') and
 			x not in excl,
-			map(lambda x: x.strip(), lst.stdout.readlines())
+			map(lambda x: x.strip(), files)
 			)
-	lst.wait()
 	return tlist