1simple_xinit = executable(
2    'simple-xinit',
3    'simple-xinit.c',
4    include_directories: inc,
5)
6
7piglit_env = environment()
8piglit_env.set('XSERVER_DIR', meson.source_root())
9piglit_env.set('XSERVER_BUILDDIR', meson.build_root())
10
11some_ops = ' -o clear,src,dst,over,xor,disjointover'
12rendercheck_tests = [
13    ['blend/All/a8r8g8b8', '-t blend -f a8r8g8b8'],
14    ['blend/All/x8r8g8b8', '-t blend -f a8r8g8b8,x8r8g8b8'],
15    ['blend/All/a2r10g10b10', '-t blend -f a8r8g8b8,a2r10g10b10'],
16    ['blend/Clear', '-t blend -o clear'],
17    ['blend/Src', '-t blend -o src'],
18    ['blend/Over', '-t blend -o over'],
19    ['composite/Some/a8r8g8b8', '-t composite -f a8r8g8b8' + some_ops],
20    ['composite/Some/x8r8g8b8', '-t composite -f a8r8g8b8,x8r8g8b8' + some_ops],
21    ['composite/Some/a2r10g10b10', '-t composite -f a8r8g8b8,a2r10g10b10' + some_ops],
22    ['ca composite/Some/a8r8g8b8', '-t cacomposite -f a8r8g8b8' + some_ops],
23    ['ca composite/Some/a8', '-t cacomposite -f a8r8g8b8,a8' + some_ops],
24    ['ca composite/Some/x8r8g8b8', '-t cacomposite -f a8r8g8b8,x8r8g8b8' + some_ops],
25    ['ca composite/Some/a2r10g10b10', '-t cacomposite -f a8r8g8b8,a2r10g10b10' + some_ops],
26    ['fill', '-t fill'],
27    ['bug7366', '-t bug7366'],
28    ['destination coordinates', '-t dcoords'],
29    ['source coordinates', '-t scoords'],
30    ['mask coordinates', '-t mcoords'],
31    ['translated source coordinates', '-t tscoords'],
32    ['translated mask coordinates', '-t tmcoords'],
33    ['triangles', '-t triangles'],
34    ['LibreOffice xRGB', '-t libreoffice_xrgb'],
35    ['GTK ARGB vs xBGR', '-t gtk_argb_xbgr'],
36]
37
38rendercheck = find_program('rendercheck', required:false)
39
40if get_option('xvfb')
41    xvfb_args = [
42        xvfb_server.full_path(),
43        '-screen',
44        'scrn',
45        '1280x1024x24',
46    ]
47
48    test('XTS',
49        find_program('scripts/xvfb-piglit.sh'),
50        env: piglit_env,
51        timeout: 1200,
52        suite: 'xvfb'
53    )
54
55    if rendercheck.found()
56        foreach rctest: rendercheck_tests
57            test(rctest[0],
58                 simple_xinit,
59                 # Use full_path so people can copy and paste the
60                 # command line from testlog.txt easily.
61                 args: [
62                     rendercheck.path(),
63                     rctest[1].split(' '),
64                     '--',
65                     xvfb_args,
66                 ],
67                 suite: 'xvfb'
68                )
69        endforeach
70    endif
71
72    if get_option('xephyr') and build_glamor
73        test('XTS',
74            find_program('scripts/xephyr-glamor-piglit.sh'),
75            env: piglit_env,
76            timeout: 1200,
77            suite: 'xephr-glamor',
78        )
79
80        if rendercheck.found()
81            foreach rctest: rendercheck_tests
82                test(rctest[0],
83                     simple_xinit,
84                     args: [simple_xinit.full_path(),
85                            rendercheck.path(),
86                            rctest[1].split(' '),
87                            '----',
88                            xephyr_server.full_path(),
89                            '-glamor',
90                            '-glamor-skip-present',
91                            '-schedMax', '2000',
92                            '--',
93                            xvfb_args,
94                           ],
95                     suite: 'xephr-glamor',
96                     timeout: 300,
97                    )
98            endforeach
99        endif
100    endif
101endif
102
103subdir('bigreq')
104subdir('damage')
105subdir('sync')
106
107if build_xorg
108# Tests that require at least some DDX functions in order to fully link
109# For now, requires xf86 ddx, could be adjusted to use another
110    unit_sources = [
111     '../mi/miinitext.c',
112     '../mi/miinitext.h',
113     '../mi/micmap.c',
114     '../mi/micmap.h',
115     'fixes.c',
116     'input.c',
117     'list.c',
118     'misc.c',
119     'signal-logging.c',
120     'string.c',
121     'test_xkb.c',
122     'tests-common.c',
123     'tests.c',
124     'touch.c',
125     'xfree86.c',
126     'xtest.c',
127    ]
128    unit_defines = ['-DXORG_TESTS']
129    unit_includes = [inc, xorg_inc]
130
131    if build_res
132        unit_sources += ['hashtabletest.c']
133        unit_defines += ['-DRES_TESTS']
134    endif
135
136    unit_c_args = unit_defines
137    if meson.get_compiler('c').has_link_argument('-Wl,-wrap')
138       # LTO breaks with -Wl,-wrap on certain configurations
139       unit_c_args += ['-fno-lto']
140       unit_sources += [
141        'xi1/protocol-xchangedevicecontrol.c',
142        'xi2/protocol-common.c',
143        'xi2/protocol-xiqueryversion.c',
144        'xi2/protocol-xiquerydevice.c',
145        'xi2/protocol-xiselectevents.c',
146        'xi2/protocol-xigetselectedevents.c',
147        'xi2/protocol-xisetclientpointer.c',
148        'xi2/protocol-xigetclientpointer.c',
149        'xi2/protocol-xiquerypointer.c',
150        'xi2/protocol-xipassivegrabdevice.c',
151        'xi2/protocol-xiwarppointer.c',
152        'xi2/protocol-eventconvert.c',
153        'xi2/xi2.c',
154       ]
155       unit_defines += ['-DLDWRAP_TESTS']
156       unit_includes += [include_directories('xi1', 'xi2')]
157       ldwraps = [
158        '-Wl,-wrap,dixLookupWindow',
159        '-Wl,-wrap,dixLookupClient',
160        '-Wl,-wrap,WriteToClient',
161        '-Wl,-wrap,dixLookupWindow',
162        '-Wl,-wrap,XISetEventMask',
163        '-Wl,-wrap,AddResource',
164        '-Wl,-wrap,GrabButton',
165       ]
166    else
167       ldwraps = []
168       message('ld -wrap required for xi1 & xi2 unit tests, skipping')
169    endif
170
171    unit = executable('tests',
172         unit_sources,
173         c_args: unit_c_args,
174         dependencies: [pixman_dep, randrproto_dep, inputproto_dep, libxcvt_dep],
175         include_directories: unit_includes,
176         link_args: ldwraps,
177         link_with: xorg_link,
178    )
179
180    test('unit', unit)
181endif
182