File: t_a7_hier_block_cmake.py

package info (click to toggle)
verilator 5.038-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 162,552 kB
  • sloc: cpp: 139,204; python: 20,931; ansic: 10,222; yacc: 6,000; lex: 1,925; makefile: 1,260; sh: 494; perl: 282; fortran: 22
file content (47 lines) | stat: -rwxr-xr-x 1,899 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2024 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0

import vltest_bootstrap
import multiprocessing

# If a test fails, broken .cmake may disturb the next run
test.clean_objs()

test.scenarios('simulator')
test.top_filename = "t/t_hier_block.v"

threads = ('-DTEST_THREADS=6' if test.vltmt else '-DTEST_THREADS=1')

if not test.have_cmake:
    test.skip("Test requires CMake; ignore error since not available or version too old")

test.run(logfile=test.obj_dir + "/cmake.log",
         cmd=[
             'cd "' + test.obj_dir + '" && cmake ' + test.t_dir + '/t_hier_block_cmake',
             "-DCMAKE_PREFIX_PATH=" + os.environ["VERILATOR_ROOT"], threads
         ])

test.run(logfile=test.obj_dir + "/build.log",
         cmd=[
             'cd "' + test.obj_dir + '" && cmake --build', '.', ('-v' if test.verbose else ''),
             '-j ' + str(multiprocessing.cpu_count()), '--', "CXX_FLAGS=" + str(threads)
         ])

test.run(logfile=test.obj_dir + "/run.log",
         cmd=['cd "' + test.obj_dir + '" && ./t_hier_block_cmake', '.'])

target_dir = test.obj_dir + '/CMakeFiles/t_hier_block_cmake.dir/Vt_hier_block.dir/'
test.file_grep(target_dir + 'Vsub0/sub0.sv', r'^module\s+(\S+)\s+', "sub0")
test.file_grep(target_dir + 'Vsub1/sub1.sv', r'^module\s+(\S+)\s+', "sub1")
test.file_grep(target_dir + 'Vsub2/sub2.sv', r'^module\s+(\S+)\s+', "sub2")
test.file_grep(target_dir + 'Vt_hier_block__stats.txt',
               r'HierBlock,\s+Hierarchical blocks\s+(\d+)', 14)
test.file_grep(test.obj_dir + '/run.log', r'MACRO:(\S+) is defined', "cplusplus")

test.passes()