On 2015-05-26 07:23, praveen malviya wrote:
>
>
>
> On 08-May-15 1:41 PM, Hans Nordeback wrote:
>>    00-README.unittest                              |  32 ++++++++++++++++
>>    configure.ac                                    |   1 +
>>    osaf/services/saf/amf/amfd/Makefile.am          |   2 +-
>>    osaf/services/saf/amf/amfd/tests/Makefile.am    |  50 
>> +++++++++++++++++++++++++
>>    osaf/services/saf/amf/amfd/tests/test_amf_db.cc |  44 
>> ++++++++++++++++++++++
>>    5 files changed, 128 insertions(+), 1 deletions(-)
>>
>>
>> As part of refactoring enable the use of google unit test framework.
>>
>> diff --git a/00-README.unittest b/00-README.unittest
>> new file mode 100644
>> --- /dev/null
>> +++ b/00-README.unittest
>> @@ -0,0 +1,32 @@
>> +Support for using google unit test in openSAF. Using unit test during e.g. 
>> refactoring
>> +to identify units and make code unit testable should improve the overall 
>> code quality
>> +and robustness.
> One questions, as I am not much familiar with google test framework:
>
> Besides testing the code units (refactored or newly developed), could
> this framework be used for functional testing for a distributed
> scenario? A AMF model is distributed across the nodes and a functional
> test case may require sync among nodes.

Well you can but you probably/most likely want to write such framework in for 
example python and not 
C/C++.

Thanks,
Hans


