add CI tests using the standard test interface (astepano)
This commit is contained in:
parent
fbcc8c1370
commit
38b03e9432
13 changed files with 637 additions and 1 deletions
64
tests/setcap-getcap-basic-functionality/Makefile
Normal file
64
tests/setcap-getcap-basic-functionality/Makefile
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/libcap/Sanity/setcap-getcap-basic-functionality
|
||||
# Description: test basic functionality
|
||||
# Author: Karel Srot <ksrot@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
#
|
||||
# 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=/CoreOS/libcap/Sanity/setcap-getcap-basic-functionality
|
||||
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: Karel Srot <ksrot@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: test basic functionality" >> $(METADATA)
|
||||
@echo "Type: Sanity" >> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: libcap" >> $(METADATA)
|
||||
@echo "Requires: libcap" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
||||
3
tests/setcap-getcap-basic-functionality/PURPOSE
Normal file
3
tests/setcap-getcap-basic-functionality/PURPOSE
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
PURPOSE of /CoreOS/libcap/Sanity/setcap-getcap-basic-functionality
|
||||
Description: test basic functionality
|
||||
Author: Karel Srot <ksrot@redhat.com>
|
||||
98
tests/setcap-getcap-basic-functionality/runtest.sh
Executable file
98
tests/setcap-getcap-basic-functionality/runtest.sh
Executable file
|
|
@ -0,0 +1,98 @@
|
|||
#!/bin/bash
|
||||
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/libcap/Sanity/setcap-getcap-basic-functionality
|
||||
# Description: test basic functionality
|
||||
# Author: Karel Srot <ksrot@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
#
|
||||
# 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="libcap"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||
rlRun "pushd $TmpDir"
|
||||
rlRun "mkdir mydir && touch file1 mydir/file2 mydir/file3"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "set and get capabilities"
|
||||
rlRun "setcap cap_net_admin+p file1 cap_net_raw+ei mydir/file2"
|
||||
rlRun -s "getcap file1 mydir/file2"
|
||||
rlAssertGrep "file1 = cap_net_admin+p" $rlRun_LOG
|
||||
rlAssertGrep "mydir/file2 = cap_net_raw+ei" $rlRun_LOG
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "set capabilities via stdin"
|
||||
rlRun "echo -e 'cap_net_raw+p\ncap_net_admin+p' > input"
|
||||
rlRun -s "setcap - mydir/file3 < input"
|
||||
rlAssertGrep "Please enter caps for file \[empty line to end\]:" $rlRun_LOG
|
||||
rlRun "getcap mydir/file3 | grep 'mydir/file3 = cap_net_admin,cap_net_raw+p'"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "set capabilities quietly via stdin"
|
||||
rlRun "echo -e 'cap_net_raw+p' > input"
|
||||
rlRun -s "setcap -q - mydir/file3 < input"
|
||||
rlAssertNotGrep "Please enter caps for file" $rlRun_LOG
|
||||
rlRun "getcap mydir/file3 | grep 'mydir/file3 = cap_net_raw+p'"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "remove capabilities"
|
||||
rlRun "setcap -r mydir/file3"
|
||||
rlRun "getcap | grep file3" 1 "There should be no capabilities listed for file1"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "listing capabilities recursively"
|
||||
rlRun -s "getcap -r *"
|
||||
rlAssertGrep "file1 = cap_net_admin+p" $rlRun_LOG
|
||||
rlAssertGrep "mydir/file2 = cap_net_raw+ei" $rlRun_LOG
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "listing capabilities verbosely"
|
||||
rlRun -s "getcap -v mydir/*"
|
||||
rlAssertGrep "mydir/file2 = cap_net_raw+ei" $rlRun_LOG
|
||||
rlAssertGrep "mydir/file3\$" $rlRun_LOG -E
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "print help"
|
||||
rlRun "setcap -h | grep 'usage: setcap'" 1
|
||||
rlRun "getcap -h | grep 'usage: getcap'" 1
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "exit with 1 on error"
|
||||
rlRun -s "setcap foo bar" 1
|
||||
rlAssertGrep "fatal error: Invalid argument" $rlRun_LOG
|
||||
rlRun -s "getcap -f oo" 1
|
||||
rlAssertGrep "getcap: invalid option -- 'f'" $rlRun_LOG
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
Loading…
Add table
Add a link
Reference in a new issue