fall back to .debug_info scan in fatal signal handler
[folly.git] / folly / experimental / test / TestUtilTest.cpp
index 7b1eeda380c0e3c80eea72ef1fcdf532b49efb95..79046e0736ea126f8b91f4339a4a45ee192ea61e 100644 (file)
 
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <fcntl.h>
 
 #include <system_error>
 
 #include <boost/algorithm/string.hpp>
-#include <folly/Memory.h>
 #include <glog/logging.h>
-#include <gtest/gtest.h>
+
+#include <folly/Memory.h>
+#include <folly/portability/Environment.h>
+#include <folly/portability/Fcntl.h>
+#include <folly/portability/GTest.h>
 
 using namespace folly;
 using namespace folly::test;
@@ -43,13 +45,15 @@ TEST(TemporaryFile, Simple) {
     EXPECT_EQ(1, r);
   }
 
-  // The file must have been closed.  This assumes that no other thread
-  // has opened another file in the meanwhile, which is a sane assumption
-  // to make in this test.
-  ssize_t r = write(fd, &c, 1);
-  int savedErrno = errno;
-  EXPECT_EQ(-1, r);
-  EXPECT_EQ(EBADF, savedErrno);
+  msvcSuppressAbortOnInvalidParams([&] {
+    // The file must have been closed.  This assumes that no other thread
+    // has opened another file in the meanwhile, which is a sane assumption
+    // to make in this test.
+    ssize_t r = write(fd, &c, 1);
+    int savedErrno = errno;
+    EXPECT_EQ(-1, r);
+    EXPECT_EQ(EBADF, savedErrno);
+  });
 }
 
 TEST(TemporaryFile, Prefix) {
@@ -194,6 +198,11 @@ TEST_F(EnvVarSaverTest, ExampleNew) {
   auto key = "hahahahaha";
   EXPECT_EQ(nullptr, getenv(key));
 
+  PCHECK(0 == setenv(key, "", true));
+  EXPECT_STREQ("", getenv(key));
+  PCHECK(0 == unsetenv(key));
+  EXPECT_EQ(nullptr, getenv(key));
+
   auto saver = make_unique<EnvVarSaver>();
   PCHECK(0 == setenv(key, "blah", true));
   EXPECT_EQ("blah", std::string{getenv(key)});
@@ -202,7 +211,7 @@ TEST_F(EnvVarSaverTest, ExampleNew) {
 }
 
 TEST_F(EnvVarSaverTest, ExampleExisting) {
-  auto key = "USER";
+  auto key = "PATH";
   EXPECT_NE(nullptr, getenv(key));
   auto value = std::string{getenv(key)};
 
@@ -214,7 +223,7 @@ TEST_F(EnvVarSaverTest, ExampleExisting) {
 }
 
 TEST_F(EnvVarSaverTest, ExampleDeleting) {
-  auto key = "USER";
+  auto key = "PATH";
   EXPECT_NE(nullptr, getenv(key));
   auto value = std::string{getenv(key)};