[libcalamares] Test the Entropy service
This commit is contained in:
parent
a574b43eb8
commit
8947f9c00c
@ -19,6 +19,7 @@
|
||||
#include "Tests.h"
|
||||
|
||||
#include "CalamaresUtilsSystem.h"
|
||||
#include "Entropy.h"
|
||||
#include "Logger.h"
|
||||
#include "UMask.h"
|
||||
#include "Yaml.h"
|
||||
@ -176,3 +177,26 @@ LibCalamaresTests::testUmask()
|
||||
QCOMPARE( CalamaresUtils::setUMask( 022 ), m );
|
||||
QCOMPARE( CalamaresUtils::setUMask( m ), 022 );
|
||||
}
|
||||
|
||||
void
|
||||
LibCalamaresTests::testEntropy()
|
||||
{
|
||||
QByteArray data;
|
||||
|
||||
auto r0 = CalamaresUtils::getEntropy( 0, data );
|
||||
QCOMPARE( CalamaresUtils::EntropySource::None, r0 );
|
||||
QCOMPARE( 0, data.size() );
|
||||
|
||||
auto r1 = CalamaresUtils::getEntropy( 16, data );
|
||||
QVERIFY( r1 != CalamaresUtils::EntropySource::None );
|
||||
QCOMPARE( 16, data.size() );
|
||||
// This can randomly fail (but not often)
|
||||
QVERIFY( data.at( data.size() - 1 ) != char( 0xcb ) );
|
||||
|
||||
auto r2 = CalamaresUtils::getEntropy( 8, data );
|
||||
QVERIFY( r2 != CalamaresUtils::EntropySource::None );
|
||||
QCOMPARE( 8, data.size() );
|
||||
QCOMPARE( r1, r2 );
|
||||
// This can randomly fail (but not often)
|
||||
QVERIFY( data.at( data.size() - 1 ) != char( 0xcb ) );
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ private Q_SLOTS:
|
||||
|
||||
/** @brief Test that all the UMask objects work correctly. */
|
||||
void testUmask();
|
||||
|
||||
/** @brief Tests the entropy functions. */
|
||||
void testEntropy();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user