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

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