Adding tests to the new_tests branch
This commit is contained in:
parent
95d0ea6880
commit
a6650f241c
5 changed files with 1137 additions and 0 deletions
77
tests/sanity/Makefile
Normal file
77
tests/sanity/Makefile
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
# Copyright (c) 2006 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 v.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.
|
||||||
|
#
|
||||||
|
# Author: Jakub Hrozek
|
||||||
|
|
||||||
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# Example Makefile for RHTS #
|
||||||
|
# This example is geared towards a test for a specific package #
|
||||||
|
# It does most of the work for you, but may require further coding #
|
||||||
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
# The toplevel namespace within which the test lives.
|
||||||
|
TOPLEVEL_NAMESPACE=CoreOS
|
||||||
|
|
||||||
|
# The name of the package under test:
|
||||||
|
PACKAGE_NAME=shadow-utils
|
||||||
|
|
||||||
|
# The path of the test below the package:
|
||||||
|
RELATIVE_PATH=sanity
|
||||||
|
|
||||||
|
# Version of the Test. Used with make tag.
|
||||||
|
export TESTVERSION=1.1
|
||||||
|
|
||||||
|
# The combined namespace of the test.
|
||||||
|
export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||||
|
|
||||||
|
# A phony target is one that is not really the name of a file.
|
||||||
|
# It is just a name for some commands to be executed when you
|
||||||
|
# make an explicit request. There are two reasons to use a
|
||||||
|
# phony target: to avoid a conflict with a file of the same
|
||||||
|
# name, and to improve performance.
|
||||||
|
.PHONY: all install download clean
|
||||||
|
|
||||||
|
# Executables to be built should be added here, they will be generated on the system under test.
|
||||||
|
BUILT_FILES=
|
||||||
|
|
||||||
|
# Data files, .c files, scripts anything needed to either compile the test and/or run it.
|
||||||
|
FILES=$(METADATA) Makefile PURPOSE sanity_test.py runtest.sh
|
||||||
|
|
||||||
|
run: $(FILES) build
|
||||||
|
./runtest.sh
|
||||||
|
|
||||||
|
build: $(BUILT_FILES)
|
||||||
|
chmod a+x ./sanity_test.py
|
||||||
|
chmod a+x ./runtest.sh
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *~ *.rpm $(BUILT_FILES)
|
||||||
|
|
||||||
|
# Include Common Makefile
|
||||||
|
include /usr/share/rhts/lib/rhts-make.include
|
||||||
|
|
||||||
|
# Generate the testinfo.desc here:
|
||||||
|
$(METADATA): Makefile
|
||||||
|
@touch $(METADATA)
|
||||||
|
@echo "Owner: Jakub Hrozek <jhrozek@redhat.com>" > $(METADATA)
|
||||||
|
@echo "Name: $(TEST)" >> $(METADATA)
|
||||||
|
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||||
|
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||||
|
@echo "License: GNU GPL" >> $(METADATA)
|
||||||
|
@echo "Description: Basic sanity test for shadow-utils" >> $(METADATA)
|
||||||
|
@echo "TestTime: 5m" >> $(METADATA)
|
||||||
|
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||||
|
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
|
||||||
|
@echo "Requires: python" >> $(METADATA)
|
||||||
|
rhts-lint $(METADATA)
|
||||||
|
|
10
tests/sanity/PURPOSE
Normal file
10
tests/sanity/PURPOSE
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
This is a basic sanity test for the shadow-utils package. It is implemented
|
||||||
|
in python on top of the unittesting.py module.
|
||||||
|
|
||||||
|
Its purpose is to ensure that the binaries in the shadow-utils package behave
|
||||||
|
as expected and its switches/options work correctly.
|
||||||
|
|
||||||
|
For the most part, every binary in the shadow-utils package is represented by
|
||||||
|
a single class named Test<BinaryName>, i.e. TestUsermod etc. There are some
|
||||||
|
exceptions, like TestUseraddWeirdNameTest though.
|
||||||
|
|
24
tests/sanity/runtest.sh
Executable file
24
tests/sanity/runtest.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
. /usr/bin/rhts-environment.sh
|
||||||
|
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||||
|
|
||||||
|
rlJournalStart
|
||||||
|
rlFileBackup --clean /etc/default/useradd- /etc/default/useradd
|
||||||
|
setenforce 0
|
||||||
|
python sanity_test.py -v
|
||||||
|
setenforce 1
|
||||||
|
rlFileRestore
|
||||||
|
|
||||||
|
EXIT=$?
|
||||||
|
if [[ $EXIT -eq 0 ]]; then
|
||||||
|
RESULT="PASS"
|
||||||
|
else
|
||||||
|
RESULT="FAIL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
rlJournalEnd
|
||||||
|
|
||||||
|
echo "Result: $RESULT"
|
||||||
|
echo "Exit: $EXIT"
|
||||||
|
report_result $TEST $RESULT $EXIT
|
1013
tests/sanity/sanity_test.py
Executable file
1013
tests/sanity/sanity_test.py
Executable file
File diff suppressed because it is too large
Load diff
13
tests/tests.yml
Normal file
13
tests/tests.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
# This first play always runs on the local staging system
|
||||||
|
- hosts: localhost
|
||||||
|
roles:
|
||||||
|
- role: standard-test-beakerlib
|
||||||
|
tags:
|
||||||
|
- classic
|
||||||
|
- atomic
|
||||||
|
tests:
|
||||||
|
- sanity
|
||||||
|
required_packages:
|
||||||
|
- shadow-utils # sanity test needs shadow-utils
|
||||||
|
- python # sanity test needs python
|
Loading…
Reference in a new issue