HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //lib64/python3.9/site-packages/borg/__pycache__/selftest.cpython-39.opt-1.pyc
a

HZ�h9�@s�dZddlZddlZddlZddlmZmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZe	e
ee
egZdZGd	d
�d
e�Zdd�ZdS)
af
Self testing module
===================

The selftest() function runs a small test suite of relatively fast tests that are meant to discover issues
with the way Borg was compiled or packaged and also bugs in Borg itself.

These tests are a subset of the borg/testsuite and are run with Pythons built-in unittest, hence none of
the tests used for this can or should be ported to py.test currently.

To assert that self test discovery works correctly the number of tests is kept in the SELFTEST_COUNT
variable. SELFTEST_COUNT must be updated if new tests are added or removed to or from any of the tests
used here.
�N)�
TestResult�	TestSuite�defaultTestLoader�)�HashIndexDataTestCase�HashIndexRefcountingTestCase�HashIndexTestCase)�CryptoTestCase)�ChunkerTestCase�!cs@eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Z�ZS)�SelfTestResultcst���g|_dS�N)�super�__init__�	successes��self��	__class__��3/usr/lib64/python3.9/site-packages/borg/selftest.pyr(s
zSelfTestResult.__init__cst��|�|j�|�dSr
)r�
addSuccessr�append�r�testrrrr,szSelfTestResult.addSuccesscCs|��pt|�Sr
)ZshortDescription�strrrrr�	test_name0szSelfTestResult.test_namecCsX|j|j|jD]\}}|�d|�|�|�q|jD]\}}|�d|�|�|�q6dS)Nzself test %s FAILED:
%szself test %s skipped: %s)�errorsZfailuresZunexpectedSuccesses�errorrZskippedZwarning)r�loggerrZfailure�reasonrrr�log_results3szSelfTestResult.log_resultscCs
t|j�Sr
)�lenrrrrr�successful_test_count9sz$SelfTestResult.successful_test_count)	�__name__�
__module__�__qualname__rrrr!r#�
__classcell__rrrrr's
rc	Cs�tj�d�dkr|�d�dSt��}t�}t�}tD] }t	j
|j}|�t
�|��q6|�|�|�|�|��}|tk}|��r�|r�|�d|t�|��r�|r�|�d�t	�d�t��|}|�d||�dS)NZ
BORG_SELFTESTZdisabledz5borg selftest disabled via BORG_SELFTEST env variablezwself test count (%d != %d) mismatch, either test discovery is broken or a test was added without updating borg.selftestzmself test failed
Could be a bug either in Borg, the package / distribution you use, your OS or your hardware.�z'%d self tests completed in %.2f seconds)�os�environ�get�debug�time�perf_counterrr�SELFTEST_CASES�sys�modulesr%ZaddTestrZloadTestsFromTestCase�runr!r#�SELFTEST_COUNTZ
wasSuccessfulr�exit)	rZselftest_started�resultZ
test_suiteZ	test_case�moduleZsuccessful_testsZcount_mismatchZselftest_elapsedrrr�selftest=s,


�

r7)�__doc__r)r0r-ZunittestrrrZtestsuite.hashindexrrrZtestsuite.cryptor	Ztestsuite.chunkerr
r/r3rr7rrrr�<module>s �