mirror of
https://github.com/microsoft/mscclpp.git
synced 2026-05-12 01:10:22 +00:00
26 lines
600 B
C++
26 lines
600 B
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <mscclpp/errors.hpp>
|
|
#include <mscclpp/utils.hpp>
|
|
#include <thread>
|
|
|
|
TEST(UtilsTest, getHostName) {
|
|
std::string hostname1 = mscclpp::getHostName(1024, '.');
|
|
EXPECT_FALSE(hostname1.empty());
|
|
EXPECT_LE(hostname1.size(), 1024);
|
|
|
|
EXPECT_EQ(mscclpp::getHostName(1024, hostname1[0]).size(), 0);
|
|
|
|
std::string hostname2;
|
|
|
|
std::thread th([&hostname2]() { hostname2 = mscclpp::getHostName(1024, '.'); });
|
|
|
|
ASSERT_TRUE(th.joinable());
|
|
th.join();
|
|
|
|
EXPECT_EQ(hostname1, hostname2);
|
|
}
|