File: test_debug.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (78 lines) | stat: -rw-r--r-- 2,439 bytes parent folder | download | duplicates (2)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import py

from pypy.interpreter.gateway import interp2app
from rpython.rlib import debug


class AppTestDebug:
    spaceconfig = dict(usemodules=['__pypy__'])

    def setup_class(cls):
        if cls.runappdirect:
            py.test.skip("not meant to be run with -A")
        cls.w_check_log = cls.space.wrap(interp2app(cls.check_log))

    def setup_method(self, meth):
        debug._log = debug.DebugLog()

    def teardown_method(self, meth):
        debug._log = None

    @staticmethod
    def check_log(space, w_expected):
        assert list(debug._log) == space.unwrap(w_expected)

    def test_debug_print(self):
        from __pypy__ import debug_start, debug_stop, debug_print
        debug_start('my-category')
        debug_print('one')
        debug_print('two', 3, [])
        debug_stop('my-category')
        self.check_log([
                ('my-category', [
                        ('debug_print', 'one'),
                        ('debug_print', 'two 3 []'),
                        ])
                ])

    def test_debug_print_once(self):
        from __pypy__ import debug_print_once
        debug_print_once('foobar', 'hello world')
        self.check_log([
                ('foobar', [
                        ('debug_print', 'hello world'),
                        ])
                ])

    def test_debug_flush(self):
        from __pypy__ import debug_flush
        debug_flush()
        # assert did not crash

    def test_debug_read_timestamp(self):
        from __pypy__ import debug_read_timestamp
        a = debug_read_timestamp()
        b = debug_read_timestamp()
        assert b > a

    def test_debug_get_timestamp_unit(self):
        from __pypy__ import debug_get_timestamp_unit
        unit = debug_get_timestamp_unit()
        assert unit in ('tsc', 'ns', 'QueryPerformanceCounter')

    def test_debug_start_stop_timestamp(self):
        import time
        from __pypy__ import debug_start, debug_stop, debug_read_timestamp
        assert debug_start('foo') is None
        assert debug_stop('foo') is None
        ts1 = debug_start('foo', timestamp=True)
        t = time.process_time()
        while time.process_time() - t < 0.02:
            pass
        ts2 = debug_stop('foo', timestamp=True)
        assert ts2 > ts1

    def test_remote_exec_exists(self):
        import __pypy__
        assert hasattr(__pypy__, 'remote_exec')
        # real test in test_pypy_remote_debug.py