Commit 4bce7f6d authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Simplify some tests-in-loop in unit-tests

Summary: [Folly] Simplify a few cases of writing a loop to test each element of the loop in small-locks and spin-locks unit-tests.

Reviewed By: markisaa

Differential Revision: D20936029

fbshipit-source-id: fd8a922d8e7b0a00ccd524c9905c641fd97a32f9
parent ddcf8ada
......@@ -29,6 +29,7 @@
#include <folly/Random.h>
#include <folly/portability/Asm.h>
#include <folly/portability/GFlags.h>
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>
#include <folly/portability/PThread.h>
#include <folly/portability/Unistd.h>
......@@ -85,10 +86,7 @@ void splock_test() {
folly::asm_volatile_pause();
MSLGuard g(v.lock);
int first = v.ar[0];
for (size_t j = 1; j < sizeof v.ar / sizeof j; ++j) {
EXPECT_EQ(first, v.ar[j]);
}
EXPECT_THAT(v.ar, testing::Each(testing::Eq(v.ar[0])));
int byte = folly::Random::rand32(rng);
memset(v.ar, char(byte), sizeof v.ar);
......
......@@ -21,6 +21,7 @@
#include <thread>
#include <folly/portability/Asm.h>
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>
using folly::SpinLockGuardImpl;
......@@ -45,10 +46,7 @@ void spinlockTestThread(LockedVal<LOCK>* v) {
folly::asm_volatile_pause();
SpinLockGuardImpl<LOCK> g(v->lock);
int first = v->ar[0];
for (size_t j = 1; j < sizeof v->ar / sizeof j; ++j) {
EXPECT_EQ(first, v->ar[j]);
}
EXPECT_THAT(v->ar, testing::Each(testing::Eq(v->ar[0])));
int byte = folly::Random::rand32(rng);
memset(v->ar, char(byte), sizeof v->ar);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment