#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;
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) {
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)});
}
TEST_F(EnvVarSaverTest, ExampleExisting) {
- auto key = "USER";
+ auto key = "PATH";
EXPECT_NE(nullptr, getenv(key));
auto value = std::string{getenv(key)};
}
TEST_F(EnvVarSaverTest, ExampleDeleting) {
- auto key = "USER";
+ auto key = "PATH";
EXPECT_NE(nullptr, getenv(key));
auto value = std::string{getenv(key)};