aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/tutorial/threads/threads_test.cpp
blob: 36696561165d9965187fb50e539f0b870e1266fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>

TEST_MT_F("multiple threads", 2, std::vector<size_t>(num_threads)) {
    ASSERT_EQUAL(num_threads, f1.size());
    f1[thread_id] = thread_id;
    TEST_BARRIER();
    if (thread_id == 0) {
        TEST_TRACE();
        EXPECT_EQUAL(1u, f1[1]);
    } else {
        TEST_TRACE();
        EXPECT_EQUAL(0u, f1[0]);
    }
}

TEST_MAIN() { TEST_RUN_ALL(); }