Blame SOURCES/dist-3-add-selftests.patch

f87e68
commit efc92106173b5130e32587f6c788f19f2477051d
f87e68
Author: Neil Horman <nhorman@tuxdriver.com>
f87e68
Date:   Fri Jul 27 15:52:49 2018 -0400
f87e68
f87e68
    Add make check test harness
f87e68
    
f87e68
    Start adding tests to self test cscope in travis ci
f87e68
    
f87e68
    Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
f87e68
f87e68
diff --git a/Makefile.am b/Makefile.am
f87e68
index ae0fc53..d79d44e 100644
f87e68
--- a/Makefile.am
f87e68
+++ b/Makefile.am
f87e68
@@ -1,6 +1,6 @@
f87e68
 ## Process this file with automake to produce Makefile.in
f87e68
 
f87e68
-SUBDIRS = doc src contrib
f87e68
+SUBDIRS = doc src contrib tests
f87e68
 
f87e68
 EXTRA_DIST = INSTALL.gnu packages
f87e68
 
f87e68
diff --git a/configure.in b/configure.in
f87e68
index c51887d..e0a8b1f 100644
f87e68
--- a/configure.in
f87e68
+++ b/configure.in
f87e68
@@ -415,5 +415,5 @@ case "$host_os" in
f87e68
 	;;
f87e68
 esac
f87e68
 
f87e68
-AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile contrib/Makefile])
f87e68
+AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile contrib/Makefile tests/Makefile])
f87e68
 AC_OUTPUT
