From 7479b9cb0e00e417282d29969f30e30cb5c44f8e Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Wed, 4 Sep 2019 08:02:52 +0000 Subject: [PATCH] [lldb][NFC] Add a simple test for thread_local storage. Seems we fail to read TLS data on Linux, so the test only runs on macOS for now. We will see how this test runs on the BSD bots. llvm-svn: 370848 --- .../test/lang/cpp/thread_local/Makefile | 3 +++ .../lang/cpp/thread_local/TestThreadLocal.py | 5 +++++ .../test/lang/cpp/thread_local/main.cpp | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile new file mode 100644 index 000000000000..99bfa7e03b47 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../make +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py new file mode 100644 index 000000000000..9f8ed89375eb --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py @@ -0,0 +1,5 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), + lldbinline.expectedFailureAll(oslist=["windows", "linux"])) diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp new file mode 100644 index 000000000000..1855b7c5f344 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp @@ -0,0 +1,17 @@ +int storage = 45; +thread_local int tl_global_int = 123; +thread_local int *tl_global_ptr = &storage; + +int main(int argc, char **argv) { + //% self.expect("expr tl_local_int", error=True, substrs=["couldn't get the value of variable tl_local_int"]) + //% self.expect("expr *tl_local_ptr", error=True, substrs=["couldn't get the value of variable tl_local_ptr"]) + thread_local int tl_local_int = 321; + thread_local int *tl_local_ptr = nullptr; + tl_local_ptr = &tl_local_int; + tl_local_int++; + //% self.expect("expr tl_local_int + 1", substrs=["int", "= 323"]) + //% self.expect("expr *tl_local_ptr + 2", substrs=["int", "= 324"]) + //% self.expect("expr tl_global_int", substrs=["int", "= 123"]) + //% self.expect("expr *tl_global_ptr", substrs=["int", "= 45"]) + return 0; +} -- 2.34.1