From ab0d495421a1c97dea524da72b50df82cfcb874a Mon Sep 17 00:00:00 2001 From: Jakub Martisko Date: Fri, 30 Jul 2021 13:43:27 +0200 Subject: [PATCH] Add gating tests Resolves: rhbz#1986357 --- tests/gating/all.sh | 21 +++++++++++++++++++++ tests/gating/gunzip/test.sh | 10 ++++++++++ tests/gating/gzexe/test.sh | 17 +++++++++++++++++ tests/gating/gzip/test.sh | 8 ++++++++ tests/gating/zcat/test.sh | 14 ++++++++++++++ tests/gating/zcmp/test.sh | 9 +++++++++ tests/gating/zdiff/test.sh | 9 +++++++++ tests/gating/zegrep/test.sh | 9 +++++++++ tests/gating/zfgrep/test.sh | 9 +++++++++ tests/gating/zforce/test.sh | 10 ++++++++++ tests/gating/zgrep/test.sh | 9 +++++++++ tests/gating/zless/test.sh | 4 ++++ tests/gating/zmore/test.sh | 4 ++++ tests/gating/znew/test.sh | 4 ++++ tests/sanity.yml | 15 +++++++++++++++ tests/test_simple.yml | 18 +++++++++--------- tests/tests.yml | 4 +++- 17 files changed, 164 insertions(+), 10 deletions(-) create mode 100755 tests/gating/all.sh create mode 100755 tests/gating/gunzip/test.sh create mode 100755 tests/gating/gzexe/test.sh create mode 100755 tests/gating/gzip/test.sh create mode 100755 tests/gating/zcat/test.sh create mode 100755 tests/gating/zcmp/test.sh create mode 100755 tests/gating/zdiff/test.sh create mode 100755 tests/gating/zegrep/test.sh create mode 100755 tests/gating/zfgrep/test.sh create mode 100755 tests/gating/zforce/test.sh create mode 100755 tests/gating/zgrep/test.sh create mode 100755 tests/gating/zless/test.sh create mode 100755 tests/gating/zmore/test.sh create mode 100755 tests/gating/znew/test.sh create mode 100644 tests/sanity.yml diff --git a/tests/gating/all.sh b/tests/gating/all.sh new file mode 100755 index 0000000..07fb296 --- /dev/null +++ b/tests/gating/all.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +passed=0 +subtests=(./gzip ./gunzip ./gzexe ./zcat ./zcmp ./zdiff ./zegrep ./zfgrep ./zforce ./zgrep ./zless ./zmore ./znew) +total=${#subtests[@]} + +for subtest in ${subtests[@]} +do + pushd $subtest >/dev/null + ./test.sh + result=$? + echo "Test $subtest result: $result" + if [ "$result" == "0" ] + then + ((passed++)) + fi + popd >/dev/null +done + +echo "Passed $passed/$total tests" +[[ $total == $passed ]] || exit 1 diff --git a/tests/gating/gunzip/test.sh b/tests/gating/gunzip/test.sh new file mode 100755 index 0000000..cb1bd73 --- /dev/null +++ b/tests/gating/gunzip/test.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Hello World!" > ./in +gzip -f -k ./in +gunzip -c ./in.gz > ./out +diff ./in ./out +result=$? +rm -f *.gz ./out ./in +exit $result + diff --git a/tests/gating/gzexe/test.sh b/tests/gating/gzexe/test.sh new file mode 100755 index 0000000..f52cda1 --- /dev/null +++ b/tests/gating/gzexe/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + + +cat <./in +#!/bin/bash +echo "Hello World!" +EOF +chmod +x ./in +./in >./expected + +gzexe ./in 2>/dev/null +/bin/bash ./in >./out +diff ./out ./expected +result=$? +rm -f ./in ./in~ ./out ./expected +exit $result + diff --git a/tests/gating/gzip/test.sh b/tests/gating/gzip/test.sh new file mode 100755 index 0000000..17b1885 --- /dev/null +++ b/tests/gating/gzip/test.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "Hello World!" > ./in +gzip -f -c ./in >/dev/null +result=$? +rm -f ./in *.gz +exit $result + diff --git a/tests/gating/zcat/test.sh b/tests/gating/zcat/test.sh new file mode 100755 index 0000000..a4c8ef9 --- /dev/null +++ b/tests/gating/zcat/test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Hello" > ./in +echo "World!" > ./in2 +echo "Hello" > ./exp +echo "World!" >> ./exp +gzip -f -k ./in +gzip -f -k ./in2 +zcat ./in.gz ./in2.gz >out +diff ./exp ./out +result=$? +rm -f ./in ./in2 *.gz ./out ./exp +exit $result + diff --git a/tests/gating/zcmp/test.sh b/tests/gating/zcmp/test.sh new file mode 100755 index 0000000..1c694e5 --- /dev/null +++ b/tests/gating/zcmp/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Hello World!" > ./in +gzip -f -k ./in +zcmp ./in ./in.gz +result=$? +rm -f *.gz ./out ./in +exit $result + diff --git a/tests/gating/zdiff/test.sh b/tests/gating/zdiff/test.sh new file mode 100755 index 0000000..84d3f20 --- /dev/null +++ b/tests/gating/zdiff/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Hello World!" > ./in +gzip -f -k ./in +zdiff ./in ./in.gz +result=$? +rm -f *.gz ./out ./in +exit $result + diff --git a/tests/gating/zegrep/test.sh b/tests/gating/zegrep/test.sh new file mode 100755 index 0000000..d695585 --- /dev/null +++ b/tests/gating/zegrep/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Hello World!" > ./in +gzip -f -k ./in +zegrep "ello" ./in.gz >/dev/null +result=$? +rm -f *.gz ./out ./in +exit $result + diff --git a/tests/gating/zfgrep/test.sh b/tests/gating/zfgrep/test.sh new file mode 100755 index 0000000..35b9073 --- /dev/null +++ b/tests/gating/zfgrep/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Hello World!" > ./in +gzip -f -k ./in +zfgrep "ello" ./in.gz >/dev/null +result=$? +rm -f *.gz ./out ./in +exit $result + diff --git a/tests/gating/zforce/test.sh b/tests/gating/zforce/test.sh new file mode 100755 index 0000000..ce79e25 --- /dev/null +++ b/tests/gating/zforce/test.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Hello World!" > ./in +gzip -f -c ./in > ./out +zforce ./out > /dev/null +ls ./out.gz >/dev/null +result=$? +rm -f ./in *.gz +exit $result + diff --git a/tests/gating/zgrep/test.sh b/tests/gating/zgrep/test.sh new file mode 100755 index 0000000..e74c6bc --- /dev/null +++ b/tests/gating/zgrep/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Hello World!" > ./in +gzip -f -k ./in +zgrep "ello" ./in.gz >/dev/null +result=$? +rm -f *.gz ./out ./in +exit $result + diff --git a/tests/gating/zless/test.sh b/tests/gating/zless/test.sh new file mode 100755 index 0000000..c72f95e --- /dev/null +++ b/tests/gating/zless/test.sh @@ -0,0 +1,4 @@ +#!/bin/bash +zless --help >/dev/null +result=$? +exit $result diff --git a/tests/gating/zmore/test.sh b/tests/gating/zmore/test.sh new file mode 100755 index 0000000..8cafdce --- /dev/null +++ b/tests/gating/zmore/test.sh @@ -0,0 +1,4 @@ +#!/bin/bash +zmore --help >/dev/null +result=$? +exit $result diff --git a/tests/gating/znew/test.sh b/tests/gating/znew/test.sh new file mode 100755 index 0000000..8c81298 --- /dev/null +++ b/tests/gating/znew/test.sh @@ -0,0 +1,4 @@ +#!/bin/bash +znew --help >/dev/null +result=$? +exit $result diff --git a/tests/sanity.yml b/tests/sanity.yml new file mode 100644 index 0000000..da0d623 --- /dev/null +++ b/tests/sanity.yml @@ -0,0 +1,15 @@ +--- +- hosts: localhost + vars: + - artifacts: ./artifacts + remote_user: root + roles: + - role: standard-test-basic + tags: + - atomic + - classic + - container + tests: + - simple: + dir: gating + run: ./all.sh diff --git a/tests/test_simple.yml b/tests/test_simple.yml index 37fdd70..9f7d0df 100644 --- a/tests/test_simple.yml +++ b/tests/test_simple.yml @@ -20,13 +20,13 @@ with_items: - {file: test-simple, dest: test-simple } - - block: - - name: Execute the tests - shell: exec > /tmp/test.log && /usr/local/bin/test-simple 2>&1 + - name: Execute the tests + block: + - shell: exec > /tmp/test.log && /usr/local/bin/test-simple 2>&1 - - always: - - name: Pull out the logs - fetch: - dest: "{{ artifacts }}/" - src: "/tmp/test.log" - flat: yes + always: + - name: Pull out the logs + fetch: + dest: "{{ artifacts }}/" + src: "/tmp/test.log" + flat: true diff --git a/tests/tests.yml b/tests/tests.yml index 8a6aab3..b057848 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -1 +1,3 @@ -- include: test_simple.yml +--- +- import_playbook: test_simple.yml +- import_playbook: sanity.yml