From 902f597125c32df1f12fe7049975ff0edb32860e Mon Sep 17 00:00:00 2001 From: Ondrej Mejzlik Date: Thu, 20 Jun 2024 19:15:34 +0200 Subject: [PATCH] add test --- Sanity/smoke-test/Makefile | 64 ++++++++++++++++++++++ Sanity/smoke-test/PURPOSE | 3 + Sanity/smoke-test/main.fmf | 28 ++++++++++ Sanity/smoke-test/runtest.sh | 51 +++++++++++++++++ Sanity/smoke-test/tests.sh | 103 +++++++++++++++++++++++++++++++++++ 5 files changed, 249 insertions(+) create mode 100644 Sanity/smoke-test/Makefile create mode 100644 Sanity/smoke-test/PURPOSE create mode 100644 Sanity/smoke-test/main.fmf create mode 100755 Sanity/smoke-test/runtest.sh create mode 100755 Sanity/smoke-test/tests.sh diff --git a/Sanity/smoke-test/Makefile b/Sanity/smoke-test/Makefile new file mode 100644 index 0000000..491118e --- /dev/null +++ b/Sanity/smoke-test/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/tinycdb/Sanity/smoke-test +# Description: smoke test +# Author: Jaroslav Škarvada +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 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/tinycdb/Sanity/smoke-test +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE tests.sh + +.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: Jaroslav Škarvada " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: smoke test" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: tinycdb" >> $(METADATA) + @echo "Requires: tinycdb diffutils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: yes" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/Sanity/smoke-test/PURPOSE b/Sanity/smoke-test/PURPOSE new file mode 100644 index 0000000..23266cb --- /dev/null +++ b/Sanity/smoke-test/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/tinycdb/Sanity/smoke-test +Description: smoke test +Author: Jaroslav Škarvada diff --git a/Sanity/smoke-test/main.fmf b/Sanity/smoke-test/main.fmf new file mode 100644 index 0000000..a9e3da6 --- /dev/null +++ b/Sanity/smoke-test/main.fmf @@ -0,0 +1,28 @@ +summary: smoke test +description: '' +contact: Petr Sklenar +component: + - tinycdb +test: ./runtest.sh +framework: beakerlib +recommend: + - tinycdb + - diffutils +duration: 5m +enabled: true +tag: + - NoRHEL4 + - NoRHEL5 + - TIPfail + - Tier1 + - rhel-buildroot + - rhel8-buildroot + - rhel8-crb +tier: '1' +adjust: + - enabled: false + when: distro == rhel-4, rhel-5, rhel-6, rhel-7 + continue: false +extra-nitrate: TC#0598800 +extra-summary: /CoreOS/tinycdb/Sanity/smoke-test +extra-task: /CoreOS/tinycdb/Sanity/smoke-test diff --git a/Sanity/smoke-test/runtest.sh b/Sanity/smoke-test/runtest.sh new file mode 100755 index 0000000..81874cd --- /dev/null +++ b/Sanity/smoke-test/runtest.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/tinycdb/Sanity/smoke-test +# Description: smoke test +# Author: Jaroslav Škarvada +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 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/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="tinycdb" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp ./tests.sh $TmpDir/" 0 "Copying test suite" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "./tests.sh" 0 "Running modified upstream test suite" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/Sanity/smoke-test/tests.sh b/Sanity/smoke-test/tests.sh new file mode 100755 index 0000000..76d2e87 --- /dev/null +++ b/Sanity/smoke-test/tests.sh @@ -0,0 +1,103 @@ +#! /bin/sh + +# tests.sh: This script will run tests for cdb. +# Execute with ./tests.sh ./cdb +# (first arg if present gives path to cdb tool to use, default is `cdb'). +# +# This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru. +# Public domain. +# Slightly modified for automated testing by Jaroslav Škarvada + +case "$1" in + "") cdb=cdb ;; + *) cdb="$1" ;; +esac + +rm -f 1.cdb 1a.cdb + +echo Create simple db +echo "+3,4:one->here ++1,1:a->b ++1,3:b->abc ++3,4:one->also + +" | $cdb -c 1.cdb || exit 1 + +echo Dump simple db +$cdb -d 1.cdb || exit 2 + +echo Stats for simple db +$cdb -s 1.cdb || exit 3 + +echo "Query simple db (two records match)" +$cdb -q 1.cdb one || exit 4 +echo + +echo Query for non-existed key +$cdb -q 1.cdb none && exit 5 + +echo Doing 600 repeated records +( + for i in 0 1 2 3 4 5 ; do + for j in 0 1 2 3 4 5 6 7 8 9 ; do + for k in 0 1 2 3 4 5 6 7 8 9 ; do + echo "+1,3:a->$i$j$k" + done + done + done + echo "+1,5:b->other" + echo +) | $cdb -c 1.cdb || exit 6 + + +echo cdb stats should show 601 record +$cdb -s 1.cdb || exit 7 + +echo Querying key +$cdb -q 1.cdb b || exit 8 +echo + +echo Dumping and re-creating db +$cdb -d 1.cdb | $cdb -c 1a.cdb || exit 9 +cmp 1.cdb 1a.cdb || exit 10 + +$cdb -d -m 1.cdb | $cdb -c -m 1a.cdb || exit 11 +cmp 1.cdb 1a.cdb || exit 12 + +echo Handling large key size +echo "+123456789012,1:" | $cdb -c 1.cdb && exit 13 + +echo Handling large value size +echo "+1,123456789012:" | $cdb -c 1.cdb && exit 14 + +echo "Handling invalid input format (short file)" +echo "+10,10:" | $cdb -c 1.cdb && exit 15 + +echo Creating db with eol in key and value +echo "+2,2:a +->b + +" | $cdb -c 1.cdb || exit 16 + +echo Querying key-value with eol +$cdb -q 1.cdb "a +" || exit 17 + +echo Handling file size limits +( + ulimit -f 4 + trap '' 25 + ( + for i in 0 1 2 3 4 5 6 7 8 9 ; do + for j in 0 1 2 3 4 5 6 7 8 9 ; do + for k in 0 1 2 3 4 5 6 7 8 9 ; do + echo "+4,4:k$i$j$k->v$i$j$k" + done + done + done + echo + ) | $cdb -c 1.cdb || exit 18 +) + +rm -rf 1.cdb 1a.cdb 1.cdb.tmp +exit 0