packaging: Add testing infrastructure 33/229933/1
authorSlava Barinov <v.barinov@samsung.com>
Mon, 6 Apr 2020 12:01:32 +0000 (15:01 +0300)
committerSlava Barinov <v.barinov@samsung.com>
Mon, 6 Apr 2020 12:46:36 +0000 (15:46 +0300)
Now gdb could be tested by adding --define 'run_tests 1' just like the rest of
toolchain.

Change-Id: Ic398df605fe3da9bae748df6d0f61b325e5aa872
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
packaging/gdb.spec

index 7f1f69f14c58103476453314e86e6db2743134fe..de8b82c55ca37aab33adbc343218604e56c4f492 100644 (file)
@@ -1,3 +1,21 @@
+%if 0%{?run_tests}
+%define gdb_run_tests 1
+%endif
+
+# Enable this when testing on device to:
+# 1. Enable macro to turn on testsuite building ('gdb_run_tests 1')
+# 2. Skip configure and make commands and go directly to 'make check'
+%if 0%{?run_tests_on_device}
+%define gdb_run_tests 1
+%define gdb_skip_configure 1
+%define gdb_skip_make 1
+%endif
+
+# Exit right after 'make ..' step to keep all object files produced by gdb build
+%if 0%{?exit_on_make_finish}
+%define gdb_exit_on_make_finish 1
+%endif
+
 Name:           gdb
 Version:        8.3.1
 Release:        0
@@ -18,6 +36,10 @@ BuildRequires:  python-devel
 BuildRequires:  gcc-c++
 BuildRequires:  ncurses-devel
 BuildRequires:  makeinfo
+%if 0%{?gdb_run_tests}
+BuildRequires:  dejagnu
+BuildRequires:  glibc-devel-static
+%endif
 
 %description
 GDB, the GNU debugger, allows you to debug programs written in C, C++,
@@ -40,6 +62,15 @@ and printing their data.
 
 This package provides a program that allows you to run GDB on a different machine than the one which is running the program being debugged.
 
+%{?gdb_run_tests:
+%package testresults
+Summary:       Testsuite results
+License:       Public Domain
+Group:         Development/Building
+%description testresults
+Results from running the gdb tests.
+}
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -59,23 +90,49 @@ LDFLAGS+=" -pie"
 #If you want to add a new LDFLAGS to IPA, add it to `IPA_LDFLAGS` rather than` LDFLAGS`.
 IPA_LDFLAGS+=""
 
+%{!?gdb_skip_configure:
 %configure                                             \
        --with-gdb-datadir=%{_datadir}/gdb              \
        --enable-gdb-build-warnings=,-Wno-unused        \
        --disable-werror                                \
        --with-separate-debug-dir=/usr/lib/debug        \
-       --disable-sim                                   \
+       %{!?gdb_run_tests:--disable-sim}                \
        --disable-rpath                                 \
        --with-expat                                    \
        --enable-64-bit-bfd                             \
-       --enable-static --disable-shared --enable-debug
+       --enable-debug                                  \
+       %{!?gdb_run_tests: --enable-static --disable-shared}
+}
 
+%{!?gdb_skip_make:
 make %{?_smp_mflags}
+}
+
+%{?gdb_exit_on_make_finish:
+exit 1
+}
+
+%{?gdb_run_tests:
+echo "Run testsuite"
+# asan needs a whole shadow address space
+ulimit -v unlimited || true
+make -k check %{?_smp_mflags} || true
+mkdir ./testresults
+for tool in $(find -name '*.sum' -exec basename {} \; | sort -u | sed -e 's/.sum//'); do
+./contrib/dg-extract-results.sh -t $tool $(find -name '*.sum') | tee -a ./testresults/test_summary.txt
+done
+}
 
 
 %install
 %make_install
 
+%{?gdb_run_tests:
+  find . \( -name "*.sum" -o -name "*.log" -a \! -name "config.log" \) -exec tar -rf testresults.tar {} \;
+  mkdir -p ./testresults && tar -xf testresults.tar -C ./testresults
+  find ./testresults/ -type f -exec chmod 644 {} \;
+}
+
 %find_lang opcodes
 %find_lang bfd
 mv opcodes.lang %{name}.lang
@@ -105,3 +162,10 @@ cat bfd.lang >> %{name}.lang
 %manifest %{name}.manifest
 %{_includedir}/*.h
 %{_includedir}/gdb/*.h
+
+%{?gdb_run_tests:
+%files testresults
+%defattr(-,root,root)
+%doc testresults/test_summary.txt
+%doc testresults/*
+}