Add distrubution patches and self-tests

This commit is contained in:
Vladis Dronov 2022-04-11 20:37:00 +02:00
parent 6f2736b2af
commit 6d97c98d0f
4 changed files with 492 additions and 30 deletions

View File

@ -1,20 +1,18 @@
Summary: C source code tree search and browse tool Summary: C source code tree search and browse tool
Name: cscope Name: cscope
Version: 15.9 Version: 15.9
Release: 13%{?dist} Release: 14%{?dist}
Source0: https://downloads.sourceforge.net/project/%{name}/%{name}/v%{version}/%{name}-%{version}.tar.gz Source0: https://downloads.sourceforge.net/project/%{name}/%{name}/v%{version}/%{name}-%{version}.tar.gz
URL: http://cscope.sourceforge.net URL: http://cscope.sourceforge.net
License: BSD and GPLv2+ License: BSD and GPLv2+
BuildRequires: gcc BuildRequires: pkgconf-pkg-config ncurses-devel gcc flex bison m4
BuildRequires: pkgconfig ncurses-devel flex bison m4 BuildRequires: autoconf automake make
BuildRequires: autoconf automake Requires: emacs-filesystem coreutils ed
BuildRequires: make
Requires: emacs-filesystem coreutils
Requires: ed
%if !0%{?rhel} && 0%{?fedora} < 36 %if !0%{?rhel} && 0%{?fedora} < 36
Requires: xemacs-filesystem Requires: xemacs-filesystem
%endif %endif
# upstream commits from https://sourceforge.net/p/cscope/cscope/commit_browser
Patch1: cscope-1-modified-from-patch-81-Fix-reading-include-files-in-.patch Patch1: cscope-1-modified-from-patch-81-Fix-reading-include-files-in-.patch
Patch2: cscope-2-Cull-extraneous-declaration.patch Patch2: cscope-2-Cull-extraneous-declaration.patch
Patch3: cscope-3-Avoid-putting-directories-found-during-header-search.patch Patch3: cscope-3-Avoid-putting-directories-found-during-header-search.patch
@ -23,6 +21,10 @@ Patch5: cscope-5-contrib-ocs-Fix-bashims-Closes-480591.patch
Patch6: cscope-6-doc-cscope.1-Fix-hyphens.patch Patch6: cscope-6-doc-cscope.1-Fix-hyphens.patch
Patch7: cscope-7-fscanner-swallow-function-as-parameters.patch Patch7: cscope-7-fscanner-swallow-function-as-parameters.patch
Patch8: cscope-8-emacs-plugin-fixup-GNU-Emacs-27.1-removes-function-p.patch Patch8: cscope-8-emacs-plugin-fixup-GNU-Emacs-27.1-removes-function-p.patch
# distrubution patches which were not upstreamed
Patch9: dist-1-coverity-fixes.patch
Patch10: dist-2-cscope-indexer-help.patch
Patch11: dist-3-add-selftests.patch
%define cscope_share_path %{_datadir}/cscope %define cscope_share_path %{_datadir}/cscope
%if !0%{?rhel} && 0%{?fedora} < 36 %if !0%{?rhel} && 0%{?fedora} < 36
@ -33,34 +35,27 @@ Patch8: cscope-8-emacs-plugin-fixup-GNU-Emacs-27.1-removes-function-p.patch
%define emacs_lisp_path %{_datadir}/emacs/site-lisp %define emacs_lisp_path %{_datadir}/emacs/site-lisp
%define vim_plugin_path %{_datadir}/vim/vimfiles/plugin %define vim_plugin_path %{_datadir}/vim/vimfiles/plugin
%description %description
cscope is a mature, ncurses based, C source code tree browsing tool. It cscope is a mature, ncurses based, C source code tree browsing tool. It
allows users to search large source code bases for variables, functions, allows users to search large source code bases for variables, functions,
macros, etc, as well as perform general regex and plain text searches. macros, etc, as well as perform general regex and plain text searches.
Results are returned in lists, from which the user can select individual Results are returned in lists, from which the user can select individual
matches for use in file editing. matches for use in file editing.
%prep %prep
%setup -q %autosetup -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
autoreconf
%build %build
aclocal
autoheader
autoconf
automake --add-missing
%configure %configure
make make
%install %install
rm -rf $RPM_BUILD_ROOT %{name}-%{version}.files rm -rf $RPM_BUILD_ROOT %{name}-%{version}.files
make DESTDIR=$RPM_BUILD_ROOT install make DESTDIR=$RPM_BUILD_ROOT install
mkdir -p $RPM_BUILD_ROOT/var/lib/cs mkdir -p $RPM_BUILD_ROOT/var/lib/cs
mkdir -p $RPM_BUILD_ROOT%{cscope_share_path} mkdir -p $RPM_BUILD_ROOT%{cscope_share_path}
cp -a contrib/xcscope/xcscope.el $RPM_BUILD_ROOT%{cscope_share_path} cp -a contrib/xcscope/xcscope.el $RPM_BUILD_ROOT%{cscope_share_path}
@ -73,7 +68,8 @@ for dir in %{xemacs_lisp_path} %{emacs_lisp_path} ; do
echo "%ghost $dir/xcscope.el*" >> %{name}-%{version}.files echo "%ghost $dir/xcscope.el*" >> %{name}-%{version}.files
done done
%check
make check
%files -f %{name}-%{version}.files %files -f %{name}-%{version}.files
%{_bindir}/* %{_bindir}/*
@ -109,6 +105,10 @@ rm -f %{emacs_lisp_path}/xcscope.el
rm -f %{vim_plugin_path}/cctree.vim rm -f %{vim_plugin_path}/cctree.vim
%changelog %changelog
* Mon Apr 11 2022 Vladis Dronov <vdronov@redhat.com> - 15.9-14
- Add distrubution patches which were not upstreamed
- Add self-tests
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 15.9-13 * Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 15.9-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
@ -177,8 +177,7 @@ rm -f %{vim_plugin_path}/cctree.vim
* Wed Aug 05 2015 Neil Horman <nhorman@redhat.com> - 15.8b-1 * Wed Aug 05 2015 Neil Horman <nhorman@redhat.com> - 15.8b-1
- Update to latest upstream - Update to latest upstream
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - * Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 15.8-12
* 15.8-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Tue Sep 30 2014 Neil Horman <nhorman@redhat.com> - 15.8-11 * Tue Sep 30 2014 Neil Horman <nhorman@redhat.com> - 15.8-11
@ -248,7 +247,7 @@ rm -f %{vim_plugin_path}/cctree.vim
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 15.6-5 * Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 15.6-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Fri Jun 12 2009 Neil Horman <nhorman@redhat.com> * Fri Jun 12 2009 Neil Horman <nhorman@redhat.com> - 15.6-4
- Fix some buffer overflows (bz 505605) - Fix some buffer overflows (bz 505605)
* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 15.6-3 * Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 15.6-3
@ -314,7 +313,7 @@ rm -f %{vim_plugin_path}/cctree.vim
* Tue Sep 28 2004 Neil Horman <nhorman@redhat.com> * Tue Sep 28 2004 Neil Horman <nhorman@redhat.com>
- fixed inverted index bug (bz 133942) - fixed inverted index bug (bz 133942)
* Mon Sep 13 2004 Frank Ch. Eigler <fche@redhat.com> * Mon Sep 13 2004 Frank Ch. Eigler <fche@redhat.com>
- bumped release number to a plain "1" - bumped release number to a plain "1"
@ -328,7 +327,7 @@ rm -f %{vim_plugin_path}/cctree.vim
- Added upstream ocs fix - Added upstream ocs fix
- Added feature to find symbol assignments - Added feature to find symbol assignments
- Changed default SYSDIR directory to /var/lib/cs - Changed default SYSDIR directory to /var/lib/cs
- Incoproated M. Schwendt's fix for ocs -s - Incoproated M. Schwendt's fix for ocs -s
* Fri Jun 18 2004 Neil Horman <nhorman@redhat.com> * Fri Jun 18 2004 Neil Horman <nhorman@redhat.com>
- built the package - built the package

View File

@ -0,0 +1,26 @@
diff -up ./src/egrep.c.coverity2 ./src/egrep.c
--- ./src/egrep.c.coverity2 2018-10-11 15:22:40.481384312 -0400
+++ ./src/egrep.c 2018-10-11 15:23:31.152211589 -0400
@@ -1205,6 +1205,7 @@ yyparse (void)
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
+ /* coverity[leaked_storage] */
}
# endif
#endif /* no yyoverflow */
diff -up ./src/logdir.c.coverity2 ./src/logdir.c
--- ./src/logdir.c.coverity2 2018-10-11 15:23:50.009147309 -0400
+++ ./src/logdir.c 2018-10-11 15:24:26.279023664 -0400
@@ -79,8 +79,10 @@ logdir(char *name)
if (line[j] == '\n')
break;
/* return a null pointer if the whole file has been read */
- if (j >= i)
+ if (j >= i) {
+ (void) close(pwf);
return(0);
+ }
line[++j] = 0; /* terminate the line */
(void) lseek(pwf, (long) (j - i), 1); /* point at the next line */
p = nextfield(line); /* get the logname */

