More tests
authorkarltk <karltk@gentoo.org>
Sat, 9 Oct 2004 22:18:13 +0000 (22:18 -0000)
committerkarltk <karltk@gentoo.org>
Sat, 9 Oct 2004 22:18:13 +0000 (22:18 -0000)
svn path=/; revision=147

trunk/src/equery/tests/common-functions.sh
trunk/src/equery/tests/test-belongs.sh [new file with mode: 0755]
trunk/src/equery/tests/test-check.sh [new file with mode: 0755]
trunk/src/equery/tests/test-depends.sh [new file with mode: 0755]
trunk/src/equery/tests/test-depgraph.sh [new file with mode: 0755]
trunk/src/equery/tests/test-list.sh [new file with mode: 0755]
trunk/src/equery/tests/test-size.sh [new file with mode: 0755]
trunk/src/equery/tests/test-uses.sh [new file with mode: 0755]
trunk/src/equery/tests/test-which.sh [new file with mode: 0755]

index 125517f72919c3617b70ff35c2eab6b282be4643..f065a0a3029b805b8b4b472ebb632414f03d9125 100644 (file)
@@ -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 (executable)
index 0000000..bd0eac4
--- /dev/null
@@ -0,0 +1,24 @@
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# 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 (executable)
index 0000000..3608ce4
--- /dev/null
@@ -0,0 +1,27 @@
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# 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 (executable)
index 0000000..a70dcfc
--- /dev/null
@@ -0,0 +1,27 @@
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# 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 (executable)
index 0000000..016bb37
--- /dev/null
@@ -0,0 +1,27 @@
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# 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 (executable)
index 0000000..fae5426
--- /dev/null
@@ -0,0 +1,39 @@
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# 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 (executable)
index 0000000..126a5db
--- /dev/null
@@ -0,0 +1,27 @@
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# 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 (executable)
index 0000000..f03e786
--- /dev/null
@@ -0,0 +1,39 @@
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# 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 (executable)
index 0000000..491868f
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/bash
+#
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# 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