Skip to content

Commit 5cb5246

Browse files
committed
tests/ffi_float: Split tgammaf() testcase to a separate test.
Some libc's may implement tgammaf as a header macro using tgamma(), so don't assume it'll be in the library.
1 parent a66a99b commit 5cb5246

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

tests/unix/ffi_float.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def ffi_open(names):
2828
# test passing double and float args
2929
libm = ffi_open(('libm.so', 'libm.so.6', 'libc.so.0', 'libc.so.6', 'libc.dylib'))
3030
tgamma = libm.func('d', 'tgamma', 'd')
31-
tgammaf = libm.func('f', 'tgammaf', 'f')
32-
for fun in (tgamma, tgammaf):
31+
for fun in (tgamma,):
3332
for val in (0.5, 1, 1.0, 1.5, 4, 4.0):
3433
print('%.6f' % fun(val))

tests/unix/ffi_float.py.exp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,3 @@
66
0.886227
77
6.000000
88
6.000000
9-
1.772454
10-
1.000000
11-
1.000000
12-
0.886227
13-
6.000000
14-
6.000000

tests/unix/ffi_float2.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# test ffi float support
2+
import sys
3+
try:
4+
import ffi
5+
except ImportError:
6+
print("SKIP")
7+
sys.exit()
8+
9+
10+
def ffi_open(names):
11+
err = None
12+
for n in names:
13+
try:
14+
mod = ffi.open(n)
15+
return mod
16+
except OSError as e:
17+
err = e
18+
raise err
19+
20+
libm = ffi_open(('libm.so', 'libm.so.6', 'libc.so.0', 'libc.so.6', 'libc.dylib'))
21+
22+
# Some libc's implement tgammaf as header macro with tgamma(), so don't assume
23+
# it'll be in library.
24+
try:
25+
tgammaf = libm.func('f', 'tgammaf', 'f')
26+
except OSError:
27+
print("SKIP")
28+
sys.exit()
29+
30+
for fun in (tgammaf,):
31+
for val in (0.5, 1, 1.0, 1.5, 4, 4.0):
32+
print('%.6f' % fun(val))

tests/unix/ffi_float2.py.exp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1.772454
2+
1.000000
3+
1.000000
4+
0.886227
5+
6.000000
6+
6.000000

0 commit comments

Comments
 (0)