File: run-tests.py

package info (click to toggle)
python-crc32c 2.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 252 kB
  • sloc: ansic: 867; python: 172; makefile: 2; sh: 2
file content (38 lines) | stat: -rw-r--r-- 802 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import subprocess as sp
import sys

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))


def run(cmd):
    print(" ".join(cmd))
    sp.check_call(cmd)


def run_tests():
    run(
        [
            sys.executable,
            "-c",
            "import crc32c; print('Is big endian? ', crc32c.big_endian)",
        ]
    )
    run([sys.executable, "-mpytest", os.path.join(SCRIPT_DIR, "test")])
    run(
        [
            sys.executable,
            "-c",
            "import crc32c; import time; x = b' ' * int(1e9); n = 10; s = time.time(); [crc32c.crc32c(x) for _ in range(n)]; print('Ran at %.3f [GB/s]' % (n/(time.time() - s),))",
        ]
    )


def main():
    run_tests()
    os.environ["CRC32C_SW_MODE"] = "force"
    run_tests()


if __name__ == "__main__":
    main()