aboutsummaryrefslogtreecommitdiff
path: root/test/libcxx/test/target_info.py
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
commit61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch)
treeec41ed70ffca97240e76f9a78bb2dedba28f310c /test/libcxx/test/target_info.py
parentf857581820d15e410e9945d2fcd5f7163be25a96 (diff)
downloadsrc-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.tar.gz
src-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.zip
Import libc++ 3.7.0 release (r246257).vendor/libc++/libc++-release_370-r246257
Notes
Notes: svn path=/vendor/libc++/dist/; revision=287518 svn path=/vendor/libc++/libc++-release_370-r246257/; revision=287519; tag=vendor/libc++/libc++-release_370-r246257
Diffstat (limited to 'test/libcxx/test/target_info.py')
-rw-r--r--test/libcxx/test/target_info.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py
new file mode 100644
index 000000000000..a61737786896
--- /dev/null
+++ b/test/libcxx/test/target_info.py
@@ -0,0 +1,55 @@
+import locale
+import platform
+import sys
+
+class TargetInfo(object):
+ def platform(self):
+ raise NotImplementedError
+
+ def system(self):
+ raise NotImplementedError
+
+ def platform_ver(self):
+ raise NotImplementedError
+
+ def platform_name(self):
+ raise NotImplementedError
+
+ def supports_locale(self, loc):
+ raise NotImplementedError
+
+
+class LocalTI(TargetInfo):
+ def platform(self):
+ platform_name = sys.platform.lower().strip()
+ # Strip the '2' from linux2.
+ if platform_name.startswith('linux'):
+ platform_name = 'linux'
+ return platform_name
+
+ def system(self):
+ return platform.system()
+
+ def platform_name(self):
+ if self.platform() == 'linux':
+ name, _, _ = platform.linux_distribution()
+ name = name.lower().strip()
+ if name:
+ return name
+ return None
+
+ def platform_ver(self):
+ if self.platform() == 'linux':
+ _, ver, _ = platform.linux_distribution()
+ ver = ver.lower().strip()
+ if ver:
+ return ver
+ return None
+
+ def supports_locale(self, loc):
+ try:
+ locale.setlocale(locale.LC_ALL, loc)
+ return True
+ except locale.Error:
+ return False
+