Skip to content

Commit

Permalink
issue: 2681317 integrate gtests
Browse files Browse the repository at this point in the history
  • Loading branch information
agalanin-at-nvidia authored and igor-ivanov committed Dec 24, 2021
1 parent ee6fe35 commit 7fb8c54
Show file tree
Hide file tree
Showing 40 changed files with 30,354 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ make install
options. Some of the options are generic autoconf options, while the sockperf
specific options are prefixed with "SOCKPERF:" in the help text.

* To enable test scripts
* To enable unit tests
* `./configure --prefix=<path to install> --enable-test`

* To enable the documentation
Expand Down
12 changes: 10 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ AM_MAINTAINER_MODE
: ${CXXFLAGS="-O3 -g"}
AC_PROG_CXX
AC_LANG(C++)
#AC_PROG_LIBTOOL
AM_PROG_AR
AC_PROG_LIBTOOL

SP_CHECK_CXXFLAGS_APPEND([OUR_CXXFLAGS], [\
-Wall \
Expand Down Expand Up @@ -173,7 +174,14 @@ AC_SEARCH_LIBS([pthread_create], [pthread], [], AC_MSG_ERROR([libpthread not fou
AC_SEARCH_LIBS([backtrace], [execinfo], [], AC_MSG_ERROR([libexecinfo not found]))
AC_SEARCH_LIBS([dlsym], [dl], [], AC_MSG_ERROR([libdl not found]))

AC_CONFIG_FILES([Makefile tools/Makefile tests/Makefile doc/Doxyfile build/sockperf.spec])
AC_CONFIG_FILES([
Makefile
tools/Makefile
tests/Makefile
tests/gtest/Makefile
doc/Doxyfile
build/sockperf.spec
])

AC_OUTPUT

Expand Down
1 change: 1 addition & 0 deletions contrib/jenkins_tests/globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ build_dir=${WORKSPACE}/${prefix}/build/
install_dir=${WORKSPACE}/${prefix}/install
compiler_dir=${WORKSPACE}/${prefix}/compiler
test_dir=${WORKSPACE}/${prefix}/test
gtest_dir=${WORKSPACE}/${prefix}/gtest
rpm_dir=${WORKSPACE}/${prefix}/rpm
cov_dir=${WORKSPACE}/${prefix}/cov
cppcheck_dir=${WORKSPACE}/${prefix}/cppcheck
Expand Down
39 changes: 39 additions & 0 deletions contrib/jenkins_tests/gtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash -eExl

source $(dirname $0)/globals.sh

echo "Checking for gtest ..."

# Check dependencies
if [ $(test -d ${install_dir} >/dev/null 2>&1 || echo $?) ]; then
echo "[SKIP] Not found ${install_dir} : build should be done before this stage"
exit 1
fi

cd $WORKSPACE

rm -rf $gtest_dir
mkdir -p $gtest_dir
cd $gtest_dir

gtest_app="$PWD/tests/gtest/gtest"
gtest_lib=$install_dir/lib/${prj_lib}

set +eE

${WORKSPACE}/configure --prefix=$install_dir --enable-test
make -C tests/gtest
rc=$(($rc+$?))

$timeout_exe env GTEST_TAP=2 $gtest_app --gtest_output=xml:${WORKSPACE}/${prefix}/test-basic.xml
rc=$(($rc+$?))

set -eE

for f in $(find $gtest_dir -name '*.tap')
do
cp $f ${WORKSPACE}/${prefix}/gtest-$(basename $f .tap).tap
done

echo "[${0##*/}]..................exit code = $rc"
exit $rc
11 changes: 11 additions & 0 deletions contrib/test_jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jenkins_test_cov=${jenkins_test_cov:="no"}
jenkins_test_cppcheck=${jenkins_test_cppcheck:="yes"}
jenkins_test_csbuild=${jenkins_test_csbuild:="no"}
jenkins_test_run=${jenkins_test_run:="no"}
jenkins_test_gtest=${jenkins_test_gtest:="yes"}
jenkins_test_style=${jenkins_test_style:="no"}


Expand Down Expand Up @@ -159,6 +160,16 @@ for target_v in "${target_list[@]}"; do
fi
fi
if [ 7 -lt "$jenkins_opt_exit" -o "$rc" -eq 0 ]; then
if [ "$jenkins_test_gtest" = "yes" ]; then
$WORKSPACE/contrib/jenkins_tests/gtest.sh
ret=$?
if [ $ret -gt 0 ]; then
do_err "case: [gtest: ret=$ret]"
fi
rc=$((rc + $ret))
fi
fi
if [ 8 -lt "$jenkins_opt_exit" -o "$rc" -eq 0 ]; then
if [ "$jenkins_test_style" = "yes" ]; then
$WORKSPACE/contrib/jenkins_tests/style.sh
ret=$?
Expand Down
13 changes: 2 additions & 11 deletions tests/Makefile.am
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
testdir = $(prefix)/etc/sockperf/

test_SCRIPTS = \
avner-analyze.awk \
avner-master-test.sh \
avner-test.sh \
avner-test-orig \
vma_multiplexers_test.sh \
vma_perf_envelope.sh

dist_test_SCRIPTS = \
SUBDIRS := gtest
EXTRA_DIST = gtest \
avner-analyze.awk \
avner-master-test.sh \
avner-test.sh \
Expand Down
108 changes: 108 additions & 0 deletions tests/gtest/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
noinst_PROGRAMS = gtest

#CXXFLAGS =
# google test shows some warnings that are suppressed
AM_CXXFLAGS = \
-Wno-error=sign-compare \
-Wno-error=missing-field-initializers \
-g -O0

AM_CPPFLAGS = \
-DGTEST_LANG_CXX11=0 \
-DGTEST_HAS_PTHREAD=1 \
-DGTEST_USE_OWN_TR1_TUPLE=0 \
-DGTEST_HAS_TR1_TUPLE=1 \
-DGTEST_ENV_HAS_STD_TUPLE_=0 \
-DGTEST_USES_SIMPLE_RE=0 \
-DPTHREADS \
\
-DGTEST_DONT_DEFINE_ASSERT_GT=0 \
-DGTEST_DONT_DEFINE_ASSERT_GE=0 \
-DGTEST_DONT_DEFINE_ASSERT_LT=0 \
-DGTEST_DONT_DEFINE_ASSERT_LE=0 \
-DGTEST_DONT_DEFINE_ASSERT_NE=0 \
-DGTEST_DONT_DEFINE_ASSERT_EQ=0 \
-DGTEST_DONT_DEFINE_SUCCEED=0 \
-DGTEST_DONT_DEFINE_FAIL=0 \
-DGTEST_DONT_DEFINE_TEST=0 \
\
-DGTEST_HAS_STD_WSTRING=0 \
-DGTEST_HAS_GLOBAL_STRING=0 \
\
-DGTEST_OS_WINDOWS=0 \
-DGTEST_OS_LINUX_ANDROID=0 \
-DGTEST_OS_CYGWIN=0 \
-DGTEST_OS_SOLARIS=0 \
-DGTEST_OS_SYMBIAN=0 \
-DGTEST_OS_WINDOWS_MOBILE=0 \
-DGTEST_OS_QNX=0 \
-DGTEST_OS_MAC=0 \
-DGTEST_OS_IOS=0 \
-DGTEST_OS_ZOS

# lgtest
noinst_LTLIBRARIES = libgtest.la

libgtest_la_CPPFLAGS = \
-I$(top_srcdir)/tests/gtest/googletest \
-I$(top_srcdir)/tests/gtest/googletest/include \
$(AM_CPPFLAGS)

libgtest_la_LDFLAGS = -pthread -static
libgtest_la_CXXFLAGS = \
$(AM_CXXFLAGS)

EXTRA_DIST = \
googletest/include \
googletest/src \
googletest/README.md \
googletest/LICENSE

libgtest_la_SOURCES = \
googletest/src/gtest-all.cc \
googletest/src/gtest_main.cc

# gtest
gtest_LDADD = libgtest.la

gtest_CPPFLAGS = \
-I$(top_srcdir)/ \
-I$(top_srcdir)/src \
-I$(top_srcdir)/tests/gtest/googletest/include \
$(AM_CPPFLAGS)

gtest_LDFLAGS = -no-install
gtest_CXXFLAGS = \
$(AM_CXXFLAGS)

gtest_SOURCES = \
main.cpp \
\
message_parser_tests.cpp

noinst_HEADERS =

gtest_DEPENDENCIES = \
libgtest.la

# This workaround allows to compile files located
# at another directory.
# This place resolve make distcheck issue
nodist_gtest_SOURCES = \
defs.cpp \
message.cpp \
os_abstract.cpp

CLEANFILES = \
defs.cpp \
message.cpp \
os_abstract.cpp

defs.cpp:
@echo "#include \"$(top_builddir)/src/$@\"" >$@

message.cpp:
@echo "#include \"$(top_builddir)/src/$@\"" >$@

os_abstract.cpp:
@echo "#include \"$(top_builddir)/src/$@\"" >$@
Loading

0 comments on commit 7fb8c54

Please sign in to comment.