>
>
> Thanks,
> Praveen
>> +Regarding google unit test, see:
>> +https://code.google.com/p/googletest/
>> +
>> +To install google test in Ubuntu 14.04 do:
>> +sudo apt-get install libgtest-dev
>> +sudo apt-get install cmake
>> +
>> +cd /usr/src/gtest
>> +sudo cmake .
>> +sudo make
>> +sudo mv libg* /usr/lib/
>> +
>> +Add the following environment variable where the gtest header files are 
>> located:
>> +export GTEST_DIR=/usr/include/gtest
>> +
>> +configure openSAF as usual, for example
>> +./bootstrap.ch
>> +./configure CFLAGS="-DRUNASROOT -O2" CXXFLAGS="-DRUNASROOT -O2" 
>> --enable-tipc
>> +
>> +make -j
>> +
>> +To build and run the unit tests
>> +make check
>> +
>> +A unit test report will be written on the console.
>> +
>> +The unit test cases are to be placed in a new directory called tests at the 
>> same directory level as e.g. include,
>> +scripts etc.
>> +Unit test logs etc. can be found under the tests directory.
>> \ No newline at end of file
>> diff --git a/configure.ac b/configure.ac
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -801,6 +801,7 @@ AC_CONFIG_FILES([
>>            osaf/services/saf/amf/amfd/include/Makefile
>>            osaf/services/saf/amf/amfd/scripts/Makefile
>>            osaf/services/saf/amf/amfd/scripts/osaf-amfd
>> +        osaf/services/saf/amf/amfd/tests/Makefile
>>            osaf/services/saf/amf/amfnd/Makefile
>>            osaf/services/saf/amf/amfnd/include/Makefile
>>            osaf/services/saf/amf/amfnd/scripts/Makefile
>> diff --git a/osaf/services/saf/amf/amfd/Makefile.am 
>> b/osaf/services/saf/amf/amfd/Makefile.am
>> --- a/osaf/services/saf/amf/amfd/Makefile.am
>> +++ b/osaf/services/saf/amf/amfd/Makefile.am
>> @@ -18,7 +18,7 @@ include $(top_srcdir)/Makefile.common
>>
>>    MAINTAINERCLEANFILES = Makefile.in
>>
>> -SUBDIRS = include scripts
>> +SUBDIRS = include scripts tests
>>
>>    osaf_execbindir = $(pkglibdir)
>>    osaf_execbin_PROGRAMS = osafamfd
>> diff --git a/osaf/services/saf/amf/amfd/tests/Makefile.am 
>> b/osaf/services/saf/amf/amfd/tests/Makefile.am
>> new file mode 100644
>> --- /dev/null
>> +++ b/osaf/services/saf/amf/amfd/tests/Makefile.am
>> @@ -0,0 +1,50 @@
>> +#      -*- OpenSAF  -*-
>> +#
>> +# (C) Copyright 2015 The OpenSAF Foundation
>> +#
>> +# This program is distributed in the hope that it will be useful, but
>> +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
>> +# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
>> +# under the GNU Lesser General Public License Version 2.1, February 1999.
>> +# The complete license can be accessed from the following location:
>> +# http://opensource.org/licenses/lgpl-license.php
>> +# See the Copying file included with the OpenSAF distribution for full
>> +# licensing terms.
>> +#
>> +# Author(s): Ericsson AB
>> +#
>> +
>> +include $(top_srcdir)/Makefile.common
>> +
>> +TESTS = testamfd
>> +
>> +check_PROGRAMS = testamfd
>> +
>> +testamfd_CXXFLAGS =$(AM_CXXFLAGS)
>> +
>> +testamfd_CPPFLAGS = \
>> +    -DSA_CLM_B01=1 \
>> +    $(AM_CPPFLAGS) \
>> +    -I$(top_srcdir)/osaf/libs/common/amf/include \
>> +    -I$(top_srcdir)/osaf/services/saf/amf/amfd/include \
>> +    -I$(top_srcdir)/osaf/libs/common/immsv/include \
>> +    -I$(top_srcdir)/osaf/tools/saflog/include \
>> +    -I$(GTEST_DIR)
>> +
>> +testamfd_LDFLAGS = \
>> +    -lgtest -lpthread
>> +
>> +testamfd_SOURCES = \
>> +    test_amf_db.cc
>> +
>> +testamfd_LDADD = \
>> +    $(top_builddir)/osaf/tools/saflog/src/libsaflog.la \
>> +    $(top_builddir)/osaf/tools/safimm/src/libimmutil.la \
>> +    $(top_builddir)/osaf/libs/core/libopensaf_core.la \
>> +    $(top_builddir)/osaf/libs/common/amf/libamf_common.la \
>> +    $(top_builddir)/osaf/libs/saf/libSaNtf/libSaNtf.la \
>> +    $(top_builddir)/osaf/libs/saf/libSaImm/libSaImmOi.la \
>> +    $(top_builddir)/osaf/libs/saf/libSaImm/libSaImmOm.la \
>> +    $(top_builddir)/osaf/libs/saf/libSaClm/libSaClm.la \
>> +    $(top_builddir)/osaf/libs/saf/libSaLog/libSaLog.la \
>> +    $(top_builddir)/osaf/libs/agents/infrastructure/rda/librda.la
>> diff --git a/osaf/services/saf/amf/amfd/tests/test_amf_db.cc 
>> b/osaf/services/saf/amf/amfd/tests/test_amf_db.cc
>> new file mode 100755
>> --- /dev/null
>> +++ b/osaf/services/saf/amf/amfd/tests/test_amf_db.cc
>> @@ -0,0 +1,44 @@
>> +#include "gtest/gtest.h"
>> +#include "db_template.h"
>> +
>> +
>> +namespace {
>> +
>> +class TEST_APP {
>> +};
>> +
>> +// The fixture for testing class AmfDb
>> +class AmfDbTest : public ::testing::Test {
>> +
>> + protected:
>> +
>> +  virtual void SetUp() {
>> +
>> +  }
>> +
>> +  virtual void TearDown() {
>> +  }
>> +
>> +  AmfDb<std::string, TEST_APP> db_;
>> +
>> +};
>> +
>> +TEST_F(AmfDbTest, IsEmptyInitially) {
>> +  std::map<std::string, TEST_APP*>::const_iterator it = db_.begin();
>> +  EXPECT_EQ(it, db_.end());
>> +}
>> +
>> +TEST_F(AmfDbTest, InsertWorks) {
>> +  unsigned int rc = 0;
>> +  TEST_APP *app = new TEST_APP;
>> +  std::string str("app1");
>> +  rc = db_.insert(str, app);
>> +  EXPECT_EQ(1, rc);
>> +}
>> +
>> +}
>> +
>> +int main(int argc, char **argv) {
>> +  ::testing::InitGoogleTest(&argc, argv);
>> +  return RUN_ALL_TESTS();
>> +}
>>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Opensaf-devel mailing list
> Opensaf-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/opensaf-devel
>
>

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to