View File

@ -0,0 +1,52 @@
diff -up ./contrib/xcscope/cscope-indexer.help ./contrib/xcscope/cscope-indexer
--- ./contrib/xcscope/cscope-indexer.help 2017-12-07 10:45:07.000000000 -0500
+++ ./contrib/xcscope/cscope-indexer 2019-06-24 15:46:31.484852474 -0400
@@ -80,6 +80,37 @@ RECURSE=
VERBOSE=
export DIR RECURSE # Need to pass these to subprocesses
+show_usage() {
+
+cat << EOF
+
+ cscope-indexer [ -v ] [-f database_file ] [-i list_file ] [ -l ] [ -r ]
+
+ where:
+
+ -f database_file
+ Specifies the cscope database file (default: cscope.out).
+
+ -i list_file
+ Specifies the name of the file into which the list of files
+ to index is placed (default: cscope.files).
+
+ -l
+ Suppress the generation/updating of the cscope database
+ file. Only a list of files is generated.
+
+ -r
+ Recurse into subdirectories to locate files to index.
+ Without this option, only the current directory is
+ searched.
+
+ -v
+ Be verbose. Output simple progress messages.
+
+EOF
+
+}
+
while [ -n "$1" ]
do
case "$1" in
@@ -110,6 +141,10 @@ do
-v)
VERBOSE=1
;;
+ -h|--help)
+ show_usage
+ exit 0
+ ;;
*)
DIR="$1"
;;

385
dist-3-add-selftests.patch Normal file
View File

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