1 //===- ErrnoTest.cpp - Error handling unit tests --------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Support/Errno.h"
11 #include "gtest/gtest.h"
13 using namespace llvm::sys
;
15 TEST(ErrnoTest
, RetryAfterSignal
) {
16 EXPECT_EQ(1, RetryAfterSignal(-1, [] { return 1; }));
18 EXPECT_EQ(-1, RetryAfterSignal(-1, [] {
22 EXPECT_EQ(EAGAIN
, errno
);
25 EXPECT_EQ(1, RetryAfterSignal(-1, [&calls
] {
28 return calls
== 1 ? -1 : 1;
32 EXPECT_EQ(1, RetryAfterSignal(-1, [](int x
) { return x
; }, 1));
34 std::unique_ptr
<int> P(RetryAfterSignal(nullptr, [] { return new int(47); }));
38 EXPECT_EQ(-1, RetryAfterSignal(-1, [] { return -1; }));