tests: fix false failure due to gdb inline function handling
[coreutils.git] / tests / d_type-check
blob33c1fd6d0b8cee979a08db9076da31691ca46024
1 #!/usr/bin/python
2 # Exit 0 if "." has useful d_type information, else 1.
3 # Intended to exit 0 only on Linux/GNU systems.
4 import sys
6 fail = 1
7 try:
8 import ctypes
10 (DT_UNKNOWN, DT_DIR,) = (0, 4,)
12 class dirent(ctypes.Structure):
13 _fields_ = [
14 ("d_ino", ctypes.c_long),
15 ("d_off", ctypes.c_long),
16 ("d_reclen", ctypes.c_ushort),
17 ("d_type", ctypes.c_ubyte),
18 ("d_name", ctypes.c_char*256)]
20 direntp = ctypes.POINTER(dirent)
22 # FIXME: find a way to avoid hard-coding libc's so-name.
23 libc = ctypes.cdll.LoadLibrary("libc.so.6")
24 libc.readdir.restype = direntp
26 dirp = libc.opendir(".")
27 if dirp:
28 ep = libc.readdir(dirp)
29 if ep:
30 name = ep.contents.d_name
31 if (name == "." or name == "..") and ep.contents.d_type == DT_DIR:
32 fail = 0
34 except:
35 pass
37 sys.exit(fail)