Skip to content

Commit

Permalink
fix windows build
Browse files Browse the repository at this point in the history
Test plan:

build locally with VS 2019 Build Tools

before, broken

after, works
  • Loading branch information
ahornby committed Feb 26, 2024
1 parent 7ca2d7e commit aeeb2fa
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 21 deletions.
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
BENCHMARK foreach_benchmark SOURCES ForeachBenchmark.cpp
TEST foreach_test SOURCES ForeachTest.cpp
TEST merge_test SOURCES MergeTest.cpp
BENCHMARK sparse_byte_set_benchmark SOURCES SparseByteSetBenchmark.cpp
BENCHMARK sparse_byte_set_benchmark WINDOWS_DISABLED
SOURCES SparseByteSetBenchmark.cpp
TEST sparse_byte_set_test SOURCES SparseByteSetTest.cpp
TEST util_test SOURCES UtilTest.cpp

Expand Down Expand Up @@ -667,13 +668,14 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
TEST simple_simd_string_utils_test SOURCES SimpleSimdStringUtilsTest.cpp

DIRECTORY detail/test/
TEST split_string_simd_test SOURCES SplitStringSimdTest.cpp
TEST split_string_simd_test WINDOWS_DISABLED
SOURCES SplitStringSimdTest.cpp

DIRECTORY detail/test/
TEST unroll_utils_test SOURCES UnrollUtilsTest.cpp

DIRECTORY detail/base64_detail/tests/
TEST base64_detail_test
TEST base64_detail_test WINDOWS_DISABLED
SOURCES
Base64AgainstScalarTest.cpp
Base64PlatformTest.cpp
Expand All @@ -685,8 +687,7 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
BENCHMARK edf_thread_pool_executor_benchmark
SOURCES EDFThreadPoolExecutorBenchmark.cpp
TEST executor_test SOURCES ExecutorTest.cpp
TEST fiber_io_executor_test WINDOWS_DISABLED
SOURCES FiberIOExecutorTest.cpp
TEST fiber_io_executor_test SOURCES FiberIOExecutorTest.cpp
TEST global_executor_test SOURCES GlobalExecutorTest.cpp
TEST serial_executor_test SOURCES SerialExecutorTest.cpp
# Fails in ThreadPoolExecutorTest.RequestContext:719 data2 != nullptr
Expand Down Expand Up @@ -760,13 +761,15 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)

DIRECTORY fibers/test/
# FiberManager swapWithException fails with segfault
BENCHMARK fibers_benchmark SOURCES FibersBenchmark.cpp
BENCHMARK fibers_benchmark WINDOWS_DISABLED
SOURCES FibersBenchmark.cpp
TEST fibers_test BROKEN SOURCES FibersTest.cpp

DIRECTORY functional/test/
TEST apply_tuple_test WINDOWS_DISABLED
SOURCES ApplyTupleTest.cpp
TEST functional_invoke_test SOURCES InvokeTest.cpp
TEST functional_invoke_test WINDOWS_DISABLED
SOURCES InvokeTest.cpp
TEST partial_test SOURCES PartialTest.cpp
TEST functional_protocol_test SOURCES protocol_test.cpp
TEST functional_traits_test SOURCES traits_test.cpp
Expand Down Expand Up @@ -935,7 +938,8 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
TEST libgen-test SOURCES LibgenTest.cpp
TEST openssl_portability_test SOURCES OpenSSLPortabilityTest.cpp
TEST pthread_test SOURCES PThreadTest.cpp
TEST time-test SOURCES TimeTest.cpp
TEST time-test WINDOWS_DISABLED
SOURCES TimeTest.cpp

