summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support/filesystem_dynamic_test_helper.py
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-06-17 19:46:40 +0000
committerEric Fiselier <eric@efcs.ca>2016-06-17 19:46:40 +0000
commitc79795874adef276115f8bcf0b46da4155d2d46d (patch)
tree3c58305df7b6b28f1626e65f704ca3aba480be3a /libcxx/test/support/filesystem_dynamic_test_helper.py
parent7a5813597dad665e4461372edbc3a6ea8e8cb8f0 (diff)
downloadbcm5719-llvm-c79795874adef276115f8bcf0b46da4155d2d46d.tar.gz
bcm5719-llvm-c79795874adef276115f8bcf0b46da4155d2d46d.zip
Add Filesystem TS -- Complete
Add the completed std::experimental::filesystem implementation and tests. The implementation supports C++11 or newer. The TS is built as part of 'libc++experimental.a'. Users of the TS need to manually link this library. Building and testing the TS can be disabled using the CMake option '-DLIBCXX_ENABLE_FILESYSTEM=OFF'. Currently 'libc++experimental.a' is not installed by default. To turn on the installation of the library use '-DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON'. llvm-svn: 273034
Diffstat (limited to 'libcxx/test/support/filesystem_dynamic_test_helper.py')
-rw-r--r--libcxx/test/support/filesystem_dynamic_test_helper.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/libcxx/test/support/filesystem_dynamic_test_helper.py b/libcxx/test/support/filesystem_dynamic_test_helper.py
new file mode 100644
index 00000000000..1f48c952798
--- /dev/null
+++ b/libcxx/test/support/filesystem_dynamic_test_helper.py
@@ -0,0 +1,85 @@
+import sys
+import os
+import stat
+
+# Ensure that this is being run on a specific platform
+assert sys.platform.startswith('linux') or sys.platform.startswith('darwin') \
+ or sys.platform.startswith('cygwin') or sys.platform.startswith('freebsd')
+
+def env_path():
+ ep = os.environ.get('LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT')
+ assert ep is not None
+ ep = os.path.realpath(ep)
+ assert os.path.isdir(ep)
+ return ep
+
+env_path_global = env_path()
+
+# Make sure we don't try and write outside of env_path.
+# All paths used should be sanitized
+def sanitize(p):
+ p = os.path.realpath(p)
+ if os.path.commonprefix([env_path_global, p]):
+ return p
+ assert False
+
+"""
+Some of the tests restrict permissions to induce failures.
+Before we delete the test enviroment, we have to walk it and re-raise the
+permissions.
+"""
+def clean_recursive(root_p):
+ if not os.path.islink(root_p):
+ os.chmod(root_p, 0o777)
+ for ent in os.listdir(root_p):
+ p = os.path.join(root_p, ent)
+ if os.path.islink(p) or not os.path.isdir(p):
+ os.remove(p)
+ else:
+ assert os.path.isdir(p)
+ clean_recursive(p)
+ os.rmdir(p)
+
+
+def init_test_directory(root_p):
+ root_p = sanitize(root_p)
+ assert not os.path.exists(root_p)
+ os.makedirs(root_p)
+
+
+def destroy_test_directory(root_p):
+ root_p = sanitize(root_p)
+ clean_recursive(root_p)
+ os.rmdir(root_p)
+
+
+def create_file(fname, size):
+ with open(sanitize(fname), 'w') as f:
+ f.write('c' * size)
+
+
+def create_dir(dname):
+ os.mkdir(sanitize(dname))
+
+
+def create_symlink(source, link):
+ os.symlink(sanitize(source), sanitize(link))
+
+
+def create_hardlink(source, link):
+ os.link(sanitize(source), sanitize(link))
+
+
+def create_fifo(source):
+ os.mkfifo(sanitize(source))
+
+
+def create_socket(source):
+ mode = 0600|stat.S_IFSOCK
+ os.mknod(sanitize(source), mode)
+
+
+if __name__ == '__main__':
+ command = " ".join(sys.argv[1:])
+ eval(command)
+ sys.exit(0)
OpenPOWER on IntegriCloud