File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ include setup_cptrace.py
2222
2323# Tests
2424include runtests.py
25- include test_doc .py
25+ include check_doc .py
2626include tests/test_*.py
2727include tests/crash/*.c
2828include tests/crash/BSDmakefile
Original file line number Diff line number Diff line change 22from doctest import testfile , ELLIPSIS , testmod
33from sys import exit , path as sys_path
44from os .path import dirname
5+ import importlib
56
67
78def testDoc (filename , name = None ):
@@ -13,17 +14,9 @@ def testDoc(filename, name=None):
1314 print ("--- %s: End of tests" % filename )
1415
1516
16- def importModule (name ):
17- mod = __import__ (name )
18- components = name .split ('.' )
19- for comp in components [1 :]:
20- mod = getattr (mod , comp )
21- return mod
22-
23-
2417def testModule (name ):
2518 print ("--- Test module %s" % name )
26- module = importModule (name )
19+ module = importlib . import_module (name )
2720 failure , nb_test = testmod (module )
2821 if failure :
2922 exit (1 )
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ Run tests manually
8484Type::
8585
8686 python3 runtests.py
87- python3 test_doc .py
87+ python3 check_doc .py
8888
8989It's also possible to run a specific test::
9090
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ trace () {
4+ (
5+ set +e
6+ python ../../strace.py -e execve $1 ; ec=$?
7+ if [ $ec -gt 0 ]; then
8+ exit $(( $ec - 128 - $2 ))
9+ fi
10+ )
11+ }
12+
13+ if command -v gcc && command -v make && command -v kill ; then
14+ make || exit
15+
16+ # trace ./invalid_read $(kill -l SEGV) |& tee /dev/stderr | grep -q 'Invalid read from'
17+ trace ./invalid_read $( kill -l SEGV) # 2>&1 | grep -q 'Invalid read from'
18+ trace ./invalid_write $( kill -l SEGV) # 2>&1 | grep -q 'Invalid write to'
19+ trace ./stack_overflow $( kill -l SEGV) # 2>&1 | grep -q 'STACK OVERFLOW!'
20+ trace ./call_null $( kill -l SEGV)
21+ trace ./abort $( kill -l ABRT)
22+ trace ./div_zero $( kill -l FPE)
23+ trace ./socket_ipv4_tcp
24+ trace ./pthread
25+ trace ./execve
26+ trace ./fork
27+ fi
Original file line number Diff line number Diff line change 11char toto ()
22{
3- char buffer [4096 ];
4- buffer [0 ] = 0 ;
3+ volatile unsigned char buffer [4096 ];
4+ buffer [0 ] = 1 ;
5+ buffer [4095 ] = 0 ;
56 toto ();
67 return buffer [0 ] + buffer [sizeof (buffer )- 1 ];
78}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ envlist = py3, pep8
44[testenv]
55basepython = python3
66commands =
7- python test_doc .py
7+ python check_doc .py
88 python runtests.py -v
99
1010[testenv:py3]
@@ -13,7 +13,7 @@ basepython = python3
1313[testenv:pep8]
1414deps = flake8
1515commands =
16- flake8 ptrace/ tests/ gdb.py runtests.py setup_cptrace.py setup.py strace.py SYSCALL_PROTOTYPES.codegen.py test_doc .py
16+ flake8 ptrace/ tests/ gdb.py runtests.py setup_cptrace.py setup.py strace.py SYSCALL_PROTOTYPES.codegen.py check_doc .py
1717
1818[flake8]
1919# E501 line too long (88 > 79 characters)
You can’t perform that action at this time.
0 commit comments