DIRECTORY ssl/test/
TEST openssl_hash_test SOURCES OpenSSLHashTest.cpp
Expand Down Expand Up @@ -997,7 +1001,8 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
BENCHMARK concurrent_skip_list_benchmark
SOURCES ConcurrentSkipListBenchmark.cpp
TEST concurrent_skip_list_test SOURCES ConcurrentSkipListTest.cpp
TEST constexpr_math_test SOURCES ConstexprMathTest.cpp
TEST constexpr_math_test WINDOWS_DISABLED
SOURCES ConstexprMathTest.cpp
TEST conv_test WINDOWS_DISABLED SOURCES ConvTest.cpp
TEST cpu_id_test SOURCES CpuIdTest.cpp
TEST demangle_test SOURCES DemangleTest.cpp
Expand All @@ -1009,7 +1014,8 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
SOURCES ExceptionWrapperBenchmark.cpp
TEST exception_wrapper_test WINDOWS_DISABLED
SOURCES ExceptionWrapperTest.cpp
TEST expected_test SOURCES ExpectedTest.cpp
TEST expected_test WINDOWS_DISABLED
SOURCES ExpectedTest.cpp
BENCHMARK fbstring_benchmark WINDOWS_DISABLED
SOURCES FBStringBenchmark.cpp
HEADERS FBStringTestBenchmarks.cpp.h
Expand Down Expand Up @@ -1064,7 +1070,8 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS)
#TEST poly_test SOURCES PolyTest.cpp
TEST portability_test SOURCES PortabilityTest.cpp
# Turns out this benchmark uses Linux only API for setting CPU affinity i.e. cpu_set_t.
BENCHMARK producer_consumer_queue_benchmark APPLE_DISABLED SOURCES ProducerConsumerQueueBenchmark.cpp
BENCHMARK producer_consumer_queue_benchmark APPLE_DISABLED WINDOWS_DISABLED
SOURCES ProducerConsumerQueueBenchmark.cpp
TEST producer_consumer_queue_test SLOW
SOURCES ProducerConsumerQueueTest.cpp
BENCHMARK range_find_benchmark SOURCES RangeFindBenchmark.cpp
Expand Down
1 change: 1 addition & 0 deletions folly/Padded.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <boost/iterator/iterator_adaptor.hpp>

#include <folly/Portability.h>
#include <folly/portability/SysTypes.h>
#include <folly/Traits.h>
#include <folly/functional/Invoke.h>

Expand Down
1 change: 1 addition & 0 deletions folly/container/detail/BitIteratorDetail.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <type_traits>

#include <boost/iterator/iterator_adaptor.hpp>
#include <folly/portability/SysTypes.h>

#include <folly/portability/SysTypes.h>

Expand Down
5 changes: 5 additions & 0 deletions folly/hash/test/ChecksumBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ int main(int argc, char** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);

#ifdef _MSC_VER
// MSC doesn't have aligned_alloc
buf = static_cast<uint8_t*>(std::malloc(kBufSize));
#else
buf = static_cast<uint8_t*>(std::aligned_alloc(4096, kBufSize + 64));
#endif

