[compiler-rt] r289501 - [XRay][compiler-rt] Use explicit comparisons in unit tests.
Dean Michael Berris via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 16:17:31 PST 2016
Author: dberris
Date: Mon Dec 12 18:17:31 2016
New Revision: 289501
URL: http://llvm.org/viewvc/llvm-project?rev=289501&view=rev
Log:
[XRay][compiler-rt] Use explicit comparisons in unit tests.
Summary:
This should improve the error messages generated providing a bit more
information when the failures are printed out. One example of a
contrived error looks like:
```
Expected: (Buffers.getBuffer(Buf)) != (std::error_code()), actual:
system:0 vs system:0
```
Because we're using error codes, the default printing gets us more
useful information in case of failure.
This is a follow-up on D26232.
Reviewers: rSerge
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D27495
Modified:
compiler-rt/trunk/lib/xray/tests/unit/buffer_queue_test.cc
Modified: compiler-rt/trunk/lib/xray/tests/unit/buffer_queue_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/tests/unit/buffer_queue_test.cc?rev=289501&r1=289500&r2=289501&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/tests/unit/buffer_queue_test.cc (original)
+++ compiler-rt/trunk/lib/xray/tests/unit/buffer_queue_test.cc Mon Dec 12 18:17:31 2016
@@ -14,6 +14,7 @@
#include "gtest/gtest.h"
#include <future>
+#include <system_error>
#include <unistd.h>
namespace __xray {
@@ -25,19 +26,19 @@ TEST(BufferQueueTest, API) { BufferQueue
TEST(BufferQueueTest, GetAndRelease) {
BufferQueue Buffers(kSize, 1);
BufferQueue::Buffer Buf;
- ASSERT_FALSE(Buffers.getBuffer(Buf));
+ ASSERT_EQ(Buffers.getBuffer(Buf), std::error_code());
ASSERT_NE(nullptr, Buf.Buffer);
- ASSERT_FALSE(Buffers.releaseBuffer(Buf));
+ ASSERT_EQ(Buffers.releaseBuffer(Buf), std::error_code());
ASSERT_EQ(nullptr, Buf.Buffer);
}
TEST(BufferQueueTest, GetUntilFailed) {
BufferQueue Buffers(kSize, 1);
BufferQueue::Buffer Buf0;
- EXPECT_FALSE(Buffers.getBuffer(Buf0));
+ EXPECT_EQ(Buffers.getBuffer(Buf0), std::error_code());
BufferQueue::Buffer Buf1;
EXPECT_EQ(std::errc::not_enough_memory, Buffers.getBuffer(Buf1));
- EXPECT_FALSE(Buffers.releaseBuffer(Buf0));
+ EXPECT_EQ(Buffers.releaseBuffer(Buf0), std::error_code());
}
TEST(BufferQueueTest, ReleaseUnknown) {
@@ -51,13 +52,13 @@ TEST(BufferQueueTest, ReleaseUnknown) {
TEST(BufferQueueTest, ErrorsWhenFinalising) {
BufferQueue Buffers(kSize, 2);
BufferQueue::Buffer Buf;
- ASSERT_FALSE(Buffers.getBuffer(Buf));
+ ASSERT_EQ(Buffers.getBuffer(Buf), std::error_code());
ASSERT_NE(nullptr, Buf.Buffer);
- ASSERT_FALSE(Buffers.finalize());
+ ASSERT_EQ(Buffers.finalize(), std::error_code());
BufferQueue::Buffer OtherBuf;
ASSERT_EQ(std::errc::state_not_recoverable, Buffers.getBuffer(OtherBuf));
ASSERT_EQ(std::errc::state_not_recoverable, Buffers.finalize());
- ASSERT_FALSE(Buffers.releaseBuffer(Buf));
+ ASSERT_EQ(Buffers.releaseBuffer(Buf), std::error_code());
}
TEST(BufferQueueTest, MultiThreaded) {
More information about the llvm-commits
mailing list