(actual, desired, fname)
| 11 | import re |
| 12 | |
| 13 | def assert_features_equal(actual, desired, fname): |
| 14 | __tracebackhide__ = True # Hide traceback for py.test |
| 15 | actual, desired = str(actual), str(desired) |
| 16 | if actual == desired: |
| 17 | return |
| 18 | detected = str(__cpu_features__).replace("'", "") |
| 19 | try: |
| 20 | with open("/proc/cpuinfo") as fd: |
| 21 | cpuinfo = fd.read(2048) |
| 22 | except Exception as err: |
| 23 | cpuinfo = str(err) |
| 24 | |
| 25 | try: |
| 26 | import subprocess |
| 27 | auxv = subprocess.check_output(['/bin/true'], env=dict(LD_SHOW_AUXV="1")) |
| 28 | auxv = auxv.decode() |
| 29 | except Exception as err: |
| 30 | auxv = str(err) |
| 31 | |
| 32 | import textwrap |
| 33 | error_report = textwrap.indent( |
| 34 | """ |
| 35 | ########################################### |
| 36 | ### Extra debugging information |
| 37 | ########################################### |
| 38 | ------------------------------------------- |
| 39 | --- NumPy Detections |
| 40 | ------------------------------------------- |
| 41 | %s |
| 42 | ------------------------------------------- |
| 43 | --- SYS / CPUINFO |
| 44 | ------------------------------------------- |
| 45 | %s.... |
| 46 | ------------------------------------------- |
| 47 | --- SYS / AUXV |
| 48 | ------------------------------------------- |
| 49 | %s |
| 50 | """ % (detected, cpuinfo, auxv), prefix='\r') |
| 51 | |
| 52 | raise AssertionError(( |
| 53 | "Failure Detection\n" |
| 54 | " NAME: '%s'\n" |
| 55 | " ACTUAL: %s\n" |
| 56 | " DESIRED: %s\n" |
| 57 | "%s" |
| 58 | ) % (fname, actual, desired, error_report)) |
| 59 | |
| 60 | def _text_to_list(txt): |
| 61 | out = txt.strip("][\n").replace("'", "").split(', ') |
no test coverage detected