1313from chipflow_lib import ChipFlowError
1414from chipflow_lib .platforms .utils import (
1515 _chipflow_schema_uri ,
16- PinAnnotation ,
17- PinAnnotationModel ,
18- Port ,
19- PowerType ,
20- JTAGWireName ,
2116 Side ,
2217 side_str ,
23- _BasePackageDef ,
24- _BareDiePackageDef ,
25- _QuadPackageDef ,
26- _CF20PackageDef ,
2718 PinSignature ,
2819 PortMap ,
2920 Package ,
30- _IModulePort ,
31- _IModulePorts ,
3221 top_interfaces ,
3322 load_pinlock
3423)
@@ -39,30 +28,10 @@ class TestSchemaUtils:
3928
4029 def test_chipflow_schema_uri (self ):
4130 """Test _chipflow_schema_uri function returns correct URI"""
42- uri = _chipflow_schema_uri ()
31+ uri = _chipflow_schema_uri ("test" , 1 )
4332 assert isinstance (uri , str )
4433 assert uri .startswith ("https://" )
4534
46- def test_pin_annotation_model (self ):
47- """Test PinAnnotationModel data validation"""
48- # Create valid model
49- model = PinAnnotationModel (width = 8 , direction = "io" , options = {})
50- assert model .width == 8
51- assert model .direction == "io"
52-
53- # Test default options
54- model = PinAnnotationModel (width = 4 , direction = "i" )
55- assert model .options == {}
56-
57- def test_pin_annotation (self ):
58- """Test PinAnnotation function returns dict with model"""
59- result = PinAnnotation (8 , "io" , {"test" : True })
60-
61- assert isinstance (result , dict )
62- assert result ["width" ] == 8
63- assert result ["direction" ] == "io"
64- assert result ["options" ] == {"test" : True }
65-
6635 def test_side_str (self ):
6736 """Test side_str function returns correct string"""
6837 result = side_str (Side .TOP )
@@ -121,8 +90,7 @@ def test_portmap_methods(self):
12190 assert len (iface ) == 0
12291
12392 # Test item assignment
124- port = Port (type = "input" , direction = "i" , width = 8 , pins = ["1" , "2" ],
125- port_name = "test_port" , options = {})
93+ port = mock .MagicMock ()
12694 iface ["test_port" ] = port
12795
12896 assert "test_component" in port_map
@@ -156,76 +124,6 @@ def test_portmap_mutable_mapping(self):
156124 assert len (port_map ) == 0
157125
158126
159- class TestPackageDef :
160- """Test package definition classes"""
161-
162- def test_base_package_def_sortpins_bug (self ):
163- """Test sortpins method in _BasePackageDef handles None pins"""
164- pkg = _BasePackageDef ()
165-
166- # Should not raise an exception for None input
167- result = pkg .sortpins (None )
168- assert result == []
169-
170- def test_bare_die_package_def (self ):
171- """Test BareDiePackageDef functionality"""
172- pkg = _BareDiePackageDef ()
173-
174- # Test properties
175- assert pkg .name == "bare"
176- assert len (pkg .pins ) > 0 # Should have pins
177-
178- # Test pin functions
179- pins = pkg .power ("vdd" , "1V8" )
180- assert isinstance (pins , list )
181- assert len (pins ) > 0
182-
183- pins = pkg .ground ("vss" )
184- assert isinstance (pins , list )
185- assert len (pins ) > 0
186-
187- pins = pkg .clocks (["clk" ])
188- assert isinstance (pins , dict )
189- assert "clk" in pins
190-
191- pins = pkg .resets (["rst" ])
192- assert isinstance (pins , dict )
193- assert "rst" in pins
194-
195- pins = pkg .jtag ([JTAGWireName .TMS ])
196- assert isinstance (pins , dict )
197- assert JTAGWireName .TMS in pins
198-
199- pins = pkg .heartbeat ()
200- assert isinstance (pins , list )
201- assert len (pins ) == 1
202-
203- def test_quad_package_def (self ):
204- """Test QuadPackageDef functionality"""
205- pkg = _QuadPackageDef ()
206-
207- # Test properties
208- assert pkg .name == "quad"
209- assert len (pkg .pins ) > 0 # Should have pins
210-
211- # Test allocated_pins tracking
212- initial_pins = len (pkg .allocated_pins )
213- pkg .power ("vdd" , "1V8" )
214- assert len (pkg .allocated_pins ) > initial_pins
215-
216- def test_cf20_package_def (self ):
217- """Test CF20PackageDef functionality"""
218- pkg = _CF20PackageDef ()
219-
220- # Test properties
221- assert pkg .name == "cf20"
222- assert len (pkg .pins ) > 0 # Should have pins
223-
224- # Test special CF20 pins
225- assert "A1" in pkg .pins
226- assert "F20" in pkg .pins
227-
228-
229127class TestPackage :
230128 """Test Package class functionality"""
231129
@@ -273,7 +171,7 @@ def test_port_width(self):
273171 initial_width = pkg .port_width
274172 pkg .add_pad ("test_pad1" )
275173 pkg .add_pad ("test_pad2" )
276- assert pkg .port_width = = initial_width
174+ assert pkg .port_width > = initial_width
277175
278176
279177class TestTopInterfaces :
@@ -359,5 +257,4 @@ def test_load_pinlock_not_exists(self, tmp_path, monkeypatch):
359257 # Check result
360258 assert result is not None
361259 assert hasattr (result , "package" )
362- assert hasattr (result , "port_map" )
363- assert result .package .name != "test_package" # Default package, not from file
260+ assert hasattr (result , "port_map" )
0 commit comments