tests: cleanup: Explain the purpose of some tests
[barectf.git] / tests / config / yaml / 2 / test_pass_everything.py
CommitLineData
af01d03f
PP
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
24import os
25import os.path
26import barectf
27import subprocess
28
29
0ea3b429
EB
30# Tests that a barectf 2 configuration using many features will
31# generate tracer C code that appears valid and functional.
af01d03f 32def test_everything(request, tmpdir):
a10dfb24
PP
33 yaml_path = os.path.join(os.path.dirname(request.fspath), 'configs',
34 'pass', 'everything', 'config.yaml')
af01d03f
PP
35 yaml_dir = os.path.dirname(yaml_path)
36
37 with open(yaml_path) as f:
38 cfg = barectf.configuration_from_file(f, inclusion_directories=[yaml_dir])
39
40 cg = barectf.CodeGenerator(cfg)
41 files = cg.generate_c_headers()
42 files += cg.generate_c_sources()
43
44 for file in files:
45 with open(os.path.join(tmpdir, file.name), 'w') as f:
46 f.write(file.contents)
47
90b5621a 48 cc = os.environ.get('CC', 'cc')
af01d03f
PP
49 o_file = 'obj.o'
50 subprocess.check_call([cc, '-c', '-o', o_file, files[-1].name], cwd=tmpdir)
51 nm = os.environ.get('NM', 'nm')
52 syms = subprocess.check_output([nm, o_file], cwd=tmpdir, universal_newlines=True)
53 syms_to_check = [
54 'bctf_init',
55 'bctf_my_other_stream_close_packet',
56 'bctf_my_other_stream_open_packet',
57 'bctf_my_other_stream_trace_context_no_payload',
58 'bctf_my_other_stream_trace_evev',
59 'bctf_my_other_stream_trace_my_event',
60 'bctf_my_other_stream_trace_no_context_no_payload',
61 'bctf_my_other_stream_trace_oh_henry_event',
62 'bctf_my_other_stream_trace_this_event',
63 'bctf_my_stream_close_packet',
64 'bctf_my_stream_open_packet',
65 'bctf_my_stream_trace_my_event',
66 'bctf_packet_buf',
7a37a981 67 'bctf_packet_buf_addr',
af01d03f
PP
68 'bctf_packet_buf_size',
69 'bctf_packet_events_discarded',
7a37a981 70 'bctf_discarded_event_records_count',
af01d03f
PP
71 'bctf_packet_is_empty',
72 'bctf_packet_is_full',
73 'bctf_packet_is_open',
74 'bctf_packet_set_buf',
75 'bctf_packet_size',
76 ]
77
78 for sym in syms_to_check:
79 assert sym in syms
This page took 0.027863 seconds and 4 git commands to generate.