mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Mock ldd command response.
Test aarch64 detection Arm v6/v7 little endian. x86_64 native Test aarch64 detection Unknown platform detection. Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
7032be6049
commit
26c628f8a5
1 changed files with 42 additions and 12 deletions
|
@ -297,34 +297,64 @@ def test_update_package_cache_failure_no_errors(Pihole):
|
||||||
assert 'ERROR' in updateCache.stdout
|
assert 'ERROR' in updateCache.stdout
|
||||||
assert 'done!' not in updateCache.stdout
|
assert 'done!' not in updateCache.stdout
|
||||||
|
|
||||||
def test_FTL_download_aarch64_no_errors(Pihole):
|
def test_FTL_detect_aarch64_no_errors(Pihole):
|
||||||
''' confirms only aarch64 package is downloaded for FTL engine '''
|
''' confirms only aarch64 package is downloaded for FTL engine '''
|
||||||
# mock uname to return aarch64 platform
|
# mock uname to return aarch64 platform
|
||||||
mock_command('uname', {'-m':('aarch64', '0')}, Pihole)
|
mock_command('uname', {'-m':('aarch64', '0')}, Pihole)
|
||||||
|
# mock ldd to respond with aarch64 shared library
|
||||||
|
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-aarch64.so.1', '0')}, Pihole)
|
||||||
detectPlatform = Pihole.run('''
|
detectPlatform = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdownload
|
FTLdownload
|
||||||
touch /lib/ld-linux-aarch64.so.1
|
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Detected ARM-aarch64 architecture'
|
expected_stdout = 'Detected ARM-aarch64 architecture'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
FTL_binary = Pihole.run('echo ${binary}').stdout
|
|
||||||
assert 'pihole-FTL-aarch64-linux-gnu' in FTL_binary
|
|
||||||
|
|
||||||
def test_FTL_download_armv6l_Pi_Zero_no_errors(Pihole):
|
def test_FTL_detect_armv6l_no_errors(Pihole):
|
||||||
''' confirms only armv6l package is downloaded for FTL engine (Pi-Zero) '''
|
''' confirms only armv6l package is downloaded for FTL engine '''
|
||||||
# mock uname to return aarch64 platform
|
# mock uname to return armv6l platform
|
||||||
mock_command('uname', {'-m':('armv6l', '0')}, Pihole)
|
mock_command('uname', {'-m':('armv6l', '0')}, Pihole)
|
||||||
|
# mock ldd to respond with aarch64 shared library
|
||||||
|
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-armhf.so.3', '0')}, Pihole)
|
||||||
detectPlatform = Pihole.run('''
|
detectPlatform = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdownload
|
FTLdownload
|
||||||
touch /lib/ld-linux-armhf.so.3
|
|
||||||
ls -lach /lib/
|
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Detected ARM-hf architecture'
|
expected_stdout = 'Detected ARM-hf architecture (armv6 or lower)'
|
||||||
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
|
||||||
|
def test_FTL_detect_armv7l_no_errors(Pihole):
|
||||||
|
''' confirms only armv7l package is downloaded for FTL engine '''
|
||||||
|
# mock uname to return armv7l platform
|
||||||
|
mock_command('uname', {'-m':('armv7l', '0')}, Pihole)
|
||||||
|
# mock ldd to respond with aarch64 shared library
|
||||||
|
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-armhf.so.3', '0')}, Pihole)
|
||||||
|
detectPlatform = Pihole.run('''
|
||||||
|
source /opt/pihole/basic-install.sh
|
||||||
|
FTLdownload
|
||||||
|
''')
|
||||||
|
expected_stdout = 'Detected ARM-hf architecture (armv7+)'
|
||||||
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
|
||||||
|
def test_FTL_detect_x86_64_no_errors(Pihole):
|
||||||
|
''' confirms only x86_64 package is downloaded for FTL engine '''
|
||||||
|
detectPlatform = Pihole.run('''
|
||||||
|
source /opt/pihole/basic-install.sh
|
||||||
|
FTLdownload
|
||||||
|
''')
|
||||||
|
expected_stdout = 'Detected x86_64 architecture'
|
||||||
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
|
||||||
|
def test_FTL_detect_unknown_no_errors(Pihole):
|
||||||
|
''' confirms only generic package is downloaded for FTL engine '''
|
||||||
|
# mock uname to return generic platform
|
||||||
|
mock_command('uname', {'-m':('mips', '0')}, Pihole)
|
||||||
|
detectPlatform = Pihole.run('''
|
||||||
|
source /opt/pihole/basic-install.sh
|
||||||
|
FTLdownload
|
||||||
|
''')
|
||||||
|
expected_stdout = 'Not able to detect architecture (unknown: mips)'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
FTL_binary = Pihole.run('echo ${binary}').stdout
|
|
||||||
assert 'pihole-FTL-arm-linux-gnueabihf' in FTL_binary
|
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
def mock_command(script, args, container):
|
def mock_command(script, args, container):
|
||||||
|
|
Loading…
Reference in a new issue