diff mbox series

[2/3] tests: Skip unbind/bind tests when not root

Message ID 20200918202616.55977-3-kieran.bingham@ideasonboard.com (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series VSP-Tests: unbind: | expand

Commit Message

Kieran Bingham Sept. 18, 2020, 8:26 p.m. UTC
The user must be root to be able to perform the unbind/bind cycle.
Skip this test when the user does not have root privilidges.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 tests/vsp-unit-test-0026.sh | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Kieran Bingham Sept. 18, 2020, 8:45 p.m. UTC | #1
Hi Kieran

On 18/09/2020 21:26, Kieran Bingham wrote:
> The user must be root to be able to perform the unbind/bind cycle.
> Skip this test when the user does not have root privilidges.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  tests/vsp-unit-test-0026.sh | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tests/vsp-unit-test-0026.sh b/tests/vsp-unit-test-0026.sh
> index 0e013cec881b..88038f3fdebf 100755
> --- a/tests/vsp-unit-test-0026.sh
> +++ b/tests/vsp-unit-test-0026.sh
> @@ -41,6 +41,12 @@ test_copy() {
>  test_main() {
>  	local format
>  
> +	if [ ! "$(id -u)" = 0 ] ; then
> +		# Root is required to run unbind tests
> +		test_complete skip

Ugh, this is a bit annoying as it generates a warning on the output
actually, as we haven't yet called test_start.

We could do a test_start "Rebinding VSPs", and then it will either skip
or pass. But any failures would be in the kernel logs...

> +		return
> +	fi
> +
>  	# Unbind and rebind VSPs individually
>  	for v in $vsps; do
>  		unbind_vsp $v
>
diff mbox series

Patch

diff --git a/tests/vsp-unit-test-0026.sh b/tests/vsp-unit-test-0026.sh
index 0e013cec881b..88038f3fdebf 100755
--- a/tests/vsp-unit-test-0026.sh
+++ b/tests/vsp-unit-test-0026.sh
@@ -41,6 +41,12 @@  test_copy() {
 test_main() {
 	local format
 
+	if [ ! "$(id -u)" = 0 ] ; then
+		# Root is required to run unbind tests
+		test_complete skip
+		return
+	fi
+
 	# Unbind and rebind VSPs individually
 	for v in $vsps; do
 		unbind_vsp $v