mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpiutil] Vendor llvm and update to 13.0.0 (#4224)
This commit is contained in:
38
wpiutil/src/test/native/cpp/llvm/ErrnoTest.cpp
Normal file
38
wpiutil/src/test/native/cpp/llvm/ErrnoTest.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//===- ErrnoTest.cpp - Error handling unit tests --------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "wpi/Errno.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace wpi::sys;
|
||||
|
||||
TEST(ErrnoTest, RetryAfterSignal) {
|
||||
EXPECT_EQ(1, RetryAfterSignal(-1, [] { return 1; }));
|
||||
|
||||
EXPECT_EQ(-1, RetryAfterSignal(-1, [] {
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}));
|
||||
EXPECT_EQ(EAGAIN, errno);
|
||||
|
||||
unsigned calls = 0;
|
||||
EXPECT_EQ(1, RetryAfterSignal(-1, [&calls] {
|
||||
errno = EINTR;
|
||||
++calls;
|
||||
return calls == 1 ? -1 : 1;
|
||||
}));
|
||||
EXPECT_EQ(2u, calls);
|
||||
|
||||
EXPECT_EQ(1, RetryAfterSignal(-1, [](int x) { return x; }, 1));
|
||||
|
||||
std::unique_ptr<int> P(RetryAfterSignal(nullptr, [] { return new int(47); }));
|
||||
EXPECT_EQ(47, *P);
|
||||
|
||||
errno = EINTR;
|
||||
EXPECT_EQ(-1, RetryAfterSignal(-1, [] { return -1; }));
|
||||
}
|
||||
Reference in New Issue
Block a user