403Webshell
Server IP : 213.136.93.164  /  Your IP : 216.73.216.20
Web Server : Apache
System : Linux m14200.contabo.net 5.14.0-611.54.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed May 6 18:03:03 EDT 2026 x86_64
User : ki692510 ( 1047)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib64/python3.9/site-packages/borg/testsuite/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib64/python3.9/site-packages/borg/testsuite/hashindex_stress.py
import os
import random

import pytest

from ..hashindex import NSIndex


@pytest.mark.skipif("BORG_TESTS_SLOW" not in os.environ, reason="slow tests not enabled, use BORG_TESTS_SLOW=1")
def test_hashindex_stress():
    """checks if the hashtable behaves as expected

    This can be used in _hashindex.c before running this test to provoke more collisions (don't forget to compile):
    #define HASH_MAX_LOAD .99
    #define HASH_MAX_EFF_LOAD .999
    """
    ENTRIES = 10000
    LOOPS = 1000
    idx = NSIndex()
    kv = {}
    for i in range(LOOPS):
        # put some entries
        for j in range(ENTRIES):
            k = random.randbytes(32)
            v = random.randint(0, NSIndex.MAX_VALUE - 1)
            idx[k] = (v, v)
            kv[k] = v
        # check and delete a random amount of entries
        delete_keys = random.sample(list(kv), k=random.randint(0, len(kv)))
        for k in delete_keys:
            v = kv.pop(k)
            assert idx.pop(k) == (v, v)
        # check if remaining entries are as expected
        for k, v in kv.items():
            assert idx[k] == (v, v)
        # check entry count
        assert len(kv) == len(idx)

Youez - 2016 - github.com/yon3zu
LinuXploit