aboutsummaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:39 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:39 +0000
commitd2d3ebb81992e107edf95c1c136d7a342d9b1418 (patch)
treebb1af8fff2b1400cf240e3b2532a1e5d22a121da /unittests
parent16787c9ce0b96aaa669d7fab3a495916b35ce758 (diff)
downloadsrc-d2d3ebb81992e107edf95c1c136d7a342d9b1418.tar.gz
src-d2d3ebb81992e107edf95c1c136d7a342d9b1418.zip
Vendor import of lld trunk r300422:vendor/lld/lld-trunk-r300422
Notes
Notes: svn path=/vendor/lld/dist/; revision=317025 svn path=/vendor/lld/lld-trunk-r300422/; revision=317026; tag=vendor/lld/lld-trunk-r300422
Diffstat (limited to 'unittests')
-rw-r--r--unittests/CoreTests/CMakeLists.txt2
-rw-r--r--unittests/CoreTests/ParallelTest.cpp15
2 files changed, 16 insertions, 1 deletions
diff --git a/unittests/CoreTests/CMakeLists.txt b/unittests/CoreTests/CMakeLists.txt
index 98405d5c73a1..72e7c443f8cd 100644
--- a/unittests/CoreTests/CMakeLists.txt
+++ b/unittests/CoreTests/CMakeLists.txt
@@ -3,5 +3,5 @@ add_lld_unittest(CoreTests
)
target_link_libraries(CoreTests
- ${PTHREAD_LIB}
+ ${LLVM_PTHREAD_LIB}
)
diff --git a/unittests/CoreTests/ParallelTest.cpp b/unittests/CoreTests/ParallelTest.cpp
index c0282437e2e1..bd8507026a07 100644
--- a/unittests/CoreTests/ParallelTest.cpp
+++ b/unittests/CoreTests/ParallelTest.cpp
@@ -29,3 +29,18 @@ TEST(Parallel, sort) {
lld::parallel_sort(std::begin(array), std::end(array));
ASSERT_TRUE(std::is_sorted(std::begin(array), std::end(array)));
}
+
+TEST(Parallel, parallel_for) {
+ // We need to test the case with a TaskSize > 1. We are white-box testing
+ // here. The TaskSize is calculated as (End - Begin) / 1024 at the time of
+ // writing.
+ uint32_t range[2050];
+ std::fill(range, range + 2050, 1);
+ lld::parallel_for(0, 2049, [&range](size_t I) { ++range[I]; });
+
+ uint32_t expected[2049];
+ std::fill(expected, expected + 2049, 2);
+ ASSERT_TRUE(std::equal(range, range + 2049, expected));
+ // Check that we don't write past the end of the requested range.
+ ASSERT_EQ(range[2049], 1u);
+}