547f6607f1a714eba5c45b1036dcab1bd40b7dc3
[barectf.git] / tests / config / yaml / 2 / test_pass_everything.py
1 # The MIT License (MIT)
2 #
3 # Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 import os
25 import os.path
26 import barectf
27 import subprocess
28
29
30 def test_everything(request, tmpdir):
31 yaml_path = os.path.join(os.path.dirname(request.fspath), 'configs',
32 'pass', 'everything', 'config.yaml')
33 yaml_dir = os.path.dirname(yaml_path)
34
35 with open(yaml_path) as f:
36 cfg = barectf.configuration_from_file(f, inclusion_directories=[yaml_dir])
37
38 cg = barectf.CodeGenerator(cfg)
39 files = cg.generate_c_headers()
40 files += cg.generate_c_sources()
41
42 for file in files:
43 with open(os.path.join(tmpdir, file.name), 'w') as f:
44 f.write(file.contents)
45
46 cc = os.environ.get('CC', 'cc')
47 o_file = 'obj.o'
48 subprocess.check_call([cc, '-c', '-o', o_file, files[-1].name], cwd=tmpdir)
49 nm = os.environ.get('NM', 'nm')
50 syms = subprocess.check_output([nm, o_file], cwd=tmpdir, universal_newlines=True)
51 syms_to_check = [
52 'bctf_init',
53 'bctf_my_other_stream_close_packet',
54 'bctf_my_other_stream_open_packet',
55 'bctf_my_other_stream_trace_context_no_payload',
56 'bctf_my_other_stream_trace_evev',
57 'bctf_my_other_stream_trace_my_event',
58 'bctf_my_other_stream_trace_no_context_no_payload',
59 'bctf_my_other_stream_trace_oh_henry_event',
60 'bctf_my_other_stream_trace_this_event',
61 'bctf_my_stream_close_packet',
62 'bctf_my_stream_open_packet',
63 'bctf_my_stream_trace_my_event',
64 'bctf_packet_buf',
65 'bctf_packet_buf_size',
66 'bctf_packet_events_discarded',
67 'bctf_packet_is_empty',
68 'bctf_packet_is_full',
69 'bctf_packet_is_open',
70 'bctf_packet_set_buf',
71 'bctf_packet_size',
72 ]
73
74 for sym in syms_to_check:
75 assert sym in syms
This page took 0.032183 seconds and 3 git commands to generate.