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 "gtest/gtest.h" 11 12 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" 13 #include "Plugins/ScriptInterpreter/Python/lldb-python.h" 14 #include "lldb/Host/FileSystem.h" 15 #include "lldb/Host/HostInfo.h" 16 17 #include "PythonTestSuite.h" 18 19 using namespace lldb_private; 20 21 void PythonTestSuite::SetUp() { 22 FileSystem::Initialize(); 23 HostInfoBase::Initialize(); 24 // ScriptInterpreterPython::Initialize() depends on HostInfo being 25 // initializedso it can compute the python directory etc. 26 ScriptInterpreterPython::Initialize(); 27 ScriptInterpreterPython::InitializePrivate(); 28 29 // Although we don't care about concurrency for the purposes of running 30 // this test suite, Python requires the GIL to be locked even for 31 // deallocating memory, which can happen when you call Py_DECREF or 32 // Py_INCREF. So acquire the GIL for the entire duration of this 33 // test suite. 34 m_gil_state = PyGILState_Ensure(); 35 } 36 37 void PythonTestSuite::TearDown() { 38 PyGILState_Release(m_gil_state); 39 40 ScriptInterpreterPython::Terminate(); 41 } 42