File: test_rsignal.py

package info (click to toggle)
pypy 5.6.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 97,040 kB
  • ctags: 185,069
  • sloc: python: 1,147,862; ansic: 49,642; cpp: 5,245; asm: 5,169; makefile: 529; sh: 481; xml: 232; lisp: 45
file content (39 lines) | stat: -rw-r--r-- 973 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
import os, py
from rpython.translator.c.test.test_genc import compile
from rpython.rlib import rsignal

def setup_module(mod):
    if not hasattr(os, 'kill') or not hasattr(os, 'getpid'):
        py.test.skip("requires os.kill() and os.getpid()")
    if not hasattr(rsignal, 'SIGUSR1'):
        py.test.skip("requires SIGUSR1 in signal")


def check(expected):
    res = rsignal.pypysig_poll()
    os.write(1, "poll() => %d, expected %d\n" % (res, expected))
    assert res == expected

def test_simple():
    import os
    check(-1)
    check(-1)
    for i in range(3):
        rsignal.pypysig_setflag(rsignal.SIGUSR1)
        os.kill(os.getpid(), rsignal.SIGUSR1)
        check(rsignal.SIGUSR1)
        check(-1)
        check(-1)

    rsignal.pypysig_ignore(rsignal.SIGUSR1)
    os.kill(os.getpid(), rsignal.SIGUSR1)
    check(-1)
    check(-1)

    rsignal.pypysig_default(rsignal.SIGUSR1)
    check(-1)


def test_compile():
    fn = compile(test_simple, [])
    fn()