/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <folly/experimental/TestUtil.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
#include <system_error>
#include <boost/algorithm/string.hpp>
#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)});