Ack.

regards,

Anders Widell


On 10/22/2016 02:53 PM, Hans Nordeback wrote:
>   osaf/libs/core/cplusplus/base/tests/Makefile.am         |   7 +-
>   osaf/libs/core/cplusplus/base/tests/file_notify_test.cc |  83 
> +++++++++++++++++
>   2 files changed, 88 insertions(+), 2 deletions(-)
>
>
> diff --git a/osaf/libs/core/cplusplus/base/tests/Makefile.am 
> b/osaf/libs/core/cplusplus/base/tests/Makefile.am
> --- a/osaf/libs/core/cplusplus/base/tests/Makefile.am
> +++ b/osaf/libs/core/cplusplus/base/tests/Makefile.am
> @@ -33,7 +33,8 @@ libbase_test_LDFLAGS = \
>       -pthread -lrt \
>       $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-getenv.o \
>       $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-log_message.o \
> -     $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-process.o
> +     $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-process.o \
> +     $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-file_notify.o
>   
>   libbase_test_SOURCES = \
>       getenv_test.cc \
> @@ -44,8 +45,10 @@ libbase_test_SOURCES = \
>       time_add_test.cc \
>       time_compare_test.cc \
>       time_convert_test.cc \
> +     file_notify_test.cc \
>       time_subtract_test.cc
>   
>   libbase_test_LDADD = \
>       $(GTEST_DIR)/lib/libgtest.la \
> -     $(GTEST_DIR)/lib/libgtest_main.la
> +     $(GTEST_DIR)/lib/libgtest_main.la \
> +     $(top_builddir)/osaf/libs/core/libopensaf_core.la
> diff --git a/osaf/libs/core/cplusplus/base/tests/file_notify_test.cc 
> b/osaf/libs/core/cplusplus/base/tests/file_notify_test.cc
> new file mode 100644
> --- /dev/null
> +++ b/osaf/libs/core/cplusplus/base/tests/file_notify_test.cc
> @@ -0,0 +1,83 @@
> +/*      -*- OpenSAF  -*-
> + *
> + * (C) Copyright 2016 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 "base/file_notify.h"
> +#include "gtest/gtest.h"
> +
> +class FileNotifyTest : public ::testing::Test {
> + protected:
> +  FileNotifyTest() {
> +    // Setup work can be done here for each test.
> +  }
> +
> +  virtual ~FileNotifyTest() {
> +    // Cleanup work that doesn't throw exceptions here.
> +  }
> +
> +  // If the constructor and destructor are not enough for setting up
> +  // and cleaning up each test, you can define the following methods:
> +
> +  // cppcheck-suppress unusedFunction
> +  virtual void SetUp() {
> +    // Code here will be called immediately after the constructor (right
> +    // before each test).
> +  }
> +
> +  // cppcheck-suppress unusedFunction
> +  virtual void TearDown() {
> +    // Code here will be called immediately after each test (right
> +    // before the destructor).
> +  }
> +
> +  // Objects declared here can be used by all tests in the test case.
> +  base::FileNotify::FileNotifyErrors rc{0};
> +};
> +
> +//
> +TEST_F(FileNotifyTest, TestNonExistingPathCreation) {
> +  base::FileNotify file_notify;
> +  std::string non_existing_file = "/a/b/c";
> +
> +  rc = file_notify.WaitForFileCreation(non_existing_file, 10);
> +  ASSERT_EQ(rc, base::FileNotify::FileNotifyErrors::kError);
> +}
> +
> +//
> +TEST_F(FileNotifyTest, TestExistingFileCreation) {
> +  base::FileNotify file_notify;
> +  std::string existing_file = __FILE__;
> +
> +  rc = file_notify.WaitForFileCreation(existing_file, 10);
> +  ASSERT_EQ(rc, base::FileNotify::FileNotifyErrors::kOK);
> +}
> +
> +//
> +TEST_F(FileNotifyTest, TestNonExistingPathDeletion) {
> +  base::FileNotify file_notify;
> +  std::string non_existing_path = "/a/b/c";
> +
> +  rc = file_notify.WaitForFileDeletion(non_existing_path, 10);
> +  ASSERT_EQ(rc, base::FileNotify::FileNotifyErrors::kOK);
> +}
> +
> +TEST_F(FileNotifyTest, TestExistingFileDeletion) {
> +  base::FileNotify file_notify;
> +  std::string existing_file = __FILE__;
> +
> +  rc = file_notify.WaitForFileDeletion(existing_file, 10);
> +  ASSERT_EQ(rc, base::FileNotify::FileNotifyErrors::kTimeOut);
> +}


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to