| 1 |
mock_conf = configuration_data() |
| 2 |
|
| 3 |
mock_conf.set( |
| 4 |
'HAVE_GLIBC_IOCTL', |
| 5 |
cc.compiles( |
| 6 |
'''#include <sys/ioctl.h> |
| 7 |
int ioctl(int fd, unsigned long request, ...); |
| 8 |
''', |
| 9 |
name: 'ioctl has glibc-style prototype' |
| 10 |
), |
| 11 |
description: 'Is ioctl the glibc interface (rather than POSIX)' |
| 12 |
) |
| 13 |
|
| 14 |
mock_ioctl = library( |
| 15 |
'mock-ioctl', |
| 16 |
['mock.c', 'util.c'], |
| 17 |
include_directories: [incdir, internal_incdir], |
| 18 |
dependencies: [dl_dep], |
| 19 |
c_args: ['-DHAVE_GLIBC_IOCTL=' + (mock_conf.get('HAVE_GLIBC_IOCTL') ? '1' : '0')]) |
| 20 |
|
| 21 |
# Add mock-ioctl to the LD_PRELOAD path so it overrides libc. |
| 22 |
# Append to LD_PRELOAD so existing libraries, e.g. libasan, are kept. |
| 23 |
# If libasan isn't specified in the LD_PRELOAD path, ASAN warns about mock-ioctl |
| 24 |
# being loaded first because its memory allocations might not get intercepted. |
| 25 |
# But it appears this isn't a problem; ASAN errors in mock-ioctl are reported. |
| 26 |
# This is likely because the executable still links with libasan before libc. |
| 27 |
mock_ioctl_env = environment() |
| 28 |
mock_ioctl_env.append('LD_PRELOAD', mock_ioctl.full_path()) |
| 29 |
mock_ioctl_env.set('ASAN_OPTIONS', 'verify_asan_link_order=0') |
| 30 |
|
| 31 |
ana = executable( |
| 32 |
'test-ana', |
| 33 |
'ana.c', |
| 34 |
dependencies: libnvme_dep, |
| 35 |
include_directories: [incdir, internal_incdir], |
| 36 |
link_with: mock_ioctl, |
| 37 |
) |
| 38 |
|
| 39 |
test('ana', ana, env: mock_ioctl_env) |
| 40 |
|
| 41 |
discovery = executable( |
| 42 |
'test-discovery', |
| 43 |
'discovery.c', |
| 44 |
dependencies: libnvme_dep, |
| 45 |
include_directories: [incdir, internal_incdir], |
| 46 |
link_with: mock_ioctl, |
| 47 |
) |
| 48 |
|
| 49 |
test('discovery', discovery, env: mock_ioctl_env) |
| 50 |
|
| 51 |
features = executable( |
| 52 |
'test-features', |
| 53 |
'features.c', |
| 54 |
dependencies: libnvme_dep, |
| 55 |
link_with: mock_ioctl, |
| 56 |
) |
| 57 |
|
| 58 |
test('features', features, env: mock_ioctl_env) |
| 59 |
|
| 60 |
identify = executable( |
| 61 |
'test-identify', |
| 62 |
'identify.c', |
| 63 |
dependencies: libnvme_dep, |
| 64 |
link_with: mock_ioctl, |
| 65 |
) |
| 66 |
|
| 67 |
test('identify', identify, env: mock_ioctl_env) |
| 68 |
|
| 69 |
logs = executable( |
| 70 |
'test-logs', |
| 71 |
'logs.c', |
| 72 |
dependencies: libnvme_dep, |
| 73 |
link_with: mock_ioctl, |
| 74 |
) |
| 75 |
|
| 76 |
test('logs', logs, env: mock_ioctl_env) |
| 77 |
|
| 78 |
zns = executable( |
| 79 |
'test-zns', |
| 80 |
'zns.c', |
| 81 |
dependencies: libnvme_dep, |
| 82 |
link_with: mock_ioctl, |
| 83 |
) |
| 84 |
|
| 85 |
test('zns', zns, env: mock_ioctl_env) |
| 86 |
|
| 87 |
misc = executable( |
| 88 |
'test-misc', |
| 89 |
'misc.c', |
| 90 |
dependencies: libnvme_dep, |
| 91 |
link_with: mock_ioctl, |
| 92 |
) |
| 93 |
|
| 94 |
test('misc', misc, env: mock_ioctl_env) |