1c946d462SZachary Turner //===-- PythonTestSuite.cpp -------------------------------------*- C++ -*-===// 2c946d462SZachary Turner // 3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6c946d462SZachary Turner // 7c946d462SZachary Turner //===----------------------------------------------------------------------===// 8c946d462SZachary Turner 9b9c1b51eSKate Stone #include "gtest/gtest.h" 10c946d462SZachary Turner 11c946d462SZachary Turner #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" 1246376966SJonas Devlieghere #include "Plugins/ScriptInterpreter/Python/lldb-python.h" 1346376966SJonas Devlieghere #include "lldb/Host/FileSystem.h" 14b9c1b51eSKate Stone #include "lldb/Host/HostInfo.h" 15c946d462SZachary Turner 16c946d462SZachary Turner #include "PythonTestSuite.h" 17c946d462SZachary Turner 18c946d462SZachary Turner using namespace lldb_private; 19c946d462SZachary Turner 20b9c1b51eSKate Stone void PythonTestSuite::SetUp() { 2146376966SJonas Devlieghere FileSystem::Initialize(); 22c946d462SZachary Turner HostInfoBase::Initialize(); 23c946d462SZachary Turner // ScriptInterpreterPython::Initialize() depends on HostInfo being 24c946d462SZachary Turner // initializedso it can compute the python directory etc. 25c946d462SZachary Turner ScriptInterpreterPython::Initialize(); 2615d1b4e2SEnrico Granata ScriptInterpreterPython::InitializePrivate(); 27c946d462SZachary Turner 28c946d462SZachary Turner // Although we don't care about concurrency for the purposes of running 29c946d462SZachary Turner // this test suite, Python requires the GIL to be locked even for 30c946d462SZachary Turner // deallocating memory, which can happen when you call Py_DECREF or 31c946d462SZachary Turner // Py_INCREF. So acquire the GIL for the entire duration of this 32c946d462SZachary Turner // test suite. 33c946d462SZachary Turner m_gil_state = PyGILState_Ensure(); 34c946d462SZachary Turner } 35c946d462SZachary Turner 36b9c1b51eSKate Stone void PythonTestSuite::TearDown() { 37c946d462SZachary Turner PyGILState_Release(m_gil_state); 38c946d462SZachary Turner 39c946d462SZachary Turner ScriptInterpreterPython::Terminate(); 400bca15a3SJonas Devlieghere HostInfoBase::Terminate(); 410bca15a3SJonas Devlieghere FileSystem::Terminate(); 42c946d462SZachary Turner } 43