mirror of
https://gitlab.freedesktop.org/wayland/wayland-protocols.git
synced 2025-12-24 16:00:10 +01:00
tests: Add compile tests
Only tested by the meson build system. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
79b9a42514
commit
5cb6b92f01
4 changed files with 172 additions and 0 deletions
12
tests/build-cxx.cc.in
Normal file
12
tests/build-cxx.cc.in
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include "@PROTOCOL_CLIENT_INCLUDE_FILE@"
|
||||
#include "@PROTOCOL_SERVER_INCLUDE_FILE@"
|
||||
|
||||
/* This is a build-test only */
|
||||
|
||||
using namespace std;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
10
tests/build-pedantic.c.in
Normal file
10
tests/build-pedantic.c.in
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include "@PROTOCOL_CLIENT_INCLUDE_FILE@"
|
||||
#include "@PROTOCOL_SERVER_INCLUDE_FILE@"
|
||||
|
||||
/* This is a build-test only */
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
prog_scan_sh = find_program('scan.sh')
|
||||
prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
|
||||
|
||||
libwayland = [
|
||||
dependency('wayland-client'),
|
||||
dependency('wayland-server'),
|
||||
]
|
||||
|
||||
# Check that each protocol passes through the scanner
|
||||
foreach protocol_file : protocol_files
|
||||
protocol_path = join_paths(wayland_protocols_srcdir, protocol_file)
|
||||
|
|
@ -12,3 +17,125 @@ foreach protocol_file : protocol_files
|
|||
]
|
||||
)
|
||||
endforeach
|
||||
|
||||
# Check buildability
|
||||
|
||||
add_languages('c', 'cpp')
|
||||
replace = find_program('replace.py')
|
||||
|
||||
foreach protocol_file : protocol_files
|
||||
xml_file = fs.name(protocol_file)
|
||||
xml_components = xml_file.split('.')
|
||||
protocol_base_file_name = xml_components[0]
|
||||
|
||||
protocol_path = files(join_paths(wayland_protocols_srcdir, protocol_file))
|
||||
client_header_path = '@0@-client.h'.format(protocol_base_file_name)
|
||||
server_header_path = '@0@-server.h'.format(protocol_base_file_name)
|
||||
code_path = '@0@-code.c'.format(protocol_base_file_name)
|
||||
client_header = custom_target(
|
||||
client_header_path,
|
||||
output: client_header_path,
|
||||
input: protocol_path,
|
||||
command: [
|
||||
prog_scanner,
|
||||
'--strict',
|
||||
'client-header',
|
||||
'@INPUT@',
|
||||
'@OUTPUT@',
|
||||
],
|
||||
install: false,
|
||||
)
|
||||
server_header = custom_target(
|
||||
server_header_path,
|
||||
output: server_header_path,
|
||||
input: protocol_path,
|
||||
command: [
|
||||
prog_scanner,
|
||||
'--strict',
|
||||
'server-header',
|
||||
'@INPUT@',
|
||||
'@OUTPUT@',
|
||||
],
|
||||
install: false,
|
||||
)
|
||||
code = custom_target(
|
||||
code_path,
|
||||
output: code_path,
|
||||
input: protocol_path,
|
||||
command: [
|
||||
prog_scanner,
|
||||
'--strict',
|
||||
'private-code',
|
||||
'@INPUT@',
|
||||
'@OUTPUT@',
|
||||
],
|
||||
install: false,
|
||||
)
|
||||
|
||||
replace_command = [
|
||||
replace,
|
||||
'@INPUT@',
|
||||
'@OUTPUT@',
|
||||
'PROTOCOL_CLIENT_INCLUDE_FILE',
|
||||
client_header.full_path(),
|
||||
'PROTOCOL_SERVER_INCLUDE_FILE',
|
||||
server_header.full_path(),
|
||||
]
|
||||
|
||||
# Check that header can be included by a pedantic C99 compiler
|
||||
test_name = 'test-build-pedantic-@0@'.format(protocol_file.underscorify())
|
||||
test_name_source = '@0@.c'.format(test_name)
|
||||
test_source = custom_target(
|
||||
test_name_source,
|
||||
input: 'build-pedantic.c.in',
|
||||
output: test_name_source,
|
||||
command: replace_command,
|
||||
)
|
||||
pedantic_test_executable = executable(
|
||||
test_name,
|
||||
[
|
||||
test_source,
|
||||
client_header,
|
||||
server_header,
|
||||
code
|
||||
],
|
||||
link_args: [
|
||||
'-Wl,--unresolved-symbols=ignore-all',
|
||||
],
|
||||
dependencies: libwayland,
|
||||
c_args: [
|
||||
'-std=c99',
|
||||
'-pedantic',
|
||||
'-Wall',
|
||||
'-Werror' ],
|
||||
install: false,
|
||||
)
|
||||
test(test_name, pedantic_test_executable)
|
||||
|
||||
# Check that the header
|
||||
if not protocol_file.contains('xdg-foreign-unstable-v1')
|
||||
test_name = 'test-build-cxx-@0@'.format(protocol_file.underscorify())
|
||||
test_name_source = '@0@.cc'.format(test_name)
|
||||
test_source = custom_target(
|
||||
test_name_source,
|
||||
input: 'build-cxx.cc.in',
|
||||
output: test_name_source,
|
||||
command: replace_command,
|
||||
)
|
||||
cxx_test_executable = executable(
|
||||
test_name,
|
||||
[
|
||||
test_source,
|
||||
client_header,
|
||||
server_header,
|
||||
],
|
||||
link_args: [ '-Wl,--unresolved-symbols=ignore-all' ],
|
||||
cpp_args: [
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
],
|
||||
install: false,
|
||||
)
|
||||
test(test_name, cxx_test_executable)
|
||||
endif
|
||||
endforeach
|
||||
|
|
|
|||
23
tests/replace.py
Executable file
23
tests/replace.py
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
|
||||
execpath, inpath, outpath, *dict_list = sys.argv
|
||||
|
||||
dictonary = {}
|
||||
while dict_list:
|
||||
key, value, *rest = dict_list
|
||||
dictonary[key] = value
|
||||
dict_list = rest
|
||||
|
||||
infile = open(inpath, 'r')
|
||||
outfile = open(outpath, 'w')
|
||||
|
||||
buf = infile.read()
|
||||
infile.close()
|
||||
|
||||
for key, value in dictonary.items():
|
||||
buf = buf.replace('@{}@'.format(key), value)
|
||||
|
||||
outfile.write(buf)
|
||||
outfile.close()
|
||||
Loading…
Add table
Reference in a new issue