summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-06-25 00:51:14 +0300
committerGitHub <noreply@github.com>2020-06-25 00:51:14 +0300
commit0b9dcb2edef710bb35f1d5f8848fb5ba97990f7a (patch)
tree5aa68d3b3325f4370196bffcf231fd27d1b6396b /numpy
parent4606d02d7a3eb8c2c377437af59139f6dc211a2c (diff)
parentccefd88a24ebbf3cb1d519bce43adf47addef986 (diff)
downloadnumpy-0b9dcb2edef710bb35f1d5f8848fb5ba97990f7a.tar.gz
Merge pull request #16674 from seiko2plus/test_cpu_failinfo
TEST: Add extra debugging information to CPU features detection
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_cpu_features.py54
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..bafa5a05f 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_features_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_features_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_features_equal(npy_have, cpu_have, feature_name)
def cpu_have(self, feature_name):
map_names = self.features_map.get(feature_name, feature_name)