CI: Add tuntap to test
Sample run ``` :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 17:14:21 ] :: [ LOG ] :: ip tuntap tests :: [ 17:14:21 ] :: [ BEGIN ] :: Running '/usr/bin/python3 /usr/bin/ip-tuntap-tests.py' test_add_tap (__main__.IPTuntapTests) ... fopen /sys/class/net/ip6gre0/tun_flags: No such file or directory fopen /sys/class/net/wlan0/tun_flags: No such file or directory ok ok test_add_tun_user_group (__main__.IPTuntapTests) ... fopen /sys/class/net/ip6gre0/tun_flags: No such file or directory ok ---------------------------------------------------------------------- Ran 3 tests in 0.049s OK :: [ 17:14:21 ] :: [ PASS ] :: Command '/usr/bin/python3 /usr/bin/ip-tuntap-tests.py' (Expected 0, got 0) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 0s :: Assertions: 1 good, 0 bad :: RESULT: PASS ```
This commit is contained in:
parent
1abbe5eb83
commit
5c4250bd81
47
tests/ip-tuntap-sanity-test/Makefile
Normal file
47
tests/ip-tuntap-sanity-test/Makefile
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1+
|
||||||
|
# ~~~
|
||||||
|
# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test
|
||||||
|
# Description: Test basic ip tuntap funcionality
|
||||||
|
#
|
||||||
|
# Author: Susant Sahani <susant@redhat.com>
|
||||||
|
# Copyright (c) 2018 Red Hat, Inc.
|
||||||
|
#~~~
|
||||||
|
|
||||||
|
export TEST=/CoreOS/iproute/Sanity/ip-tuntap-sanity-test
|
||||||
|
export TESTVERSION=1.0
|
||||||
|
|
||||||
|
BUILT_FILES=
|
||||||
|
|
||||||
|
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||||
|
|
||||||
|
.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: Susant Sahani <susant@redhat.com>" > $(METADATA)
|
||||||
|
@echo "Name: $(TEST)" >> $(METADATA)
|
||||||
|
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||||
|
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||||
|
@echo "Description: Test basic ip tuntap funcionality" >> $(METADATA)
|
||||||
|
@echo "Type: Sanity" >> $(METADATA)
|
||||||
|
@echo "TestTime: 15m" >> $(METADATA)
|
||||||
|
@echo "RunFor: iproute" >> $(METADATA)
|
||||||
|
@echo "Requires: iproute" >> $(METADATA)
|
||||||
|
@echo "Priority: Normal" >> $(METADATA)
|
||||||
|
@echo "License: GPLv2" >> $(METADATA)
|
||||||
|
@echo "Confidential: no" >> $(METADATA)
|
||||||
|
@echo "Destructive: no" >> $(METADATA)
|
||||||
|
|
||||||
|
rhts-lint $(METADATA)
|
3
tests/ip-tuntap-sanity-test/PURPOSE
Normal file
3
tests/ip-tuntap-sanity-test/PURPOSE
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PURPOSE of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test
|
||||||
|
Description: Test basic ip tuntap funcionality
|
||||||
|
Author: Susant Sahani <susant@redhat.com>
|
65
tests/ip-tuntap-sanity-test/ip-tuntap-tests.py
Executable file
65
tests/ip-tuntap-sanity-test/ip-tuntap-tests.py
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1+
|
||||||
|
# ~~~
|
||||||
|
# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test
|
||||||
|
# Description: Test basic ip tuntap funcionality
|
||||||
|
#
|
||||||
|
# Author: Susant Sahani <susant@redhat.com>
|
||||||
|
# Copyright (c) 2018 Red Hat, Inc.
|
||||||
|
# ~~~
|
||||||
|
|
||||||
|
import errno
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import unittest
|
||||||
|
import subprocess
|
||||||
|
import signal
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
def setUpModule():
|
||||||
|
|
||||||
|
if shutil.which('ip') is None:
|
||||||
|
raise OSError(errno.ENOENT, 'ip not found')
|
||||||
|
|
||||||
|
class IPLinkUtilities():
|
||||||
|
|
||||||
|
def link_exists(self, link):
|
||||||
|
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
|
||||||
|
|
||||||
|
class IPTuntapTests(unittest.TestCase, IPLinkUtilities):
|
||||||
|
|
||||||
|
def test_add_tap(self):
|
||||||
|
|
||||||
|
subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tap-test', 'mode', 'tap'])
|
||||||
|
self.link_exists('tap-test')
|
||||||
|
|
||||||
|
output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tap-test']).rstrip().decode('utf-8')
|
||||||
|
self.assertRegex(output, "tap-test: tap")
|
||||||
|
|
||||||
|
subprocess.check_output(['ip', 'link', 'del', 'tap-test'])
|
||||||
|
|
||||||
|
def test_add_tun(self):
|
||||||
|
|
||||||
|
subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tun-test', 'mode', 'tun'])
|
||||||
|
self.link_exists('tun-test')
|
||||||
|
|
||||||
|
output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tun-test']).rstrip().decode('utf-8')
|
||||||
|
self.assertRegex(output, "tun-test: tun")
|
||||||
|
|
||||||
|
subprocess.check_output(['ip', 'link', 'del', 'tun-test'])
|
||||||
|
|
||||||
|
def test_add_tun_user_group(self):
|
||||||
|
|
||||||
|
subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tun-test', 'mode', 'tun', 'user', 'root', 'group', 'root'])
|
||||||
|
self.link_exists('tun-test')
|
||||||
|
|
||||||
|
output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tun-test']).rstrip().decode('utf-8')
|
||||||
|
self.assertRegex(output, "tun-test: tun")
|
||||||
|
self.assertRegex(output, "user 0 group 0")
|
||||||
|
|
||||||
|
subprocess.check_output(['ip', 'link', 'del', 'tun-test'])
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
|
||||||
|
verbosity=2))
|
34
tests/ip-tuntap-sanity-test/runtest.sh
Executable file
34
tests/ip-tuntap-sanity-test/runtest.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1+
|
||||||
|
# ~~~
|
||||||
|
# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test
|
||||||
|
# Description: Test basic ip tuntap funcionality
|
||||||
|
#
|
||||||
|
# Author: Susant Sahani <susant@redhat.com>
|
||||||
|
# Copyright (c) 2018 Red Hat, Inc.
|
||||||
|
#~~~
|
||||||
|
|
||||||
|
# Include Beaker environment
|
||||||
|
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||||
|
|
||||||
|
PACKAGE="iproute"
|
||||||
|
|
||||||
|
rlJournalStart
|
||||||
|
rlPhaseStartSetup
|
||||||
|
rlAssertRpm $PACKAGE
|
||||||
|
rlRun "cp ip-tuntap-tests.py /usr/bin"
|
||||||
|
rlPhaseEnd
|
||||||
|
|
||||||
|
rlPhaseStartTest
|
||||||
|
rlLog "ip tuntap tests"
|
||||||
|
rlRun "/usr/bin/python3 /usr/bin/ip-tuntap-tests.py"
|
||||||
|
rlPhaseEnd
|
||||||
|
|
||||||
|
rlPhaseStartCleanup
|
||||||
|
rlRun "rm /usr/bin/ip-tuntap-tests.py"
|
||||||
|
rlLog "ip tuntap tests done"
|
||||||
|
rlPhaseEnd
|
||||||
|
rlJournalPrintText
|
||||||
|
rlJournalEnd
|
||||||
|
|
||||||
|
rlGetTestState
|
@ -15,6 +15,7 @@
|
|||||||
- ip-address-label-sanity-test
|
- ip-address-label-sanity-test
|
||||||
- ip-fou-sanity-test
|
- ip-fou-sanity-test
|
||||||
- ip-token-sanity-test
|
- ip-token-sanity-test
|
||||||
|
- ip-tuntap-sanity-test
|
||||||
required_packages:
|
required_packages:
|
||||||
- iproute
|
- iproute
|
||||||
- bridge-utils
|
- bridge-utils
|
||||||
|
Loading…
Reference in New Issue
Block a user