From 82012fd019cbc619cccee875f92556be30c2b327 Mon Sep 17 00:00:00 2001 From: Petr Menšík Date: Oct 16 2019 13:25:39 +0000 Subject: Include kernel/network library Made as helper to already present networking-common library, which does not offer rlImport backend. It is backward compatible with internal kernel/network library. That is the reason why networking-common library is not used for import, no such library exists internally. --- diff --git a/kernel/network/Makefile b/kernel/network/Makefile new file mode 100644 index 0000000..09fa212 --- /dev/null +++ b/kernel/network/Makefile @@ -0,0 +1,58 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: Set of common function/utils for network-qe test +# Author: Zhenjie Chen +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/kernel/Library/network +export TESTVERSION=1.1 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh lib.sh Makefile + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +-include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Zhenjie Chen " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Set of common function for network-qe test" >> $(METADATA) + @echo "Type: Library" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "Provides: library(kernel/network)" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/kernel/network/lib.sh b/kernel/network/lib.sh new file mode 100644 index 0000000..30d1a8a --- /dev/null +++ b/kernel/network/lib.sh @@ -0,0 +1,120 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k sts=4 sw=4 et +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: network-qe lib +# Author: Zhenjie Chen +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# library-prefix = network +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +true <<'=cut' +=pod + +=head1 NAME + +kernel/network - tools to setup testing network environment + +=head1 DESCRIPTION + +This is basic library for creation of network interfaces and working with them. + +=cut + +networkFindInclude() +{ + for kernelBase in $@ + do + local CANDIDATE="$kernelBase/networking-common/include.sh" + if [ -f "$CANDIDATE" ] + then + echo $CANDIDATE + exit 0 + else + CANDIDATE="$kernelBase/Library/networking-common/include.sh" + if [ -f "$CANDIDATE" ] + then + echo $CANDIDATE + exit 0 + fi + fi + done + exit 1 +} + +if [ -n "$BASH_SOURCE" ] +then + # BASH_SOURCE=*/kernel/Library/network/lib.sh + # fetch kernel base, ie */kernel + local kernelBase="$(dirname -- $(dirname -- $(dirname -- $BASH_SOURCE)))" + local include=$(networkFindInclude "$kernelBase" /usr/share/beakerlib-libraries/kernel) + + [ -f "$include" ] && source "$include" +fi + + +<<'=cut' +=pod + +=head1 VARIABLES + +Below is the list of global variables. When writing a new library, +please make sure that all global variables start with the library +prefix to prevent collisions with other libraries. + +=over + +=item NETWORK_COMMONLIB_DIR + +Directory to networking tools script + +=back + +=head1 FUNCTIONS + +=head2 networkToolsEnable + +Adds tools into path. After calling it, just call or source netns_?_net.sh. +On cleanup phase, call netns_clean.sh to remove created namespaces. + +=over + +=back +=cut +networkToolsEnable() { + export PATH="$PATH:$networkLib/tools" +} + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Verification +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# This is a verification callback which will be called by +# rlImport after sourcing the library to make sure everything is +# all right. It makes sense to perform a basic sanity test and +# check that all required packages are installed. The function +# should return 0 only when the library is ready to serve. + +networkLibraryLoaded() { + [ -d "$networkLib" ] +} diff --git a/kernel/network/runtest.sh b/kernel/network/runtest.sh new file mode 100644 index 0000000..add4412 --- /dev/null +++ b/kernel/network/runtest.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k sts=4 sw=4 et +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: execution of netowk-qe lib +# Author: Zhenjie Chen +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="kernel-kernel-Library-network" + +rlJournalStart + rlImport kernel/network + rlPhaseStartSetup + rlRun "rlImport kernel/network" + rlRun "networkToolsEnable" + rlPhaseEnd + rlPhaseStartTest "Test of namespaces" + rlRun "netns_2_net.sh" + rlPhaseEnd + rlPhaseStartCleanup + rlRun "netns_clean.sh" + rlPhaseEnd +rlJournalEnd