Package rekall :: Module session_test
[frames] | no frames]

Source Code for Module rekall.session_test

 1  from rekall import addrspace 
 2  from rekall import testlib 
 3  from rekall import session 
 4   
 5   
6 -class CustomAddressSpace(addrspace.BaseAddressSpace):
7
8 - def ConfigureSession(self, session_obj):
9 session_obj.SetCache("foo", "bar", volatile=False)
10 11
12 -class SessionTest(testlib.RekallBaseUnitTestCase):
13 """Test the RunBasedAddressSpace implementation.""" 14
15 - def setUp(self):
16 self.session = session.Session() 17 self.physical_AS = CustomAddressSpace(session=self.session)
18
19 - def testSessionCache(self):
20 """Make sure session gets the correct cache.""" 21 with self.session: 22 self.session.SetParameter("cache", "memory") 23 24 # Set something in the session cache. 25 self.session.SetCache("a", "b") 26 27 # Make sure it is set. 28 self.assertEqual(self.session.GetParameter("a"), "b") 29 30 self.physical_AS.volatile = False 31 self.session.physical_address_space = self.physical_AS 32 33 # None volatile physical address space should use the user specified 34 # cache type. 35 self.assertEqual(self.session.cache.__class__.__name__, "Cache") 36 37 # Assigning the physical address space causes the cache to be 38 # purged. The cache is allowed to be purged at any time (it is only a 39 # cache). 40 self.assertEqual(self.session.GetParameter("a"), None) 41 42 # Volatile physical address space forces a TimedCache 43 self.physical_AS.volatile = True 44 self.session.physical_address_space = self.physical_AS 45 46 self.assertEqual(self.session.cache.__class__.__name__, "TimedCache") 47 48 # Any parameters set by the address space should be present in the 49 # session cache. 50 self.assertEqual(self.session.GetParameter("foo"), "bar")
51