From 97e290cf39c0c5bb5bbf697d6ab8fb2aab73da40 Mon Sep 17 00:00:00 2001 From: karltk Date: Sat, 9 Oct 2004 22:18:13 +0000 Subject: [PATCH] More tests svn path=/; revision=147 --- trunk/src/equery/tests/common-functions.sh | 9 +++++ trunk/src/equery/tests/test-belongs.sh | 24 +++++++++++++ trunk/src/equery/tests/test-check.sh | 27 +++++++++++++++ trunk/src/equery/tests/test-depends.sh | 27 +++++++++++++++ trunk/src/equery/tests/test-depgraph.sh | 27 +++++++++++++++ trunk/src/equery/tests/test-list.sh | 39 ++++++++++++++++++++++ trunk/src/equery/tests/test-size.sh | 27 +++++++++++++++ trunk/src/equery/tests/test-uses.sh | 39 ++++++++++++++++++++++ trunk/src/equery/tests/test-which.sh | 22 ++++++++++++ 9 files changed, 241 insertions(+) create mode 100755 trunk/src/equery/tests/test-belongs.sh create mode 100755 trunk/src/equery/tests/test-check.sh create mode 100755 trunk/src/equery/tests/test-depends.sh create mode 100755 trunk/src/equery/tests/test-depgraph.sh create mode 100755 trunk/src/equery/tests/test-list.sh create mode 100755 trunk/src/equery/tests/test-size.sh create mode 100755 trunk/src/equery/tests/test-uses.sh create mode 100755 trunk/src/equery/tests/test-which.sh diff --git a/trunk/src/equery/tests/common-functions.sh b/trunk/src/equery/tests/common-functions.sh index 125517f..f065a0a 100644 --- a/trunk/src/equery/tests/common-functions.sh +++ b/trunk/src/equery/tests/common-functions.sh @@ -40,4 +40,13 @@ function assert_ge() { printf "FAIL: $2 ! -ge $3\n" report_failure $1 fi +} + +function assert_exists() { + if [ -f $2 ] ; then + report_pass $1 + else + printf "FAIL: $2 does not exist\n" + report_failure $1 + fi } \ No newline at end of file diff --git a/trunk/src/equery/tests/test-belongs.sh b/trunk/src/equery/tests/test-belongs.sh new file mode 100755 index 0000000..bd0eac4 --- /dev/null +++ b/trunk/src/equery/tests/test-belongs.sh @@ -0,0 +1,24 @@ +#! /bin/bash +# +# Copyright (c) 2004, Karl Trygve Kalleberg +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +. common-functions.sh + +tmpfile=$(tempfilename) + +test_belongs() { + equery belongs $(which gcc) > ${tmpfile} + + x=$(grep "gcc-config" ${tmpfile} | wc -l) + + assert_eq ${FUNCNAME} ${x} 1 +} + +# Run tests + +test_belongs + +rm -f ${tmpfile} \ No newline at end of file diff --git a/trunk/src/equery/tests/test-check.sh b/trunk/src/equery/tests/test-check.sh new file mode 100755 index 0000000..3608ce4 --- /dev/null +++ b/trunk/src/equery/tests/test-check.sh @@ -0,0 +1,27 @@ +#! /bin/bash +# +# Copyright (c) 2004, Karl Trygve Kalleberg +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +. common-functions.sh + +tmpfile=$(tempfilename) + +test_check() { + equery check gcc > ${tmpfile} + + x=$(grep "sys-devel/gcc" ${tmpfile} | wc -l) + + assert_ge ${FUNCNAME} ${x} 1 + + x=$(egrep "[0-9]+ out of [0-9]+" ${tmpfile} | wc -l) + assert_ge ${FUNCNAME} ${x} 1 +} + +# Run tests + +test_check + +rm -f ${tmpfile} \ No newline at end of file diff --git a/trunk/src/equery/tests/test-depends.sh b/trunk/src/equery/tests/test-depends.sh new file mode 100755 index 0000000..a70dcfc --- /dev/null +++ b/trunk/src/equery/tests/test-depends.sh @@ -0,0 +1,27 @@ +#! /bin/bash +# +# Copyright (c) 2004, Karl Trygve Kalleberg +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +. common-functions.sh + +tmpfile=$(tempfilename) + +test_depends() { +# equery skel gcc > ${tmpfile} + +# x=$(grep "app-shells/bash" ${tmpfile} | wc -l) + +# assert_eq ${FUNCNAME} ${x} 1 + +# x=$(grep "virtual/libc" ${tmpfile} | wc -l) +# assert_eq ${FUNCNAME} ${x} 1 +} + +# Run tests + +#test_skel + +rm -f ${tmpfile} \ No newline at end of file diff --git a/trunk/src/equery/tests/test-depgraph.sh b/trunk/src/equery/tests/test-depgraph.sh new file mode 100755 index 0000000..016bb37 --- /dev/null +++ b/trunk/src/equery/tests/test-depgraph.sh @@ -0,0 +1,27 @@ +#! /bin/bash +# +# Copyright (c) 2004, Karl Trygve Kalleberg +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +. common-functions.sh + +tmpfile=$(tempfilename) + +test_depgraph() { + equery depgraph gcc > ${tmpfile} + + x=$(grep "app-shells/bash" ${tmpfile} | wc -l) + + assert_eq ${FUNCNAME} ${x} 1 + + x=$(grep "virtual/libc" ${tmpfile} | wc -l) + assert_eq ${FUNCNAME} ${x} 1 +} + +# Run tests + +test_depgraph + +rm -f ${tmpfile} \ No newline at end of file diff --git a/trunk/src/equery/tests/test-list.sh b/trunk/src/equery/tests/test-list.sh new file mode 100755 index 0000000..fae5426 --- /dev/null +++ b/trunk/src/equery/tests/test-list.sh @@ -0,0 +1,39 @@ +#! /bin/bash +# +# Copyright (c) 2004, Karl Trygve Kalleberg +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +. common-functions.sh + +tmpfile=$(tempfilename) + +test_list() { + equery list > ${tmpfile} + + pkgs=$(cat ${tmpfile} | wc -l) + x=$(grep "[I--]" ${tmpfile} | wc -l) + assert_eq ${FUNCNAME} ${pkgs} ${x] + + x=$(grep "app-shells/bash" | wc -l) + assert_ge ${FUNCNAME} $x 1 +} + +test_list_installed() { + test_list +} + +test_list_portage_tree() { + equery list -I -p > ${tmpfile} +} + +test_list_overlay_tree() { + equery list -I -o > ${tmpfile} +} + +# Run tests + +test_list + +rm -f ${tmpfile} \ No newline at end of file diff --git a/trunk/src/equery/tests/test-size.sh b/trunk/src/equery/tests/test-size.sh new file mode 100755 index 0000000..126a5db --- /dev/null +++ b/trunk/src/equery/tests/test-size.sh @@ -0,0 +1,27 @@ +#! /bin/bash +# +# Copyright (c) 2004, Karl Trygve Kalleberg +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +. common-functions.sh + +tmpfile=$(tempfilename) + +test_size() { + equery size gcc > ${tmpfile} + + x=$(grep "sys-devel/gcc" ${tmpfile} | wc -l) + + assert_ge ${FUNCNAME} ${x} 1 + + x=$(egrep "size\([0-9]+\)" ${tmpfile} | wc -l) + assert_ge ${FUNCNAME} ${x} 1 +} + +# Run tests + +test_size + +rm -f ${tmpfile} \ No newline at end of file diff --git a/trunk/src/equery/tests/test-uses.sh b/trunk/src/equery/tests/test-uses.sh new file mode 100755 index 0000000..f03e786 --- /dev/null +++ b/trunk/src/equery/tests/test-uses.sh @@ -0,0 +1,39 @@ +#! /bin/bash +# +# Copyright (c) 2004, Karl Trygve Kalleberg +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +. common-functions.sh + +tmpfile=$(tempfilename) + +test_uses() { + equery uses gcc > ${tmpfile} + + x=$(grep "static" ${tmpfile} | wc -l) + + assert_eq ${FUNCNAME} ${x} 1 + + x=$(cat ${tmpfile} | wc -l) + assert_ge ${FUNCNAME} $x 7 +} + +test_uses_all() { + equery uses -a uclibc > ${tmpfile} + + x=$(grep "static" ${tmpfile} | wc -l) + assert_eq ${FUNCNAME} ${pkgs} ${x] + + x=$(cat ${tmpfile} | wc -l) + assert_ge ${FUNCNAME} $x 5 + +} + +# Run tests + +test_uses +test_uses_all + +rm -f ${tmpfile} \ No newline at end of file diff --git a/trunk/src/equery/tests/test-which.sh b/trunk/src/equery/tests/test-which.sh new file mode 100755 index 0000000..491868f --- /dev/null +++ b/trunk/src/equery/tests/test-which.sh @@ -0,0 +1,22 @@ +#! /bin/bash +# +# Copyright (c) 2004, Karl Trygve Kalleberg +# Copyright (c) 2004, Gentoo Foundation +# +# Licensed under the GNU General Public License, v2 + +. common-functions.sh + +tmpfile=$(tempfilename) + +test_which() { + file=$(equery which gcc) + + assert_exists ${FUNCNAME} ${file} +} + +# Run tests + +test_which + +rm -f ${tmpfile} \ No newline at end of file -- 2.26.2