std::default_random_engine rng(1729); // Deterministic seed.
std::uniform_int_distribution<uint16_t> dist(0, 255);
Expand Down
2 changes: 1 addition & 1 deletion folly/io/async/test/AsyncSSLSocketTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ class HandshakeTimeoutCallback : public SSLServerAcceptCallbackBase {

hcb_->setSocket(sock);
sock->getEventBase()->tryRunAfterDelay(
[=, this] {
[=] {
std::cerr << "Delayed SSL accept, client will have close by now"
<< std::endl;
// SSL accept will fail
Expand Down
8 changes: 4 additions & 4 deletions folly/io/async/test/TestSSLServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ TestSSLServer::~TestSSLServer() {
/* static */ std::unique_ptr<SSLContext> TestSSLServer::getDefaultSSLContext() {
// Set up a default SSL context
std::unique_ptr<SSLContext> sslContext = std::make_unique<SSLContext>();
sslContext->loadCertificate(find_resource(kTestCert).c_str());
sslContext->loadPrivateKey(find_resource(kTestKey).c_str());
sslContext->loadCertificate(find_resource(kTestCert).string().c_str());
sslContext->loadPrivateKey(find_resource(kTestKey).string().c_str());
sslContext->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
// By default, SSLContext disables OpenSSL's internal session cache.
// Enable it here on the server for testing session reuse.
Expand All @@ -64,8 +64,8 @@ TestSSLServer::TestSSLServer(SSLServerAcceptCallbackBase* acb, bool enableTFO)
}

void TestSSLServer::loadTestCerts() {
ctx_->loadCertificate(find_resource(kTestCert).c_str());
ctx_->loadPrivateKey(find_resource(kTestKey).c_str());
ctx_->loadCertificate(find_resource(kTestCert).string().c_str());
ctx_->loadPrivateKey(find_resource(kTestKey).string().c_str());
}

TestSSLServer::TestSSLServer(
Expand Down
2 changes: 2 additions & 0 deletions folly/logging/test/GlogFormatterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ TEST(GlogFormatter, logThreadName) {
true /* logThreadName */));
}

#ifndef _WIN32
TEST(GlogFormatter, logThreadNameChanged) {
if (folly::canSetCurrentThreadName()) {
std::string msg;
Expand All @@ -129,6 +130,7 @@ TEST(GlogFormatter, logThreadNameChanged) {
EXPECT_EQ(expected, msg);
}
}
#endif

TEST(GlogFormatter, filename) {
auto tid = getOSThreadID();
Expand Down
4 changes: 2 additions & 2 deletions folly/synchronization/test/AtomicUtilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ struct AtomicFetchModifyTest : testing::Test {};

TEST_F(AtomicFetchModifyTest, example) {
constexpr auto prime255 = 1619;
constexpr auto op = [](auto _) { return (_ + 3) % prime255; };
constexpr auto op = [=](auto _) { return (_ + 3) % prime255; };
std::atomic<int> cell{2};
auto const prev = folly::atomic_fetch_modify(cell, op, relaxed);
EXPECT_EQ(2, prev);
Expand All @@ -602,7 +602,7 @@ TEST_F(AtomicFetchModifyTest, contention) {
}
return v;
};
constexpr auto op_ = [](auto _) { return (_ + 3) % prime255; };
constexpr auto op_ = [=](auto _) { return (_ + 3) % prime255; };

// run concurrent atomic-fetch-modify ops until enough contention is observed,
// where contention observed is ~ number of times an op is repeated
Expand Down
2 changes: 2 additions & 0 deletions folly/test/FBVectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ TEST(FBVector, overflowAssign) {
std::length_error);
}

#ifndef _MSC_VER
TEST(FBVector, zeroInit) {
// This is a higher-level version of TEST(Traits, zeroInit).
struct S1 {
Expand All @@ -323,3 +324,4 @@ TEST(FBVector, zeroInit) {
EXPECT_EQ(vec[0].mp_, nullptr);
EXPECT_EQ(vec[8].mp_, nullptr);
}
#endif
3 changes: 2 additions & 1 deletion folly/test/FileUtilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ TEST_F(WriteFileAtomic, multipleFiles) {
EXPECT_EQ(0440, getPerms(tmpPath("foo_txt")));
EXPECT_EQ(0444, getPerms(tmpPath("foo.txt2")));
}
#endif // !_WIN32

TEST_F(WriteFileAtomic, WriteWithCustomTempPath) {
auto path = fs::path{tmpDir_.path().string()} / fs::path{"file"};
Expand All @@ -570,6 +569,8 @@ TEST_F(WriteFileAtomic, WriteWithCustomTempPath) {
ASSERT_TRUE(success);
EXPECT_EQ(output, "data_2");
}
#endif // !_WIN32

} // namespace test
} // namespace folly

Expand Down
4 changes: 2 additions & 2 deletions folly/test/base64_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ namespace {
template <std::size_t N>
constexpr auto base64EncodeArray(const std::array<char, N>& in) {
std::array<char, folly::base64EncodedSize(N) + 1> res{};
folly::base64Encode(in.begin(), in.end(), res.data());
folly::base64Encode(in.data(), in.data() + in.size(), res.data());
res.back() = 0;
return res;
}

template <std::size_t N>
constexpr auto base64URLEncodeArray(const std::array<char, N>& in) {
std::array<char, folly::base64URLEncodedSize(N) + 1> res{};
folly::base64URLEncode(in.begin(), in.end(), res.data());
folly::base64URLEncode(in.data(), in.data() + in.size(), res.data());
res.back() = 0;
return res;
}
Expand Down

0 comments on commit aeeb2fa

Please sign in to comment.