@@ -105,23 +105,62 @@ def test_removing_and_adding_insertion_order(self):
105105 self .assertEqual (thread_collection .GetSize (), 3 )
106106 self .assertIn (middle_thread , thread_collection )
107107
108- def test_get_total_in_bytes (self ):
108+ def test_get_current_size_in_bytes (self ):
109109 """
110- Tests that get total in bytes properly returns an error without a process,
110+ Tests that ensures GetCurrentSizeInBytes properly returns an error without a process,
111111 and the readable regions with a process.
112112 """
113113
114114 options = lldb .SBSaveCoreOptions ()
115115 options .SetStyle (lldb .eSaveCoreCustomOnly )
116116 process = self .get_basic_process ()
117117 memory_range = lldb .SBMemoryRegionInfo ()
118- process .GetMemoryRegionInfo (0x7FFF12A84030 , memory_range )
118+
119+ # Add the memory range of 0x1000-0x1100
120+ process .GetMemoryRegionInfo (0x1000 , memory_range )
119121 options .AddMemoryRegionToSave (memory_range )
122+
123+ # Check that we fail when we have no process set
124+ # even though we added a memory region.
120125 error = lldb .SBError ()
121126 total = options .GetCurrentSizeInBytes (error )
122127 self .assertTrue (error .Fail (), error .GetCString ())
128+
129+ # Check that we don't get an error now that we've added a process
123130 options .SetProcess (process )
124131 total = options .GetCurrentSizeInBytes (error )
125132 self .assertTrue (error .Success (), error .GetCString ())
133+
134+ # Validate the size returned is the same size as the single region we added.
126135 expected_size = memory_range .GetRegionEnd () - memory_range .GetRegionBase ()
127136 self .assertEqual (total , expected_size )
137+
138+ def test_get_total_in_bytes_missing_requirements (self ):
139+ """
140+ Tests the matrix of error responses that GetCurrentSizeInBytes
141+ """
142+
143+ options = lldb .SBSaveCoreOptions ()
144+
145+ # No process, no style returns an error.
146+ error = lldb .SBError ()
147+ total = options .GetCurrentSizeInBytes (error )
148+ self .assertTrue (error .Fail (), error .GetCString ())
149+
150+ # No process returns an error
151+ options .SetStyle (lldb .eSaveCoreCustomOnly )
152+ total = options .GetCurrentSizeInBytes (error )
153+ self .assertTrue (error .Fail (), error .GetCString ())
154+
155+ options .Clear ()
156+
157+ # No style returns an error
158+ process = self .get_basic_process ()
159+ options .SetProcess (process )
160+ total = options .GetCurrentSizeInBytes (error )
161+ self .assertTrue (error .Fail (), error .GetCString ())
162+
163+ # Options that result in no valid data returns an error.
164+ options .SetStyle (lldb .eSaveCoreCustomOnly )
165+ total = options .GetCurrentSizeInBytes (error )
166+ self .assertTrue (error .Fail (), error .GetCString ())
0 commit comments