1c946d462SZachary Turner //===-- PythonTestSuite.cpp -------------------------------------*- C++ -*-===// 2c946d462SZachary Turner // 3c946d462SZachary Turner // The LLVM Compiler Infrastructure 4c946d462SZachary Turner // 5c946d462SZachary Turner // This file is distributed under the University of Illinois Open Source 6c946d462SZachary Turner // License. See LICENSE.TXT for details. 7c946d462SZachary Turner // 8c946d462SZachary Turner //===----------------------------------------------------------------------===// 9c946d462SZachary Turner 108c68837dSPavel Labath #include "Plugins/ScriptInterpreter/Python/lldb-python.h" 11*b9c1b51eSKate Stone #include "gtest/gtest.h" 12c946d462SZachary Turner 13c946d462SZachary Turner #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" 14*b9c1b51eSKate Stone #include "lldb/Host/HostInfo.h" 15c946d462SZachary Turner 16c946d462SZachary Turner #include "PythonTestSuite.h" 17c946d462SZachary Turner 18c946d462SZachary Turner using namespace lldb_private; 19c946d462SZachary Turner 20*b9c1b51eSKate Stone void PythonTestSuite::SetUp() { 21c946d462SZachary Turner HostInfoBase::Initialize(); 22c946d462SZachary Turner // ScriptInterpreterPython::Initialize() depends on HostInfo being 23c946d462SZachary Turner // initializedso it can compute the python directory etc. 24c946d462SZachary Turner ScriptInterpreterPython::Initialize(); 2515d1b4e2SEnrico Granata ScriptInterpreterPython::InitializePrivate(); 26c946d462SZachary Turner 27c946d462SZachary Turner // Although we don't care about concurrency for the purposes of running 28c946d462SZachary Turner // this test suite, Python requires the GIL to be locked even for 29c946d462SZachary Turner // deallocating memory, which can happen when you call Py_DECREF or 30c946d462SZachary Turner // Py_INCREF. So acquire the GIL for the entire duration of this 31c946d462SZachary Turner // test suite. 32c946d462SZachary Turner m_gil_state = PyGILState_Ensure(); 33c946d462SZachary Turner } 34c946d462SZachary Turner 35*b9c1b51eSKate Stone void PythonTestSuite::TearDown() { 36c946d462SZachary Turner PyGILState_Release(m_gil_state); 37c946d462SZachary Turner 38c946d462SZachary Turner ScriptInterpreterPython::Terminate(); 39c946d462SZachary Turner } 40