f87e68
diff --git a/tests/Makefile.am b/tests/Makefile.am
f87e68
new file mode 100644
f87e68
index 0000000..2278a71
f87e68
--- /dev/null
f87e68
+++ b/tests/Makefile.am
f87e68
@@ -0,0 +1,7 @@
f87e68
+check_SCRIPTS = check0.sh check1.sh check2.sh \
f87e68
+		check3.sh check4.sh check6.sh \
f87e68
+		check7.sh check8.sh check9.sh
f87e68
+
f87e68
+TESTS = check0.sh check1.sh check2.sh \
f87e68
+	check3.sh check4.sh check6.sh \
f87e68
+	check7.sh check8.sh check9.sh
f87e68
diff --git a/tests/check0.sh b/tests/check0.sh
f87e68
new file mode 100755
f87e68
index 0000000..6c6883b
f87e68
--- /dev/null
f87e68
+++ b/tests/check0.sh
f87e68
@@ -0,0 +1,32 @@
f87e68
+#!/bin/sh
f87e68
+
f87e68
+EXPECT=4
f87e68
+SINDEX=0
f87e68
+STERM=main
f87e68
+STYPE="find C symbol"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+	CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+#Count the number of instances of the string 'Copyright'
f87e68
+#We expect 178 currently
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
diff --git a/tests/check1.sh b/tests/check1.sh
f87e68
new file mode 100755
f87e68
index 0000000..78ffe21
f87e68
--- /dev/null
f87e68
+++ b/tests/check1.sh
f87e68
@@ -0,0 +1,32 @@
f87e68
+#!/bin/sh
f87e68
+
f87e68
+EXPECT=3
f87e68
+SINDEX=1
f87e68
+STERM=main
f87e68
+STYPE="symbol definition"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+        CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+#Count the number of instances of the string 'Copyright'
f87e68
+#We expect 178 currently
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
diff --git a/tests/check2.sh b/tests/check2.sh
f87e68
new file mode 100755
f87e68
index 0000000..414430a
f87e68
--- /dev/null
f87e68
+++ b/tests/check2.sh
f87e68
@@ -0,0 +1,30 @@
f87e68
+#!/bin/sh
f87e68
+
f87e68
+EXPECT=96
f87e68
+SINDEX=2
f87e68
+STERM=build
f87e68
+STYPE="functions called by"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+        CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
diff --git a/tests/check3.sh b/tests/check3.sh
f87e68
new file mode 100755
f87e68
index 0000000..a6b2c7e
f87e68
--- /dev/null
f87e68
+++ b/tests/check3.sh
f87e68
@@ -0,0 +1,31 @@
f87e68
+#!/bin/sh
f87e68
+
f87e68
+EXPECT=35
f87e68
+SINDEX=3
f87e68
+STERM=printf
f87e68
+STYPE="functions calling"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+        CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+#We expect 178 currently
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
diff --git a/tests/check4.sh b/tests/check4.sh
f87e68
new file mode 100755
f87e68
index 0000000..dd2c98c
f87e68
--- /dev/null
f87e68
+++ b/tests/check4.sh
f87e68
@@ -0,0 +1,29 @@
f87e68
+#!/bin/sh
f87e68
+EXPECT=3
f87e68
+SINDEX=4
f87e68
+STERM=oldsigquit
f87e68
+STYPE="regular text string"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+        CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
diff --git a/tests/check6.sh b/tests/check6.sh
f87e68
new file mode 100755
f87e68
index 0000000..c664960
f87e68
--- /dev/null
f87e68
+++ b/tests/check6.sh
f87e68
@@ -0,0 +1,32 @@
f87e68
+#!/bin/sh
f87e68
+
f87e68
+EXPECT=1
f87e68
+SINDEX=6
f87e68
+STERM=msg.*what
f87e68
+STYPE="egrep string"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+        CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+#Count the number of instances of the string 'Copyright'
f87e68
+#We expect 178 currently
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
diff --git a/tests/check7.sh b/tests/check7.sh
f87e68
new file mode 100755
f87e68
index 0000000..5ac965c
f87e68
--- /dev/null
f87e68
+++ b/tests/check7.sh
f87e68
@@ -0,0 +1,32 @@
f87e68
+#!/bin/sh
f87e68
+
f87e68
+EXPECT=1
f87e68
+SINDEX=7
f87e68
+STERM=main.c
f87e68
+STYPE="file named"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+        CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+#Count the number of instances of the string 'Copyright'
f87e68
+#We expect 178 currently
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
diff --git a/tests/check8.sh b/tests/check8.sh
f87e68
new file mode 100755
f87e68
index 0000000..72cb946
f87e68
--- /dev/null
f87e68
+++ b/tests/check8.sh
f87e68
@@ -0,0 +1,32 @@
f87e68
+#!/bin/sh
f87e68
+
f87e68
+EXPECT=8
f87e68
+SINDEX=8
f87e68
+STERM=unistd.h
f87e68
+STYPE="files including this file"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+        CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+#Count the number of instances of the string 'Copyright'
f87e68
+#We expect 178 currently
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
diff --git a/tests/check9.sh b/tests/check9.sh
f87e68
new file mode 100755
f87e68
index 0000000..a728a32
f87e68
--- /dev/null
f87e68
+++ b/tests/check9.sh
f87e68
@@ -0,0 +1,32 @@
f87e68
+#!/bin/sh
f87e68
+
f87e68
+EXPECT=2
f87e68
+SINDEX=9
f87e68
+STERM=reftime
f87e68
+STYPE="assignments to symbol"
f87e68
+
f87e68
+if [ -z "$CSCOPE_BINARY" ]
f87e68
+then
f87e68
+        CSCOPE_BINARY=./src/cscope
f87e68
+fi
f87e68
+
f87e68
+echo "Searching item $SINDEX, '$STYPE', '$STERM'"
f87e68
+
f87e68
+#Get to the top level directory
f87e68
+cd ..
f87e68
+
f87e68
+#Remove any previous databases from testing
f87e68
+rm -f cscope.out
f87e68
+
f87e68
+#Count the number of instances of the string 'Copyright'
f87e68
+#We expect 178 currently
f87e68
+COUNT=$($CSCOPE_BINARY -R -L -k -$SINDEX$STERM | wc -l)
f87e68
+
f87e68
+if [ $COUNT -ne $EXPECT ]
f87e68
+then
f87e68
+	echo "Expected $EXPECT instances of $STYPE $STERM but found $COUNT"
f87e68
+	exit 1
f87e68
+fi
f87e68
+
f87e68
+exit 0
f87e68
+
f87e68
-- 
f87e68
2.35.1
f87e68