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