Skip to content

Commit

Permalink
Preapre unittests skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 23, 2021
1 parent 31718cf commit 2418585
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
2 changes: 0 additions & 2 deletions unittest/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
SUBDIRS = meta lib vslib syncd

ACLOCAL_AMFLAGS=-I m4
2 changes: 1 addition & 1 deletion unittest/meta/TestAttrKeyMap.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "AttrKeyMap.cpp"
#include "AttrKeyMap.h"

#include <gtest/gtest.h>

Expand Down
6 changes: 3 additions & 3 deletions unittest/syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/syncd -I$(top_srcdir)/lib -I$(top_srcdir

bin_PROGRAMS = tests

LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main

tests_SOURCES = main.cpp \
TestCommandLineOptions.cpp

tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDADD = $(top_srcdir)/syncd/libSyncd.a -lswsscommon -lpthread -L$(top_srcdir)/lib/.libs -lsairedis -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)

TESTS = tests
tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/syncd/libSyncd.a -lswsscommon -lpthread -L$(top_srcdir)/lib/.libs -lsairedis -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)
19 changes: 16 additions & 3 deletions unittest/syncd/TestCommandLineOptions.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#include "CommandLineOptions.h"

void testCtr()
#include <gtest/gtest.h>

using namespace syncd;

TEST(CommandLineOptions, getCommandLineString)
{
syncd::CommandLineOptions opt;

opt.getCommandLineString();
auto str = opt.getCommandLineString();

EXPECT_EQ(str, " EnableDiagShell=NO EnableTempView=NO DisableExitSleep=NO EnableUnittests=NO"
" EnableConsistencyCheck=NO EnableSyncMode=NO RedisCommunicationMode=redis_async"
" EnableSaiBulkSuport=NO StartType=cold ProfileMapFile= GlobalContext=0 ContextConfig= BreakConfig=");
}

TEST(CommandLineOptions, startTypeStringToStartType)
{
auto st = syncd::CommandLineOptions::startTypeStringToStartType("foo");

syncd::CommandLineOptions::startTypeStringToStartType("foo");
EXPECT_EQ(st, SAI_START_TYPE_UNKNOWN);
}
15 changes: 9 additions & 6 deletions unittest/syncd/main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include <gtest/gtest.h>

// TODO to gtest?
#include <iostream>

void testCtr();

int main()
int main(int argc, char* argv[])
{
testCtr();
testing::InitGoogleTest(&argc, argv);

const auto env = new ::testing::Environment();

testing::AddGlobalTestEnvironment(env);

return 0;
return RUN_ALL_TESTS();
}

0 comments on commit 2418585

Please sign in to comment.