def test_non_overflow(slabutil):
    "Test that slabs do not overflow upto the slab LRU size."
    slabs = []
    def _mkslab(i):
        v = [i * _SLABSZ]
        return slabutil_make_slab(_NS, zip(map(str, v), v))

    def _cb(self, key, slabdesc, seq=[0]):
        assert False

    lc = LRUCache(_LRUSZ, _cb)
    for i in xrange(_LRUSZ):
        sl = _mkslab(i)
        slabs.append(sl)
        lc.insert_slab(sl)
Exemple #2
0
def test_non_overflow(slabutil):
    "Test that slabs do not overflow upto the slab LRU size."
    slabs = []

    def _mkslab(i):
        v = [i * _SLABSZ]
        return slabutil_make_slab(_NS, zip(map(str, v), v))

    def _cb(self, key, slabdesc, seq=[0]):
        assert False

    lc = LRUCache(_LRUSZ, _cb)
    for i in xrange(_LRUSZ):
        sl = _mkslab(i)
        slabs.append(sl)
        lc.insert_slab(sl)
def test_overflow(slabutil):
    "Test that slabs overflow in LRU sequence."

    slabs = []
    def _mkslab(i):
        v = [i * _SLABSZ]
        return slabutil_make_slab(_NS, zip(map(str, v), v))

    def _cb(slabkey, slabdesc, seq=[0]):
        n = seq[0]
        assert slabdesc is slabs[n]
        seq[0] = n + 1

    lc = LRUCache(_LRUSZ, _cb)
    for i in xrange(2*_LRUSZ):
        sl = _mkslab(i)
        slabs.append(sl)
        lc.insert_slab(sl)
Exemple #4
0
def test_overflow(slabutil):
    "Test that slabs overflow in LRU sequence."

    slabs = []

    def _mkslab(i):
        v = [i * _SLABSZ]
        return slabutil_make_slab(_NS, zip(map(str, v), v))

    def _cb(slabkey, slabdesc, seq=[0]):
        n = seq[0]
        assert slabdesc is slabs[n]
        seq[0] = n + 1

    lc = LRUCache(_LRUSZ, _cb)
    for i in xrange(2 * _LRUSZ):
        sl = _mkslab(i)
        slabs.append(sl)
        lc.insert_slab(sl)
Exemple #5
0
def test_flush(slabutil):
    "Test that flush presents slabs in sequence."

    slabs = []

    def _mkslab(i):
        v = [i * _SLABSZ]
        return slabutil_make_slab(_NS, zip(map(str, v), v))

    seen = [False]

    def _cb(slabkey, slabdesc, seq=[0], seen=seen):
        seen[0] = True
        n = seq[0]
        assert slabdesc is slabs[n]
        seq[0] = n + 1

    lc = LRUCache(_LRUSZ, _cb)
    for i in xrange(_LRUSZ):
        sl = _mkslab(i)
        slabs.append(sl)
        lc.insert_slab(sl)

    lc.flush()
    assert seen[0] is True
def test_flush(slabutil):
    "Test that flush presents slabs in sequence."

    slabs = []
    def _mkslab(i):
        v = [i * _SLABSZ]
        return slabutil_make_slab(_NS, zip(map(str, v), v))

    seen = [False]
    def _cb(slabkey, slabdesc, seq=[0], seen=seen):
        seen[0] = True
        n = seq[0]
        assert slabdesc is slabs[n]
        seq[0] = n + 1

    lc = LRUCache(_LRUSZ, _cb)
    for i in xrange(_LRUSZ):
        sl = _mkslab(i)
        slabs.append(sl)
        lc.insert_slab(sl)


    lc.flush()
    assert seen[0] is True
Exemple #7
0
def test_empty(slabutil):
    "Test the properties of an empty cache object."

    lc = LRUCache(_LRUSZ)
    assert len(lc) == 0
    assert lc.get(_NS, _KEY) is None
Exemple #8
0
def pytest_funcarg__lrucache(request):
    "Prepare a pre-initialized cache object."
    return LRUCache(_LRUSZ)
def test_empty(slabutil):
    "Test the properties of an empty cache object."

    lc = LRUCache(_LRUSZ)
    assert len(lc) == 0
    assert lc.get(_NS, _KEY) is None