Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix build and test.

Summary:
Fix bug in FBStringTest (don't reuse the same file name)

Don't use VLOG, as that requires that glog is compiled with gflags
support, which it isn't always.

Add other targets and tests, make all tests pass.

Test Plan: tests

Reviewed By: delong.j@fb.com

FB internal diff: D493018
  • Loading branch information...
commit 966000458dcdda8259e053d5be51e3051295ae3d 1 parent 987da6d
@tudor tudor authored
View
130 folly/Makefile.am
@@ -2,84 +2,118 @@ SUBDIRS = . test
ACLOCAL_AMFLAGS = -I m4
+noinst_PROGRAMS = generate_fingerprint_tables
+generate_fingerprint_tables_SOURCES = build/GenerateFingerprintTables.cpp
+generate_fingerprint_tables_LDADD = libfolly.la
+
lib_LTLIBRARIES = \
libfolly.la \
libfollybenchmark.la \
- libfollytimeout_queue.la
+ libfollytimeout_queue.la \
+ libfollyfingerprint.la
follyincludedir = $(includedir)/folly
nobase_follyinclude_HEADERS = \
- FBVector.h \
- detail/ThreadLocalDetail.h \
- detail/DiscriminatedPtrDetail.h \
+ Arena.h \
+ Arena-inl.h \
+ AtomicHashArray.h \
+ AtomicHashArray-inl.h \
+ AtomicHashMap.h \
+ AtomicHashMap-inl.h \
+ Benchmark.h \
+ Bits.h \
+ ConcurrentSkipList.h \
+ ConcurrentSkipList-inl.h \
+ Conv.h \
detail/AtomicHashUtils.h \
detail/BitIteratorDetail.h \
+ detail/DiscriminatedPtrDetail.h \
+ detail/FingerprintPolynomial.h \
detail/GroupVarintDetail.h \
- IntrusiveList.h \
- TimeoutQueue.h \
- String.h \
- PackedSyncPtr.h \
- Conv.h \
- ThreadLocal.h \
- ProducerConsumerQueue.h \
- Histogram-inl.h \
- ThreadCachedInt.h \
- ConcurrentSkipList.h \
- json.h \
- folly-config.h \
- FBString.h \
- Unicode.h \
- test/function_benchmark/test_functions.h \
- test/function_benchmark/benchmark_impl.h \
- test/FBStringTestBenchmarks.cpp.h \
- test/SynchronizedTestLib.h \
- test/FBVectorTestBenchmarks.cpp.h \
- test/SynchronizedTestLib-inl.h \
- Synchronized.h \
- Malloc.h \
+ detail/SlowFingerprint.h \
+ detail/ThreadLocalDetail.h \
+ DiscriminatedPtr.h \
dynamic.h \
- AtomicHashArray.h \
dynamic-inl.h \
- Bits.h \
- sorted_vector_types.h \
- Hash.h \
- DiscriminatedPtr.h \
- ConcurrentSkipList-inl.h \
- Random.h \
+ eventfd.h \
+ FBString.h \
+ FBVector.h \
+ Fingerprint.h \
+ folly-config.h \
+ Foreach.h \
+ FormatArg.h \
+ Format.h \
+ Format-inl.h \
GroupVarint.h \
- Range.h \
- Benchmark.h \
- Likely.h \
+ Hash.h \
Histogram.h \
- AtomicHashMap.h \
+ Histogram-inl.h \
+ IntrusiveList.h \
+ json.h \
+ Likely.h \
+ Malloc.h \
+ MapUtil.h \
+ PackedSyncPtr.h \
Portability.h \
- AtomicHashArray-inl.h \
- eventfd.h \
- SmallLocks.h \
- ScopeGuard.h \
- Traits.h \
+ Preprocessor.h \
+ ProducerConsumerQueue.h \
+ Random.h \
+ Range.h \
RWSpinLock.h \
+ ScopeGuard.h \
+ SmallLocks.h \
small_vector.h \
- Foreach.h \
- AtomicHashMap-inl.h \
- MapUtil.h
+ sorted_vector_types.h \
+ StlAllocator.h \
+ String.h \
+ String-inl.h \
+ Synchronized.h \
+ test/FBStringTestBenchmarks.cpp.h \
+ test/FBVectorTestBenchmarks.cpp.h \
+ test/function_benchmark/benchmark_impl.h \
+ test/function_benchmark/test_functions.h \
+ test/SynchronizedTestLib.h \
+ test/SynchronizedTestLib-inl.h \
+ ThreadCachedArena.h \
+ ThreadCachedInt.h \
+ ThreadLocal.h \
+ TimeoutQueue.h \
+ Traits.h \
+ Unicode.h
FormatTables.cpp: build/generate_format_tables.py
build/generate_format_tables.py
+EscapeTables.cpp: build/generate_escape_tables.py
+ build/generate_escape_tables.py
+
+GroupVarintTables.cpp: build/generate_varint_tables.py
+ build/generate_varint_tables.py
+
libfolly_la_SOURCES = \
Random.cpp \
Range.cpp \
Unicode.cpp \
Conv.cpp \
- Format.cpp \
- FormatTables.cpp \
- String.cpp \
json.cpp \
dynamic.cpp \
+ GroupVarint.cpp \
+ GroupVarintTables.cpp \
+ EscapeTables.cpp \
+ ThreadCachedArena.cpp \
+ Format.cpp \
+ FormatTables.cpp \
+ String.cpp
+
libfolly_la_LIBADD = $(BOOST_THREAD_LIBS) -lpthread
+FingerprintTables.cpp: generate_fingerprint_tables
+ ./generate_fingerprint_tables
+
+libfollyfingerprint_la_SOURCES = \
+ FingerprintTables.cpp
+
libfollybenchmark_la_SOURCES = Benchmark.cpp
libfollybenchmark_la_LIBADD = -lboost_regex -lpthread -lrt
View
32 folly/test/ConcurrentSkipListBenchmark.cpp
@@ -18,9 +18,9 @@
#include <map>
#include <set>
+#include <thread>
#include <boost/shared_ptr.hpp>
-#include <boost/thread.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
@@ -77,7 +77,7 @@ void BM_IterateOverSet(int iters, int size) {
if (iter == a_set.end()) iter = a_set.begin();
}
BENCHMARK_SUSPEND {
- VLOG(20) << "sum = " << sum;
+ // VLOG(20) << "sum = " << sum;
}
}
@@ -98,7 +98,7 @@ void BM_IterateSkipList(int iters, int size) {
}
BENCHMARK_SUSPEND {
- VLOG(20) << "sum = " << sum;
+ // VLOG(20) << "sum = " << sum;
}
}
@@ -119,7 +119,7 @@ void BM_SetMerge(int iters, int size) {
if (b_set.find(*it) != b_set.end()) mergedSum += *it;
}
BENCHMARK_SUSPEND {
- VLOG(20) << mergedSum;
+ // VLOG(20) << mergedSum;
}
}
@@ -143,7 +143,7 @@ void BM_CSLMergeLookup(int iters, int size) {
}
BENCHMARK_SUSPEND {
- VLOG(20) << mergedSum;
+ // VLOG(20) << mergedSum;
}
}
@@ -180,7 +180,7 @@ void BM_CSLMergeIntersection(int iters, int size) {
}
BENCHMARK_SUSPEND {
- VLOG(20) << mergedSum;
+ // VLOG(20) << mergedSum;
}
}
@@ -199,7 +199,7 @@ void BM_SetContainsNotFound(int iters, int size) {
}
BENCHMARK_SUSPEND {
- VLOG(20) << sum;
+ // VLOG(20) << sum;
}
}
@@ -224,7 +224,7 @@ void BM_SetContainsFound(int iters, int size) {
}
BENCHMARK_SUSPEND {
- VLOG(20) << sum;
+ // VLOG(20) << sum;
}
}
@@ -248,7 +248,7 @@ void BM_CSLContainsFound(int iters, int size) {
}
BENCHMARK_SUSPEND {
- VLOG(20) << sum;
+ // VLOG(20) << sum;
}
}
@@ -268,7 +268,7 @@ void BM_CSLContainsNotFound(int iters, int size) {
}
BENCHMARK_SUSPEND {
- VLOG(20) << sum;
+ // VLOG(20) << sum;
}
}
@@ -410,7 +410,7 @@ class ConcurrentAccessData {
for (int i = 0; i < iters; ++i) {
sum += accessSkipList(id, i);
}
- VLOG(20) << sum;
+ // VLOG(20) << sum;
}
void runSet(int id, int iters) {
@@ -418,7 +418,7 @@ class ConcurrentAccessData {
for (int i = 0; i < iters; ++i) {
sum += accessSet(id, i);
}
- VLOG(20) << sum;
+ // VLOG(20) << sum;
}
bool accessSkipList(int64_t id, int t) {
@@ -484,11 +484,11 @@ static ConcurrentAccessData *mayInitTestData(int size) {
void BM_ContentionCSL(int iters, int size) {
BenchmarkSuspender susp;
auto data = mayInitTestData(size);
- std::vector<boost::thread> threads;
+ std::vector<std::thread> threads;
susp.dismiss();
for (int i = 0; i < FLAGS_num_threads; ++i) {
- threads.push_back(boost::thread(
+ threads.push_back(std::thread(
&ConcurrentAccessData::runSkipList, data, i, iters));
}
FOR_EACH(t, threads) {
@@ -499,11 +499,11 @@ void BM_ContentionCSL(int iters, int size) {
void BM_ContentionStdSet(int iters, int size) {
BenchmarkSuspender susp;
auto data = mayInitTestData(size);
- std::vector<boost::thread> threads;
+ std::vector<std::thread> threads;
susp.dismiss();
for (int i = 0; i < FLAGS_num_threads; ++i) {
- threads.push_back(boost::thread(
+ threads.push_back(std::thread(
&ConcurrentAccessData::runSet, data, i, iters));
}
FOR_EACH(t, threads) {
View
20 folly/test/ConcurrentSkipListTest.cpp
@@ -18,7 +18,7 @@
#include <set>
#include <vector>
-#include <boost/thread.hpp>
+#include <thread>
#include <glog/logging.h>
#include <gflags/gflags.h>
@@ -208,10 +208,10 @@ TEST(ConcurrentSkipList, SequentialAccess) {
void testConcurrentAdd(int numThreads) {
auto skipList(SkipListType::create(kHeadHeight));
- vector<boost::thread> threads;
+ vector<std::thread> threads;
vector<SetType> verifiers(numThreads);
for (int i = 0; i < numThreads; ++i) {
- threads.push_back(boost::thread(
+ threads.push_back(std::thread(
&randomAdding, 100, skipList, &verifiers[i], kMaxValue));
}
for (int i = 0; i < threads.size(); ++i) {
@@ -238,10 +238,10 @@ void testConcurrentRemoval(int numThreads, int maxValue) {
skipList.add(i);
}
- vector<boost::thread> threads;
+ vector<std::thread> threads;
vector<SetType > verifiers(numThreads);
for (int i = 0; i < numThreads; ++i) {
- threads.push_back(boost::thread(
+ threads.push_back(std::thread(
&randomRemoval, 100, skipList, &verifiers[i], maxValue));
}
FOR_EACH(t, threads) {
@@ -284,24 +284,24 @@ static void testConcurrentAccess(
std::sort(skipValues[i].begin(), skipValues[i].end());
}
- vector<boost::thread> threads;
+ vector<std::thread> threads;
for (int i = 0; i < FLAGS_num_threads; ++i) {
switch (i % 8) {
case 0:
case 1:
- threads.push_back(boost::thread(
+ threads.push_back(std::thread(
randomAdding, numInsertions, skipList, &verifiers[i], maxValue));
break;
case 2:
- threads.push_back(boost::thread(
+ threads.push_back(std::thread(
randomRemoval, numDeletions, skipList, &verifiers[i], maxValue));
break;
case 3:
- threads.push_back(boost::thread(
+ threads.push_back(std::thread(
concurrentSkip, &skipValues[i], skipList));
break;
default:
- threads.push_back(boost::thread(sumAllValues, skipList, &sums[i]));
+ threads.push_back(std::thread(sumAllValues, skipList, &sums[i]));
break;
}
}
View
22 folly/test/FBStringTest.cpp
@@ -19,6 +19,8 @@
#include "folly/FBString.h"
+#include <cstdlib>
+
#include <list>
#include <fstream>
#include <boost/algorithm/string.hpp>
@@ -879,8 +881,11 @@ massa, ut accumsan magna. Donec imperdiet tempor nisi et \n\
laoreet. Phasellus lectus quam, ultricies ut tincidunt in, dignissim \n\
id eros. Mauris vulputate tortor nec neque pellentesque sagittis quis \n\
sed nisl. In diam lacus, lobortis ut posuere nec, ornare id quam.";
- const char* f = "/tmp/fbstring_testing";
- {
+ char f[] = "/tmp/fbstring_testing.XXXXXX";
+ int fd = mkstemp(f);
+ EXPECT_TRUE(fd > 0);
+ if (fd > 0) {
+ close(fd); // Yeah
std::ofstream out(f);
if (!(out << s1)) {
EXPECT_TRUE(0) << "Couldn't write to temp file.";
@@ -889,12 +894,15 @@ sed nisl. In diam lacus, lobortis ut posuere nec, ornare id quam.";
}
vector<fbstring> v;
boost::split(v, s1, boost::is_any_of("\n"));
- ifstream input(f);
- fbstring line;
- FOR_EACH (i, v) {
- EXPECT_TRUE(getline(input, line));
- EXPECT_EQ(line, *i);
+ {
+ ifstream input(f);
+ fbstring line;
+ FOR_EACH (i, v) {
+ EXPECT_TRUE(getline(input, line));
+ EXPECT_EQ(line, *i);
+ }
}
+ unlink(f);
}
TEST(FBString, testMoveCtor) {
View
63 folly/test/Makefile.am
@@ -14,10 +14,14 @@ TESTS= \
bits_test \
bit_iterator_test
-lib_LTLIBRARIES = libgtestmain.la
+lib_LTLIBRARIES = libgtestmain.la libgtest.la
+
libgtestmain_la_CPPFLAGS = -Igtest-1.6.0 -Igtest-1.6.0/src
libgtestmain_la_SOURCES = gtest-1.6.0/src/gtest-all.cc gtest-1.6.0/src/gtest_main.cc
+libgtest_la_CPPFLAGS = -Igtest-1.6.0 -Igtest-1.6.0/src
+libgtest_la_SOURCES = gtest-1.6.0/src/gtest-all.cc
+
noinst_HEADERS = FBStringTestBenchmarks.cpp.h \
FBVectorTestBenchmarks.cpp.h
@@ -109,23 +113,56 @@ endian_test_SOURCES = EndianTest.cpp
endian_test_LDADD = libgtestmain.la $(top_builddir)/libfolly.la
TESTS += endian_test
-# needs externals/glog to use third-party glog
-# rw_spinlock_test_SOURCES = RWSpinLockTest.cpp
-# rw_spinlock_test_LDADD = libgtestmain.la $(top_builddir)/libfollybenchmark.la $(top_builddir)/libfolly.la $(BOOST_THREAD_LIBS)
-# TESTS += rw_spinlock_test
+rw_spinlock_test_SOURCES = RWSpinLockTest.cpp
+rw_spinlock_test_LDADD = libgtestmain.la $(top_builddir)/libfollybenchmark.la $(top_builddir)/libfolly.la $(BOOST_THREAD_LIBS)
+TESTS += rw_spinlock_test
synchronized_test_SOURCES = SynchronizedTest.cpp
synchronized_test_LDADD = libgtestmain.la $(top_builddir)/libfolly.la
TESTS += synchronized_test
-# needs externals/glog to use third-party glog
-# concurrent_skiplist_test_SOURCES = ConcurrentSkipListTest.cpp
-# concurrent_skiplist_test_LDADD = libgtestmain.la $(top_builddir)/libfolly.la
-# TESTS += concurrent_skiplist_test
+concurrent_skiplist_test_SOURCES = ConcurrentSkipListTest.cpp
+concurrent_skiplist_test_LDADD = libgtest.la $(top_builddir)/libfolly.la
+TESTS += concurrent_skiplist_test
+
+concurrent_skiplist_benchmark_SOURCES = ConcurrentSkipListBenchmark.cpp
+concurrent_skiplist_benchmark_LDADD = $(top_builddir)/libfollybenchmark.la $(top_builddir)/libfolly.la $(BOOST_THREAD_LIBS)
+noinst_PROGRAMS += concurrent_skiplist_benchmark
+
+histogram_test_SOURCES = HistogramTest.cpp
+histogram_test_LDADD = libgtestmain.la $(top_builddir)/libfolly.la
+TESTS += histogram_test
+
+group_varint_test_SOURCES = GroupVarintTest.cpp
+group_varint_test_LDADD = libgtestmain.la $(top_builddir)/libfolly.la
+TESTS += group_varint_test
+
+map_util_test_SOURCES = MapUtilTest.cpp
+map_util_test_LDADD = libgtestmain.la $(top_builddir)/libfolly.la
+TESTS += map_util_test
+
+string_test_SOURCES = StringTest.cpp
+string_test_LDADD = libgtest.la $(top_builddir)/libfolly.la $(top_builddir)/libfollybenchmark.la
+TESTS += string_test
+
+producer_consumer_queue_test_SOURCES = ProducerConsumerQueueTest.cpp
+producer_consumer_queue_test_LDADD = libgtestmain.la $(top_builddir)/libfolly.la
+TESTS += producer_consumer_queue_test
+
+atomic_hash_array_test_SOURCES = AtomicHashArrayTest.cpp
+atomic_hash_array_test_LDADD = libgtestmain.la $(top_builddir)/libfolly.la
+TESTS += atomic_hash_array_test
+
+atomic_hash_map_test_SOURCES = AtomicHashMapTest.cpp
+atomic_hash_map_test_LDADD = libgtest.la $(top_builddir)/libfolly.la $(top_builddir)/libfollybenchmark.la
+TESTS += atomic_hash_map_test
+
+format_test_SOURCES = FormatTest.cpp
+format_test_LDADD = libgtest.la $(top_builddir)/libfolly.la $(top_builddir)/libfollybenchmark.la
+TESTS += format_test
-# needs externals/glog to use third-party glog
-# concurrent_skiplist_benchmark_SOURCES = ConcurrentSkipListBenchmark.cpp
-# concurrent_skiplist_benchmark_LDADD = libgtestmain.la $(top_builddir)/libfollybenchmark.la $(top_builddir)/libfolly.la $(BOOST_THREAD_LIBS)
-# noinst_PROGRAMS += concurrent_skiplist_benchmark
+fingerprint_test_SOURCES = FingerprintTest.cpp
+fingerprint_test_LDADD = libgtest.la $(top_builddir)/libfolly.la $(top_builddir)/libfollyfingerprint.la $(top_builddir)/libfollybenchmark.la
+TESTS += fingerprint_test
check_PROGRAMS= $(TESTS)
View
13 folly/test/RWSpinLockTest.cpp
@@ -21,8 +21,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <vector>
-
-#include <boost/thread.hpp>
+#include <thread>
#include "gtest/gtest.h"
#include <gflags/gflags.h>
@@ -66,7 +65,7 @@ static void run(RWSpinLockType* lock) {
++reads;
}
}
- VLOG(0) << "total reads: " << reads << "; total writes: " << writes;
+ // VLOG(0) << "total reads: " << reads << "; total writes: " << writes;
}
@@ -152,9 +151,9 @@ TYPED_TEST(RWSpinLockTest, ConcurrentTests) {
RWSpinLockType l;
srand(time(NULL));
- std::vector<boost::thread> threads;
+ std::vector<std::thread> threads;
for (int i = 0; i < FLAGS_num_threads; ++i) {
- threads.push_back(boost::thread(&run<RWSpinLockType>, &l));
+ threads.push_back(std::thread(&run<RWSpinLockType>, &l));
}
sleep(1);
@@ -223,9 +222,9 @@ TEST(RWSpinLock, concurrent_holder_test) {
}
};
- std::vector<boost::thread> threads;
+ std::vector<std::thread> threads;
for (int i = 0; i < FLAGS_num_threads; ++i) {
- threads.push_back(boost::thread(go));
+ threads.push_back(std::thread(go));
}
sleep(5);
Please sign in to comment.
Something went wrong with that request. Please try again.