blob: eb76d35b36bbffbb25cd90bb4dc83ed2ea582ca1 (
about) (
plain)
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
|
#!/usr/bin/python3 -u
import sys;
import time;
from ctypes import *;
testlib = CDLL( "./libpcdlltest.so" );
print( testlib );
testlib.testfunc.restype = c_void_p;
testlib.testfunc2.restype = c_void_p;
testlib.testfunc3.restype = c_char_p;
testlib.cleanup_buffer.restype = c_void_p;
print( "Executing first test function (simple message from C code)" );
testlib.testfunc();
print( "Executing test function 2 (pass python value to it)" );
pvar = create_string_buffer( bytes("test message", "utf8") );
testlib.testfunc2( pvar );
del pvar;
print( "Executing test function 3 (return value from C code)" );
test_value = testlib.testfunc3().decode("utf8");
print( f"Returned value: {test_value}" );
del test_value;
print( "Executing buffer cleanup functiion" );
testlib.cleanup_buffer();
print( "Starting C thread" );
testlib.threadstarter();
print( "Printing garbage from python code" );
for pcount in range(0, 40):
print( f"Count is now in python {pcount}" );
time.sleep( 1 );
print( "All tests done" );
del testlib;
sys.exit( 0 );
|