Skip to content

Commit 5572ab5

Browse files
committed
luks: check if keyutils are usable before running tests
The command fails in Docker or otherwise limited environments, so skip the test when it is not usable. Signed-off-by: Oldřich Jedlička <[email protected]>
1 parent 2b60179 commit 5572ab5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/luks/tests/meson.build

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ cryptsetup = find_program('cryptsetup', required: true)
88
# Use keyctl to check an existing token id can be created from
99
# kernel keyring password
1010
keyutils = find_program('keyctl', required: false)
11+
keyutils_usable = false
1112
if keyutils.found()
12-
message('keyutils installed')
13+
keyutils_usable = run_command(keyutils, 'session', '-', '/bin/true', capture: false, check: false).returncode() == 0
14+
if keyutils_usable
15+
message('keyutils installed')
16+
else
17+
warning('keyutils installed, but running fails (are you inside Docker?), unable to test existing token id binding')
18+
endif
1319
else
1420
warning('keyutils not installed, unable to test existing token id binding')
1521
endif
@@ -82,7 +88,7 @@ if luksmeta_data.get('OLD_CRYPTSETUP') == '0'
8288
test('unbind-unbound-slot-luks2', find_program('unbind-unbound-slot-luks2'), env: env)
8389
test('unbind-luks2', find_program('unbind-luks2'), env: env, timeout: 60)
8490

85-
if keyutils.found() and luksmeta_data.get('OLD_CRYPTSETUP_EXISTING_TOKEN_ID') == '0'
91+
if keyutils.found() and keyutils_usable and luksmeta_data.get('OLD_CRYPTSETUP_EXISTING_TOKEN_ID') == '0'
8692
test('bind-luks2-ext-token', find_program('bind-luks2-ext-token'), env: env, timeout: 60)
8793
endif
8894

0 commit comments

Comments
 (0)