1*d0810779SPavel Labath //===-- ThreadLauncherTest.cpp --------------------------------------------===// 2*d0810779SPavel Labath // 3*d0810779SPavel Labath // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*d0810779SPavel Labath // See https://llvm.org/LICENSE.txt for license information. 5*d0810779SPavel Labath // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*d0810779SPavel Labath // 7*d0810779SPavel Labath //===----------------------------------------------------------------------===// 8*d0810779SPavel Labath 9*d0810779SPavel Labath #include "lldb/Host/ThreadLauncher.h" 10*d0810779SPavel Labath #include "llvm/Testing/Support/Error.h" 11*d0810779SPavel Labath #include "gtest/gtest.h" 12*d0810779SPavel Labath #include <future> 13*d0810779SPavel Labath 14*d0810779SPavel Labath using namespace lldb_private; 15*d0810779SPavel Labath TEST(ThreadLauncherTest,LaunchThread)16*d0810779SPavel LabathTEST(ThreadLauncherTest, LaunchThread) { 17*d0810779SPavel Labath std::promise<int> promise; 18*d0810779SPavel Labath std::future<int> future = promise.get_future(); 19*d0810779SPavel Labath llvm::Expected<HostThread> thread = 20*d0810779SPavel Labath ThreadLauncher::LaunchThread("test", [&promise] { 21*d0810779SPavel Labath promise.set_value(47); 22*d0810779SPavel Labath return (lldb::thread_result_t)47; 23*d0810779SPavel Labath }); 24*d0810779SPavel Labath ASSERT_THAT_EXPECTED(thread, llvm::Succeeded()); 25*d0810779SPavel Labath EXPECT_EQ(future.get(), 47); 26*d0810779SPavel Labath lldb::thread_result_t result; 27*d0810779SPavel Labath thread->Join(&result); 28*d0810779SPavel Labath EXPECT_EQ(result, (lldb::thread_result_t)47); 29*d0810779SPavel Labath } 30