Skip to content

Commit

Permalink
Merge pull request #1076 from peternewman/0.10
Browse files Browse the repository at this point in the history
Fix a segfault with the client if auto start is off or olad fails to start
  • Loading branch information
nomis52 committed May 19, 2016
2 parents e7e5a29 + 0863540 commit 7c2863c
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/ola/client/ClientWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ class GenericClientWrapper: public BaseClientWrapper {
ola::network::IPV4Address::Loopback(),
OLA_DEFAULT_PORT)));
}
m_socket->SetNoDelay();
if (m_socket.get()) {
m_socket->SetNoDelay();
}
}
};

Expand Down
3 changes: 2 additions & 1 deletion ola/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ola_libola_la_LIBADD = common/libolacommon.la
##################################################
test_programs += ola/OlaClientTester

ola_OlaClientTester_SOURCES = ola/StreamingClientTest.cpp
ola_OlaClientTester_SOURCES = ola/OlaClientWrapperTest.cpp \
ola/StreamingClientTest.cpp
ola_OlaClientTester_CXXFLAGS = $(COMMON_TESTING_FLAGS)
ola_OlaClientTester_LDADD = $(COMMON_TESTING_LIBS) \
$(PLUGIN_LIBS) \
Expand Down
61 changes: 61 additions & 0 deletions ola/OlaClientWrapperTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* OlaClientWrapperTest.cpp
* Basic test fixture for the OlaClientWrapper class
* Copyright (C) 2016 Peter Newman
*/

#include <cppunit/extensions/HelperMacros.h>
#include <string>
#include <memory>

#include "ola/client/ClientWrapper.h"
#include "ola/testing/TestUtils.h"

using ola::client::OlaClientWrapper;

class OlaClientWrapperTest: public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(OlaClientWrapperTest);
CPPUNIT_TEST(testNoAutoStartNoOlad);
CPPUNIT_TEST_SUITE_END();

public:
void testNoAutoStartNoOlad();
};


CPPUNIT_TEST_SUITE_REGISTRATION(OlaClientWrapperTest);


/*
* Check that the client works correctly with no auto start and without olad
* running.
*/
void OlaClientWrapperTest::testNoAutoStartNoOlad() {
// Setup the client
OlaClientWrapper ola_client(false);

// Setup the client, this tried to connect to the server
OLA_ASSERT_FALSE(ola_client.Setup());
// Try it again to make sure it still fails
OLA_ASSERT_FALSE(ola_client.Setup());

// This should be a NOOP
OLA_ASSERT_TRUE(ola_client.Cleanup());

// Try for a third time to start
OLA_ASSERT_FALSE(ola_client.Setup());
}

0 comments on commit 7c2863c

Please sign in to comment.