diff --git a/db/makefile b/db/makefile index b3a66ceeabe..c69264c8a02 100644 --- a/db/makefile +++ b/db/makefile @@ -17,7 +17,7 @@ OBJS=../stdafx.o ../util/sock.o ../grid/message.o ../util/mmap.o pdfile.o query. DBGRID_OBJS=../stdafx.o json.o ../util/sock.o ../grid/message.o ../util/util.o jsobj.o ../client/dbclient.o ../dbgrid/dbgrid.o ../dbgrid/request.o ../client/connpool.o ../dbgrid/gridconfig.o commands.o ../dbgrid/dbgrid_commands.o ../dbgrid/griddatabase.o ../client/model.o ../util/background.o ../dbgrid/shard.o lasterror.o ../util/md5.o ../util/md5main.o security.o -DBTEST_OBJS= $(OBJS) ../dbtests/dbtests.o ../dbtests/btreetests.o ../dbtests/jsobjtests.o ../dbtests/jsontests.o ../dbtests/matchertests.o ../dbtests/namespacetests.o ../dbtests/pairingtests.o ../dbtests/pdfiletests.o ../dbtests/querytests.o +DBTEST_OBJS= $(OBJS) ../dbtests/dbtests.o ../dbtests/btreetests.o ../dbtests/jsobjtests.o ../dbtests/jsontests.o ../dbtests/matchertests.o ../dbtests/namespacetests.o ../dbtests/pairingtests.o ../dbtests/pdfiletests.o ../dbtests/querytests.o ../dbtests/socktests.o GPP = g++ diff --git a/dbtests/dbtests.cpp b/dbtests/dbtests.cpp index f72925e3a94..bba5fe8c9bb 100644 --- a/dbtests/dbtests.cpp +++ b/dbtests/dbtests.cpp @@ -90,6 +90,7 @@ int main( int argc, char** argv ) { tests.add( pairingTests(), "pairing" ); tests.add( pdfileTests(), "pdfile" ); tests.add( queryTests(), "query" ); + tests.add( sockTests(), "sock" ); return tests.run( argc, argv ); } diff --git a/dbtests/dbtests.h b/dbtests/dbtests.h index 8a55e23f91d..84a8c1df4c2 100644 --- a/dbtests/dbtests.h +++ b/dbtests/dbtests.h @@ -29,3 +29,4 @@ UnitTest::TestPtr namespaceTests(); UnitTest::TestPtr pairingTests(); UnitTest::TestPtr pdfileTests(); UnitTest::TestPtr queryTests(); +UnitTest::TestPtr sockTests(); diff --git a/dbtests/socktests.cpp b/dbtests/socktests.cpp new file mode 100644 index 00000000000..7923f25e73c --- /dev/null +++ b/dbtests/socktests.cpp @@ -0,0 +1,45 @@ +// socktests.cpp : sock.{h,cpp} unit tests. +// + +/** + * Copyright (C) 2008 10gen Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software 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. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "../util/sock.h" + +#include "dbtests.h" + +namespace SockTests { + + class HostByName { + public: + void run() { + ASSERT_EQUALS( "127.0.0.1", hostbyname( "localhost" ) ); + ASSERT_EQUALS( "127.0.0.1", hostbyname( "127.0.0.1" ) ); + } + }; + + class All : public UnitTest::Suite { + public: + All() { + add< HostByName >(); + } + }; + +} // namespace SockTests + +UnitTest::TestPtr sockTests() { + return UnitTest::createSuite< SockTests::All >(); +} \ No newline at end of file diff --git a/mongo.xcodeproj/project.pbxproj b/mongo.xcodeproj/project.pbxproj index 22616e2458f..54cc2744853 100644 --- a/mongo.xcodeproj/project.pbxproj +++ b/mongo.xcodeproj/project.pbxproj @@ -93,6 +93,7 @@ 934DD88B0EFAD23B00459CC1 /* sock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sock.h; sourceTree = ""; }; 934DD88D0EFAD23B00459CC1 /* unittest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unittest.h; sourceTree = ""; }; 934DD88E0EFAD23B00459CC1 /* util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = util.cpp; sourceTree = ""; }; + 937CACE90F27BF4900C57AA6 /* socktests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = socktests.cpp; sourceTree = ""; }; 93A6E10C0F24CF9800DA4EBF /* lasterror.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lasterror.h; sourceTree = ""; }; 93A6E10D0F24CFB100DA4EBF /* flushtest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = flushtest.cpp; sourceTree = ""; }; 93A6E10E0F24CFD300DA4EBF /* security.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = security.h; sourceTree = ""; }; @@ -156,6 +157,7 @@ 934223850EF16D7000608550 /* dbtests */ = { isa = PBXGroup; children = ( + 937CACE90F27BF4900C57AA6 /* socktests.cpp */, 93D6BC9B0F266FC300FE5722 /* querytests.cpp */, 93D6BBF70F265E1100FE5722 /* matchertests.cpp */, 93AF75500F216D0300994C66 /* jsontests.cpp */, diff --git a/util/sock.h b/util/sock.h index d72d70690ae..4630ef4d1cd 100644 --- a/util/sock.h +++ b/util/sock.h @@ -18,6 +18,8 @@ #pragma once +#include "../stdafx.h" + #include #include #include "goodies.h"