From 374580a85dbfccec2fb12b39a7184c6b1b4c0af8 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 21 Mar 2019 21:31:27 -0400 Subject: [PATCH] create integration tests --- tests/TEST_no_fuse_hidden | 19 ++++++++++++++++++ tests/TEST_use_fchmod_after_unlink | 15 +++++++++++++++ tests/TEST_use_fchown_after_unlink | 15 +++++++++++++++ tests/TEST_use_fstat_after_unlink | 15 +++++++++++++++ tests/run-tests | 31 ++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100755 tests/TEST_no_fuse_hidden create mode 100755 tests/TEST_use_fchmod_after_unlink create mode 100755 tests/TEST_use_fchown_after_unlink create mode 100755 tests/TEST_use_fstat_after_unlink create mode 100755 tests/run-tests diff --git a/tests/TEST_no_fuse_hidden b/tests/TEST_no_fuse_hidden new file mode 100755 index 00000000..5a7274f0 --- /dev/null +++ b/tests/TEST_no_fuse_hidden @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import os +import sys +import tempfile + +(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1]) + +ino = os.fstat(fd).st_ino + +os.unlink(filepath) + +for entry in os.scandir(sys.argv[1]): + if entry.inode() == ino: + print("found .fuse_hidden file {}".format(entry.name),end='') + os.close(fd) + sys.exit(1) + +os.close(fd) diff --git a/tests/TEST_use_fchmod_after_unlink b/tests/TEST_use_fchmod_after_unlink new file mode 100755 index 00000000..3b2d582e --- /dev/null +++ b/tests/TEST_use_fchmod_after_unlink @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import os +import sys +import tempfile + +(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1]) + +os.fchmod(fd,0o777) + +os.unlink(filepath) + +os.fchmod(fd,0o777) + +os.close(fd) diff --git a/tests/TEST_use_fchown_after_unlink b/tests/TEST_use_fchown_after_unlink new file mode 100755 index 00000000..73529a3f --- /dev/null +++ b/tests/TEST_use_fchown_after_unlink @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import os +import sys +import tempfile + +(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1]) + +os.fchown(fd,os.getuid(),os.getgid()) + +os.unlink(filepath) + +os.fchown(fd,os.getuid(),os.getgid()) + +os.close(fd) diff --git a/tests/TEST_use_fstat_after_unlink b/tests/TEST_use_fstat_after_unlink new file mode 100755 index 00000000..0b3758cf --- /dev/null +++ b/tests/TEST_use_fstat_after_unlink @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +import os +import sys +import tempfile + +(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1]) + +os.fstat(fd) + +os.unlink(filepath) + +os.fstat(fd) + +os.close(fd) diff --git a/tests/run-tests b/tests/run-tests new file mode 100755 index 00000000..a8fb658b --- /dev/null +++ b/tests/run-tests @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + + +if len(sys.argv) != 2: + print('usage: run-test \n',file=sys.stderr) + sys.exit(1) + +test_path = os.path.realpath(sys.argv[0]) +test_path = os.path.dirname(test_path) + +for entry in os.scandir(test_path): + if not entry.name.startswith('TEST_'): + continue + + try: + print(entry.name + ': ',end='') + fullpath = os.path.join(test_path,entry.name) + args = [fullpath,sys.argv[1]] + rv = subprocess.Popen(args,stdout=subprocess.PIPE) + rv.wait(timeout=10000) + if rv.returncode: + output = rv.stdout.read().decode() + print('FAIL - {}'.format(output)) + else: + print('PASS') + except Exception as e: + print('FAIL - {}'.format(e))