From d5c0ad08cb3f8438ce599152c2fe3868046b67ee Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 4 Nov 2015 20:30:52 -0800 Subject: [PATCH 1/3] Fix test since gethostname gets the nodename The nodename is not necessarily the short name returned by hostname. --- native/getcomputername.cpp | 3 ++- tests/test-getcomputername.cpp | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/native/getcomputername.cpp b/native/getcomputername.cpp index 67e3d870d..70a52a684 100644 --- a/native/getcomputername.cpp +++ b/native/getcomputername.cpp @@ -33,7 +33,8 @@ char* GetComputerName() return NULL; } - // Get computername from system in a thread-safe manner + // Get computername from system, not that gethostname gets the + // nodename from uname std::string computername(NAME_MAX, 0); int err = gethostname(&computername[0], computername.length()); // Map errno to Win32 Error Codes diff --git a/tests/test-getcomputername.cpp b/tests/test-getcomputername.cpp index 2a6bf5e0f..5820d0565 100644 --- a/tests/test-getcomputername.cpp +++ b/tests/test-getcomputername.cpp @@ -10,13 +10,12 @@ class GetComputerNameTest : public ::testing::Test { }; -TEST_F(GetComputerNameTest, ValidateLinuxGetHostnameSystemCall) +TEST_F(GetComputerNameTest, Success) { char expectedComputerName[NAME_MAX]; - //Get expected result from using linux command - - FILE *fPtr = popen("hostname -s", "r"); + // the gethostname system call gets the nodename from uname + FILE *fPtr = popen("uname -n", "r"); ASSERT_TRUE(fPtr != NULL); char *linePtr = fgets(expectedComputerName, sizeof(expectedComputerName), fPtr); From 8c9c9b2284b4bbd79163a303548e2462e97e82b6 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 4 Nov 2015 20:47:28 -0800 Subject: [PATCH 2/3] Fix username tests by checking for null --- tests/test-getusername.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tests/test-getusername.cpp b/tests/test-getusername.cpp index 50c2d1fea..cab8cb98b 100644 --- a/tests/test-getusername.cpp +++ b/tests/test-getusername.cpp @@ -10,18 +10,9 @@ #include #include "getusername.h" -//! Test fixture for GetUserName -class GetUserNameTest : public ::testing::Test +TEST(GetUserName, Success) { -protected: - std::string UserName; - - GetUserNameTest(): UserName(std::string(getpwuid(geteuid())->pw_name)) - { - } -}; - -TEST_F(GetUserNameTest, Success) -{ - ASSERT_EQ(GetUserName(), UserName); + char* expected = getpwuid(geteuid())->pw_name; + ASSERT_TRUE(expected != NULL); + ASSERT_EQ(GetUserName(), std::string(expected)); } From 9c6edbc7a1432d993d82ac86f0d8a7daeff97e0e Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Fri, 6 Nov 2015 23:03:45 +0000 Subject: [PATCH 3/3] Added -Werror to treat all warnings as errors to monad-native CMake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b61395b0c..e0e4a7ab9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8.4) project(MONAD_NATIVE) -add_compile_options(-std=c++11 -Wall) +add_compile_options(-std=c++11 -Wall -Werror) # test in BUILD_DIR enable_testing()