brintos

brintos / linux-shallow public Read only

0
0
Text · 1.5 KiB · 47c7b80 Raw
94 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03# Copyright(c) 2020 Intel Corporation.4 5ksft_pass=06ksft_fail=17ksft_xfail=28ksft_xpass=39ksft_skip=410 11XSKOBJ=xskxceiver12 13validate_root_exec()14{15	msg="skip all tests:"16	if [ $UID != 0 ]; then17		echo $msg must be run as root >&218		test_exit $ksft_fail19	else20		return $ksft_pass21	fi22}23 24validate_veth_support()25{26	msg="skip all tests:"27	if [ $(ip link add $1 type veth 2>/dev/null; echo $?;) != 0 ]; then28		echo $msg veth kernel support not available >&229		test_exit $ksft_skip30	else31		ip link del $132		return $ksft_pass33	fi34}35 36test_status()37{38	statusval=$139	if [ $statusval -eq $ksft_fail ]; then40		echo "$2: [ FAIL ]"41	elif [ $statusval -eq $ksft_skip ]; then42		echo "$2: [ SKIPPED ]"43	elif [ $statusval -eq $ksft_pass ]; then44		echo "$2: [ PASS ]"45	fi46}47 48test_exit()49{50	if [ $1 -ne 0 ]; then51		test_status $1 $(basename $0)52	fi53	exit 154}55 56cleanup_iface()57{58	ip link set $1 mtu $259	ip link set $1 xdp off60	ip link set $1 xdpgeneric off61}62 63clear_configs()64{65	[ $(ip link show $1 &>/dev/null; echo $?;) == 0 ] &&66		{ ip link del $1; }67}68 69cleanup_exit()70{71	clear_configs $1 $272}73 74validate_ip_utility()75{76	[ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip; }77}78 79exec_xskxceiver()80{81        if [[ $busy_poll -eq 1 ]]; then82	        ARGS+="-b "83	fi84 85	./${XSKOBJ} -i ${VETH0} -i ${VETH1} ${ARGS}86	retval=$?87 88	if [[ $list -ne 1 ]]; then89	    test_status $retval "${TEST_NAME}"90	    statusList+=($retval)91	    nameList+=(${TEST_NAME})92	fi93}94