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 
10b9c1b51eSKate Stone #include "gtest/gtest.h"
11c946d462SZachary Turner 
12c946d462SZachary Turner #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
1346376966SJonas Devlieghere #include "Plugins/ScriptInterpreter/Python/lldb-python.h"
1446376966SJonas Devlieghere #include "lldb/Host/FileSystem.h"
15b9c1b51eSKate Stone #include "lldb/Host/HostInfo.h"
16c946d462SZachary Turner 
17c946d462SZachary Turner #include "PythonTestSuite.h"
18c946d462SZachary Turner 
19c946d462SZachary Turner using namespace lldb_private;
20c946d462SZachary Turner 
21b9c1b51eSKate Stone void PythonTestSuite::SetUp() {
2246376966SJonas Devlieghere   FileSystem::Initialize();
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 
37b9c1b51eSKate Stone void PythonTestSuite::TearDown() {
38c946d462SZachary Turner   PyGILState_Release(m_gil_state);
39c946d462SZachary Turner 
40c946d462SZachary Turner   ScriptInterpreterPython::Terminate();
41*0bca15a3SJonas Devlieghere   HostInfoBase::Terminate();
42*0bca15a3SJonas Devlieghere   FileSystem::Terminate();
43c946d462SZachary Turner }
44