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