Debian Codegraph @

tests/meson.build

raw
1 # This file is part of the flashrom project.
2 #
3 # Copyright 2020 Google LLC
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 test_srcs = files(
15 'io_mock.c',
16 'tests.c',
17 'libusb_wraps.c',
18 'helpers.c',
19 'flashrom.c',
20 'libflashrom.c',
21 'spi25.c',
22 'lifecycle.c',
23 'layout.c',
24 'chip.c',
25 'chip_wp.c',
26 'selfcheck.c',
27 'io_real.c',
28 'erase_func_algo.c',
29 'udelay.c',
30 )
31
32 if not programmer.get('dummy').get('active')
33 test_srcs += programmer.get('dummy').get('srcs')
34 endif
35
36 foreach p_name, p_data : programmer
37 test_srcs += p_data.get('test_srcs')
38 endforeach
39
40 mocks = [
41 '-Wl,--wrap=strdup',
42 '-Wl,--wrap=physunmap',
43 '-Wl,--wrap=physmap',
44 '-Wl,--wrap=pcidev_init',
45 '-Wl,--wrap=pcidev_readbar',
46 '-Wl,--wrap=spi_send_command',
47 '-Wl,--wrap=sio_write',
48 '-Wl,--wrap=sio_read',
49 '-Wl,--wrap=open',
50 '-Wl,--wrap=open64',
51 '-Wl,--wrap=__open64_2',
52 '-Wl,--wrap=fcntl',
53 '-Wl,--wrap=fcntl64',
54 '-Wl,--wrap=ioctl',
55 '-Wl,--wrap=read',
56 '-Wl,--wrap=write',
57 '-Wl,--wrap=fopen',
58 '-Wl,--wrap=fopen64',
59 '-Wl,--wrap=fdopen',
60 '-Wl,--wrap=fwrite',
61 '-Wl,--wrap=fflush',
62 '-Wl,--wrap=stat',
63 '-Wl,--wrap=stat64',
64 '-Wl,--wrap=__xstat',
65 '-Wl,--wrap=__xstat64',
66 '-Wl,--wrap=fstat',
67 '-Wl,--wrap=fstat64',
68 '-Wl,--wrap=__fstat50',
69 '-Wl,--wrap=__fxstat',
70 '-Wl,--wrap=__fxstat64',
71 '-Wl,--wrap=fileno',
72 '-Wl,--wrap=fsync',
73 '-Wl,--wrap=fread',
74 '-Wl,--wrap=fgets',
75 '-Wl,--wrap=fprintf',
76 '-Wl,--wrap=fclose',
77 '-Wl,--wrap=feof',
78 '-Wl,--wrap=ferror',
79 '-Wl,--wrap=clearerr',
80 '-Wl,--wrap=setvbuf',
81 '-Wl,--wrap=rget_io_perms',
82 '-Wl,--wrap=OUTB',
83 '-Wl,--wrap=INB',
84 '-Wl,--wrap=OUTW',
85 '-Wl,--wrap=INW',
86 '-Wl,--wrap=OUTL',
87 '-Wl,--wrap=INL',
88 '-Wl,--wrap=tcgetattr',
89 '-Wl,--wrap=tcsetattr',
90 '-Wl,--wrap=usb_dev_get_by_vid_pid_number',
91 '-Wl,--wrap=libusb_init',
92 '-Wl,--wrap=libusb_set_debug',
93 '-Wl,--wrap=libusb_set_option',
94 '-Wl,--wrap=libusb_open',
95 '-Wl,--wrap=libusb_set_auto_detach_kernel_driver',
96 '-Wl,--wrap=libusb_detach_kernel_driver',
97 '-Wl,--wrap=libusb_attach_kernel_driver',
98 '-Wl,--wrap=libusb_open_device_with_vid_pid',
99 '-Wl,--wrap=libusb_get_device',
100 '-Wl,--wrap=libusb_get_device_list',
101 '-Wl,--wrap=libusb_free_device_list',
102 '-Wl,--wrap=libusb_get_bus_number',
103 '-Wl,--wrap=libusb_get_device_address',
104 '-Wl,--wrap=libusb_get_device_descriptor',
105 '-Wl,--wrap=libusb_get_config_descriptor',
106 '-Wl,--wrap=libusb_free_config_descriptor',
107 '-Wl,--wrap=libusb_get_configuration',
108 '-Wl,--wrap=libusb_set_configuration',
109 '-Wl,--wrap=libusb_claim_interface',
110 '-Wl,--wrap=libusb_control_transfer',
111 '-Wl,--wrap=libusb_release_interface',
112 '-Wl,--wrap=libusb_ref_device',
113 '-Wl,--wrap=libusb_unref_device',
114 '-Wl,--wrap=libusb_close',
115 '-Wl,--wrap=libusb_alloc_transfer',
116 '-Wl,--wrap=libusb_submit_transfer',
117 '-Wl,--wrap=libusb_free_transfer',
118 '-Wl,--wrap=libusb_handle_events_timeout',
119 '-Wl,--wrap=libusb_exit',
120 '-Wl,--gc-sections',
121 ]
122
123 threads_dep = dependency('threads')
124
125 flashrom_tests = executable('flashrom_unit_tests',
126 test_srcs,
127 c_args : [
128 cargs,
129 '-ffunction-sections',
130 '-fdata-sections',
131 '-U_FORTIFY_SOURCE',
132 '-DFLASHROM_TEST',
133 ],
134 export_dynamic : true,
135 link_args : mocks + link_args,
136 dependencies : [cmocka_dep, flashrom_test_dep, threads_dep],
137 )
138 test('cmocka test flashrom', flashrom_tests)
139
140 if get_option('llvm_cov').enabled()
141 run_target('llvm-cov-tests', command : ['../scripts/llvm-cov', flashrom_tests])
142 endif