forked from os-autoinst/os-autoinst-distri-opensuse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test privileged mode in podman and docker. The command mount -t tmpfs none /mnt only works in privileged mode because the read-only protection in the default mode https://progress.opensuse.org/issues/135518
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# SUSE's openQA tests | ||
# | ||
# Copyright 2023 SUSE LLC | ||
# SPDX-License-Identifier: FSFAP | ||
|
||
# Package: podman | ||
# Summary: Test container runtime privileged mode | ||
# Maintainer: qa-c@suse.de | ||
|
||
use Mojo::Base 'containers::basetest'; | ||
use testapi; | ||
use serial_terminal 'select_serial_terminal'; | ||
use utils qw(validate_script_output_retry); | ||
use containers::utils qw(reset_container_network_if_needed); | ||
|
||
sub run { | ||
my ($self, $args) = @_; | ||
select_serial_terminal; | ||
|
||
my $runtime = $args->{runtime}; | ||
my $engine = $self->containers_factory($runtime); | ||
$self->{runtime} = $engine; | ||
reset_container_network_if_needed($runtime); | ||
|
||
my $image = "registry.suse.com/bci/bci-base:latest" | ||
|
||
record_info('Test', 'Launch a container with privileged mode'); | ||
# /dev is only accessible in privileged mode | ||
assert_script_run("$runtime run -ti --rm --privileged $image ls /dev/bus"); | ||
|
||
# Mounting tmpfs only works in privileged mode because the read-only protection in the default mode | ||
assert_script_run("$runtime run -ti --rm --privileged $image mount -t tmpfs none /mnt"); | ||
|
||
# Mounting a device only works in privileged mode | ||
assert_script_run("$runtime run -ti --rm --privileged $image bash -c 'modprobe dummy && lsmod | grep dummy'"); | ||
|
||
# Capabilities are only available in privileged mode | ||
my $capbnd = script_output("cat /proc/1/status | grep CapBnd"); | ||
validate_script_output("$runtime run -ti --rm --privileged $image cat /proc/1/status | grep CapBnd", sub { m/$capbnd/ }); | ||
} | ||
|
||
sub cleanup { | ||
my ($self) = @_; | ||
$self->{runtime}->cleanup_system_host(); | ||
} | ||
|
||
sub post_run_hook { | ||
my ($self) = @_; | ||
$self->cleanup(); | ||
} | ||
|
||
sub post_fail_hook { | ||
my ($self) = @_; | ||
$self->cleanup(); | ||
} | ||
|
||
1; |