def test_canBuildNewQueue(self):
     SharedHashFile.attach('/dev/shm', SharedFileName, 1)
     testQs         = 3
     testQItems     = 10
     testQItemSize  = 4096
     testQidsNolockMax = 1
     SharedHashFile.qNew(testQs, testQItems, testQItemSize, testQidsNolockMax)
     self.assertGreater(SharedHashFile.qNewName("Testing"), -1)
 def test_PushItemsFromAtoBautomatically(self):
     SharedHashFile.attach('/dev/shm', SharedFileName, 1)
     testQs         = 3
     testQItems     = 2
     testQItemSize  = 4096
     testQidsNolockMax = 1
     invalid = 4294967295
     SharedHashFile.qNew(testQs, testQItems, testQItemSize, testQidsNolockMax)
     source = SharedHashFile.qNewName("TestingAtoB")
     dest = SharedHashFile.qNewName("TestingBtoA")
     
     nextItem = SharedHashFile.qPushHeadPullTail(dest, invalid, source)
     
     nextItem = SharedHashFile.qPushHeadPullTail(dest, nextItem, source)
     self.assertNotEqual(nextItem, invalid)
     
     nextItem = SharedHashFile.qPushHeadPullTail(dest, nextItem, source)
     self.assertEqual(nextItem, invalid)
Exemplo n.º 3
0
import SharedHashFile
from os import system, getpid
from struct import *

if __name__ == "__main__":

  SharedFileName = 'shf-test' + str(getpid()) 
  SharedHashFile.attach('/dev/shm', SharedFileName, 1)
  testQs         = 3
  testQItems     = 10
  testQItemSize  = 65535 # Maximum possible size of TCP packet
  testQidsNolockMax = 1
  SHF_QIID_NONE = 4294967295
  
  QueueMem = SharedHashFile.qNew(testQs, testQItems, testQItemSize, testQidsNolockMax)
  QueueFree = SharedHashFile.qNewName("QueueFree")
  QueueA2B = SharedHashFile.qNewName("QueueAtoB")
  QueueB2A = SharedHashFile.qNewName("QueueBtoA")

  i = 10

  print "Loading from Free Queue onto A2B Queue..."
  # Move items from free queue onto A2B queue
  currElem = SharedHashFile.qPullTailData(QueueFree)
  while (currElem is not None):
    # Get Data and Qiid
    currElemData = currElem[0]
    currElemQiid = currElem[1]

    # Write to data
    currElemData[0:4] = pack('i', i)
Exemplo n.º 4
0
 def test_canAttachToExistingSharedMemory(self):
     SharedHashFile.attach('/dev/shm', 'test-luke1')
     self.assertTrue(SharedHashFile.attachExisting('/dev/shm', 'test-luke1'))
Exemplo n.º 5
0
 def test_canAttachToSharedMemory(self):
     self.assertTrue(SharedHashFile.attach('/dev/shm', 'test-luke1'))
Exemplo n.º 6
0
 def test_setdebuggingLogging(self):
     SharedHashFile.debugVerbosityLess()
     pass
 def test_canAttachToSharedMemory(self):
     self.assertTrue(SharedHashFile.attach('/dev/shm', SharedFileName, 1))
 def tearDown(self):
     unittest.TestCase.tearDown(self)
     if SharedHashFile.isAttached():
         SharedHashFile.delete()
 def test_canAttachToExistingSharedMemory(self):
     SharedHashFile.attach('/dev/shm', SharedFileName, 1)
     self.assertTrue(SharedHashFile.attachExisting('/dev/shm', SharedFileName))