mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Add new getfullyqualifiedname test
This commit is contained in:
1 parent
2d442eb732
commit
2eaf911346
2 files changed
+36
No files matched your search
@@ -5,6 +5,7 @@ add_executable(psnative-test
|
||||
test-getusername.cpp
|
||||
test-getcomputername.cpp
|
||||
test-getlinkcount.cpp
|
||||
test-getfullyqualifiedname.cpp
|
||||
main.cpp)
|
||||
|
||||
# manually include gtest headers
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//! @file test-getfullyqualifiedname.cpp
|
||||
//! @author George Fleming <v-geflem@microsoft.com>
|
||||
//! @brief Unit tests for GetFullyQualifiedName
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "getfullyqualifiedname.h"
|
||||
|
||||
//! Test fixture for GetComputerNameTest
|
||||
class GetFullyQualifiedNameTest : public ::testing::Test
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(GetFullyQualifiedNameTest, ValidateLinuxGetFullyQualifiedDomainName)
|
||||
{
|
||||
char expectedComputerName[HOST_NAME_MAX];
|
||||
|
||||
//Get expected result from using linux command
|
||||
|
||||
FILE *fPtr = popen("/bin/hostname --fqdn", "r");
|
||||
ASSERT_TRUE(fPtr != NULL);
|
||||
|
||||
char *linePtr = fgets(expectedComputerName, sizeof(expectedComputerName), fPtr);
|
||||
ASSERT_TRUE(linePtr != NULL);
|
||||
|
||||
// There's a tendency to have \n at end of fgets string, so remove it before compare
|
||||
size_t sz = strlen(expectedComputerName);
|
||||
if (sz > 0 && expectedComputerName[sz - 1] == '\n')
|
||||
{
|
||||
expectedComputerName[sz - 1] = '\0';
|
||||
}
|
||||
pclose(fPtr);
|
||||
|
||||
ASSERT_STREQ(GetFullyQualifiedName(), expectedComputerName);
|
||||
}
|
||||
Reference in new issue
Block a user