@@ -29,6 +29,10 @@ class TestComplianceTest(TestCase): # pylint: disable=too-many-public-methods
2929 def setUp (self ):
3030 self .tmp_dir = Path (__file__ ).parent / "vc_tmp"
3131 renew_path (str (self .tmp_dir ))
32+ self .vc_dir = self .tmp_dir / "vc"
33+ renew_path (str (self .vc_dir ))
34+ self .vci_dir = self .tmp_dir / "vci"
35+ renew_path (str (self .vci_dir ))
3236 self .vc_contents = """
3337library ieee
3438use ieee.std_logic_1164.all;
@@ -45,7 +49,7 @@ def setUp(self):
4549
4650end entity;
4751"""
48- self .vc_path = self .make_file ("vc.vhd" , self .vc_contents )
52+ self .vc_path = self .make_file ("vc.vhd" , self .vc_contents , self . vc_dir )
4953
5054 self .vci_contents = """
5155package vc_pkg is
@@ -59,32 +63,38 @@ def setUp(self):
5963 checker : checker_t := null_checker;
6064 unexpected_msg_type_policy : unexpected_msg_type_policy_t := fail
6165 ) return vc_handle_t;
66+
67+ function as_sync(handle : vc_handle_t) return sync_handle_t;
6268end package;
6369"""
64- self .vci_path = self .make_file ("vci.vhd" , self .vci_contents )
70+ self .vci_path = self .make_file ("vci.vhd" , self .vci_contents , self . vci_dir )
6571
6672 self .ui = VUnit .from_argv ([])
6773
6874 self .vc_lib = self .ui .add_library ("vc_lib" )
69- self .vc_lib .add_source_files (str (self .tmp_dir / "*.vhd" ))
75+ self .vc_lib .add_source_files (str (self .vc_dir / "*.vhd" ))
76+
77+ self .vci_lib = self .ui .add_library ("vci_lib" )
78+ self .vci_lib .add_source_files (str (self .vci_dir / "*.vhd" ))
7079
7180 def tearDown (self ):
7281 if self .tmp_dir .exists ():
7382 rmtree (self .tmp_dir )
7483
75- def make_file (self , file_name , contents ):
84+ def make_file (self , file_name , contents , directory = None ):
7685 """
7786 Create a file in the temporary directory with contents
7887 Returns the absolute path to the file.
7988 """
80- full_file_name = (self .tmp_dir / file_name ).resolve ()
89+ directory = directory if directory is not None else self .tmp_dir
90+ full_file_name = (directory / file_name ).resolve ()
8191 with full_file_name .open ("w" ) as outfile :
8292 outfile .write (contents )
8393 return str (full_file_name )
8494
8595 @mock .patch ("vunit.vc.verification_component_interface.LOGGER.error" )
8696 def test_not_finding_vc (self , error_mock ):
87- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
97+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
8898 self .assertRaises (
8999 SystemExit , VerificationComponent .find , self .vc_lib , "other_vc" , vci
90100 )
@@ -95,7 +105,7 @@ def test_not_finding_vci(self, error_mock):
95105 self .assertRaises (
96106 SystemExit ,
97107 VerificationComponentInterface .find ,
98- self .vc_lib ,
108+ self .vci_lib ,
99109 "other_vc_pkg" ,
100110 "vc_handle_t" ,
101111 )
@@ -113,15 +123,15 @@ def test_failing_on_multiple_entities(self, error_mock):
113123end entity;
114124"""
115125 self .vc_lib .add_source_file (self .make_file ("vc1_2.vhd" , vc_contents ))
116- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
126+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
117127 self .assertRaises (
118128 SystemExit , VerificationComponent .find , self .vc_lib , "vc1" , vci
119129 )
120130 error_mock .assert_called_once_with (
121131 "%s must contain a single VC entity" , self .tmp_dir / "vc1_2.vhd"
122132 )
123133
124- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
134+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
125135 self .assertRaises (
126136 SystemExit , VerificationComponent .find , self .vc_lib , "vc2" , vci
127137 )
@@ -167,7 +177,7 @@ def test_evaluating_vc_generics(self, error_mock):
167177end entity;
168178"""
169179 self .vc_lib .add_source_file (self .make_file ("vc1.vhd" , vc1_contents ))
170- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
180+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
171181 self .assertRaises (
172182 SystemExit , VerificationComponent .find , self .vc_lib , "vc1" , vci
173183 )
@@ -179,7 +189,7 @@ def test_evaluating_vc_generics(self, error_mock):
179189end entity;
180190"""
181191 self .vc_lib .add_source_file (self .make_file ("vc2.vhd" , vc2_contents ))
182- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
192+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
183193 self .assertRaises (
184194 SystemExit , VerificationComponent .find , self .vc_lib , "vc2" , vci
185195 )
@@ -191,7 +201,7 @@ def test_evaluating_vc_generics(self, error_mock):
191201end entity;
192202"""
193203 self .vc_lib .add_source_file (self .make_file ("vc3.vhd" , vc3_contents ))
194- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
204+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
195205 self .assertRaises (
196206 SystemExit , VerificationComponent .find , self .vc_lib , "vc3" , vci
197207 )
@@ -206,6 +216,7 @@ def test_failing_with_no_constructor(self, error_mock):
206216 end record;
207217
208218 impure function create_vc return vc_handle_t;
219+ function as_sync(handle : vc_handle_t) return sync_handle_t;
209220end package;
210221"""
211222 self .vc_lib .add_source_file (self .make_file ("other_vci.vhd" , vci_contents ))
@@ -230,6 +241,8 @@ def test_failing_with_wrong_constructor_return_type(self, error_mock):
230241 end record;
231242
232243 impure function new_vc return vc_t;
244+ function as_sync(handle : vc_handle_t) return sync_handle_t;
245+
233246end package;
234247"""
235248 self .vc_lib .add_source_file (self .make_file ("other_vci.vhd" , vci_contents ))
@@ -300,6 +313,7 @@ def test_failing_on_incorrect_constructor_parameters(self, error_mock):
300313 vci_contents [:- 2 ]
301314 + """
302315 ) return vc_handle_t;
316+ function as_sync(handle : vc_handle_t) return sync_handle_t;
303317end package;
304318"""
305319 )
@@ -348,6 +362,7 @@ def test_failing_on_non_private_handle_elements(self, error_mock):
348362 checker : checker_t := null_checker;
349363 unexpected_msg_type_policy : unexpected_msg_type_policy_t := fail
350364 ) return vc_handle_t;
365+ function as_sync(handle : vc_handle_t) return sync_handle_t;
351366end package;
352367"""
353368
@@ -378,6 +393,7 @@ def test_failing_on_missing_handle_record(self, error_mock):
378393 checker : checker_t := null_checker;
379394 unexpected_msg_type_policy : unexpected_msg_type_policy_t := fail
380395 ) return vc_handle_t;
396+ function as_sync(handle : vc_handle_t) return sync_handle_t;
381397end package;
382398"""
383399
@@ -432,6 +448,7 @@ def test_error_on_missing_default_value(self):
432448 vci_contents [:- 2 ]
433449 + """
434450 ) return vc_handle_t;
451+ function as_sync(handle : vc_handle_t) return sync_handle_t;
435452end package;
436453"""
437454 )
@@ -472,11 +489,11 @@ def test_create_vhdl_testbench_template_references(self):
472489
473490 vc_path = self .make_file ("vc2.vhd" , vc_contents )
474491 template , _ = VerificationComponent .create_vhdl_testbench_template (
475- "vc_lib" , vc_path , self .vci_path
492+ "vc_lib" , "vc_lib" , vc_path , self .vci_path
476493 )
477494 template = VHDLDesignFile .parse (template )
478495 refs = template .references
479- self .assertEqual (len (refs ), 13 )
496+ self .assertEqual (len (refs ), 14 )
480497 self .assertIn (VHDLReference ("library" , "vunit_lib" ), refs )
481498 self .assertIn (VHDLReference ("library" , "vc_lib" ), refs )
482499 self .assertIn (VHDLReference ("library" , "a_lib" ), refs )
@@ -485,6 +502,7 @@ def test_create_vhdl_testbench_template_references(self):
485502 self .assertIn (VHDLReference ("package" , "vc_lib" , "vc_pkg" , "all" ), refs )
486503 self .assertIn (VHDLReference ("package" , "a_lib" , "x" , "y" ), refs )
487504 self .assertIn (VHDLReference ("package" , "vunit_lib" , "sync_pkg" , "all" ), refs )
505+ self .assertIn (VHDLReference ("package" , "vunit_lib" , "vc_pkg" , "all" ), refs )
488506 self .assertIn (VHDLReference ("context" , "vc_lib" , "spam" ), refs )
489507 self .assertIn (VHDLReference ("context" , "a_lib" , "eggs" ), refs )
490508 self .assertIn (VHDLReference ("context" , "vunit_lib" , "vunit_context" ), refs )
@@ -510,7 +528,7 @@ def test_template_with_wrong_name(self):
510528
511529 template_path = self .make_file ("template.vhd" , template_contents )
512530
513- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
531+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
514532 vc = VerificationComponent .find (self .vc_lib , "vc" , vci )
515533 self .assertRaises (RuntimeError , vc .create_vhdl_testbench , template_path )
516534
@@ -532,7 +550,7 @@ def test_template_missing_contructor(self):
532550
533551 template_path = self .make_file ("template.vhd" , template_contents )
534552
535- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
553+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
536554 vc = VerificationComponent .find (self .vc_lib , "vc" , vci )
537555 self .assertRaises (RuntimeError , vc .create_vhdl_testbench , template_path )
538556
@@ -555,7 +573,7 @@ def test_template_missing_runner_cfg(self):
555573
556574 template_path = self .make_file ("template.vhd" , template_contents )
557575
558- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
576+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
559577 vc = VerificationComponent .find (self .vc_lib , "vc" , vci )
560578 self .assertRaises (RuntimeError , vc .create_vhdl_testbench , template_path )
561579
@@ -578,7 +596,7 @@ def test_template_missing_test_runner(self):
578596
579597 template_path = self .make_file ("template.vhd" , template_contents )
580598
581- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
599+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
582600 vc = VerificationComponent .find (self .vc_lib , "vc" , vci )
583601 self .assertRaises (RuntimeError , vc .create_vhdl_testbench , template_path )
584602
@@ -667,7 +685,9 @@ def test_creating_template_with_specified_vc_lib(self):
667685 [
668686 "compliance_test.py" ,
669687 "create-vc" ,
670- "-l" ,
688+ "--vc-lib-name" ,
689+ "my_vc_lib" ,
690+ "--vci-lib-name" ,
671691 "my_vc_lib" ,
672692 self .vc_path ,
673693 self .vci_path ,
@@ -688,7 +708,7 @@ def test_creating_template_with_specified_vc_lib(self):
688708 def test_adding_vhdl_testbench (self ):
689709 vc_test_lib = self .ui .add_library ("vc_test_lib" )
690710
691- vci = VerificationComponentInterface .find (self .vc_lib , "vc_pkg" , "vc_handle_t" )
711+ vci = VerificationComponentInterface .find (self .vci_lib , "vc_pkg" , "vc_handle_t" )
692712 vc = VerificationComponent .find (self .vc_lib , "vc" , vci )
693713
694714 vc .add_vhdl_testbench (vc_test_lib , str (self .tmp_dir / "compliance_test" ))
0 commit comments