Files
mscclpp/test/unit/socket_tests.cc
copilot-swe-agent[bot] e227fdc1ef Convert mp_unit tests from gtest to framework.hpp
- Modified test/mp_unit/mp_unit_tests.hpp to use ../framework.hpp instead of gtest/gtest.h
- Enhanced test/framework.hpp with GTest-compatible APIs:
  - Added Environment base class for global test setup/teardown
  - Added TestInfo and UnitTest classes for test metadata access
  - Added GTEST_SKIP macro support via SkipHelper class
  - Added namespace alias 'testing' for compatibility
  - Added InitGoogleTest and AddGlobalTestEnvironment helper functions
- Updated test/framework.cc with implementations for new classes
- All mp_unit test files now use framework.hpp through mp_unit_tests.hpp
- Formatting applied via lint.sh

Co-authored-by: chhwang <8018170+chhwang@users.noreply.github.com>
2026-02-11 00:21:04 +00:00

32 lines
700 B
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include <mscclpp/utils.hpp>
#include <thread>
#include "../framework.hpp"
#include "socket.h"
#include "utils_internal.hpp"
TEST(Socket, ListenAndConnect) {
mscclpp::Timer timeout(3);
std::string ipPortPair = "127.0.0.1:51512";
mscclpp::SocketAddress listenAddr;
ASSERT_NO_THROW(mscclpp::SocketGetAddrFromString(&listenAddr, ipPortPair.c_str()));
mscclpp::Socket listenSock(&listenAddr);
listenSock.bindAndListen();
std::thread clientThread([&listenAddr]() {
mscclpp::Socket sock(&listenAddr);
sock.connect();
});
mscclpp::Socket sock;
sock.accept(&listenSock);
clientThread.join();
}