diff options
| author | Sayed Adel <seiko@imavr.com> | 2020-06-24 03:07:51 +0200 |
|---|---|---|
| committer | Sayed Adel <seiko@imavr.com> | 2020-06-24 03:07:51 +0200 |
| commit | 42558db530074583da406eea22010b2e32e5deee (patch) | |
| tree | 7a4035e16ed6453f2b65aa45d22242c70da81ab3 /numpy | |
| parent | 7af10245239f7b928eafef02264e7c3b48b470bd (diff) | |
| download | numpy-42558db530074583da406eea22010b2e32e5deee.tar.gz | |
TEST: Add extra debugging information to CPU features detection
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/tests/test_cpu_features.py | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/numpy/core/tests/test_cpu_features.py b/numpy/core/tests/test_cpu_features.py index 337b7330c..44671b61c 100644 --- a/numpy/core/tests/test_cpu_features.py +++ b/numpy/core/tests/test_cpu_features.py @@ -1,8 +1,53 @@ import sys, platform, re, pytest - -from numpy.testing import assert_equal from numpy.core._multiarray_umath import __cpu_features__ +def assert_equal(actual, desired, fname): + __tracebackhide__ = True # Hide traceback for py.test + actual, desired = str(actual), str(desired) + if actual == desired: + return + detected = str(__cpu_features__).replace("'", "") + try: + with open("/proc/cpuinfo", "r") as fd: + cpuinfo = fd.read(2048) + except Exception as err: + cpuinfo = str(err) + + try: + import subprocess + auxv = subprocess.check_output(['/bin/true'], env=dict(LD_SHOW_AUXV="1")) + auxv = auxv.decode() + except Exception as err: + auxv = str(err) + + import textwrap + error_report = textwrap.indent( +""" +########################################### +### Extra debugging information +########################################### +------------------------------------------- +--- NumPy Detections +------------------------------------------- +%s +------------------------------------------- +--- SYS / CPUINFO +------------------------------------------- +%s.... +------------------------------------------- +--- SYS / AUXV +------------------------------------------- +%s +""" % (detected, cpuinfo, auxv), prefix='\r') + + raise AssertionError(( + "Failure Detection\n" + " NAME: '%s'\n" + " ACTUAL: %s\n" + " DESIRED: %s\n" + "%s" + ) % (fname, actual, desired, error_report)) + class AbstractTest(object): features = [] features_groups = {} @@ -12,17 +57,16 @@ class AbstractTest(object): def load_flags(self): # a hook pass - def test_features(self): self.load_flags() for gname, features in self.features_groups.items(): test_features = [self.cpu_have(f) for f in features] - assert_equal(__cpu_features__.get(gname), all(test_features)) + assert_equal(__cpu_features__.get(gname), all(test_features), gname) for feature_name in self.features: cpu_have = self.cpu_have(feature_name) npy_have = __cpu_features__.get(feature_name) - assert_equal(npy_have, cpu_have) + assert_equal(npy_have, cpu_have, feature_name) def cpu_have(self, feature_name): map_names = self.features_map.get(feature_name, feature_name) |
