|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | *
|
4 | 4 | * This program is free software; you can redistribute it and/or modify
|
5 | 5 | * it under the terms of the GNU General Public License, version 2.0,
|
@@ -125,83 +125,6 @@ std::map<std::string, std::string> load_test_case_info() {
|
125 | 125 | return load_info(current_recording_dir() + "/info");
|
126 | 126 | }
|
127 | 127 |
|
128 |
| -static std::list<std::weak_ptr<mysqlshdk::db::ISession>> g_open_sessions; |
129 |
| - |
130 |
| -static void on_session_connect( |
131 |
| - std::shared_ptr<mysqlshdk::db::ISession> session) { |
132 |
| - // called by session recorder classes when connect is called |
133 |
| - // adds a weak ptr to the session object along with the stack trace |
134 |
| - // to a list of open sessions, which will be checked when the test finishes |
135 |
| - g_open_sessions.push_back(session); |
136 |
| -} |
137 |
| - |
138 |
| -static void on_session_close(std::shared_ptr<mysqlshdk::db::ISession> session) { |
139 |
| - // called by session recorder classes when close is called |
140 |
| - for (auto iter = g_open_sessions.begin(); iter != g_open_sessions.end(); |
141 |
| - ++iter) { |
142 |
| - auto ptr = iter->lock(); |
143 |
| - if (ptr && ptr.get() == session.get()) { |
144 |
| - g_open_sessions.erase(iter); |
145 |
| - break; |
146 |
| - } |
147 |
| - } |
148 |
| -} |
149 |
| - |
150 |
| -void setup_global_from_env() { |
151 |
| - int print_traces = 0; |
152 |
| - if (const char* debug = getenv("TEST_DEBUG")) { |
153 |
| - print_traces = atoi(debug); |
154 |
| - } |
155 |
| - if (const char* mode = getenv("MYSQLSH_RECORDER_MODE")) { |
156 |
| - if (strcasecmp(mode, "direct") == 0 || !*mode) { |
157 |
| - set_mode(Mode::Direct, 0); |
158 |
| - puts("Disabled classic session recording"); |
159 |
| - } else if (strcasecmp(mode, "record") == 0) { |
160 |
| - set_mode(Mode::Record, print_traces); |
161 |
| - |
162 |
| - if (!getenv("MYSQLSH_RECORDER_PREFIX")) { |
163 |
| - printf( |
164 |
| - "MYSQLSH_RECORDER_MODE set but MYSQLSH_RECORDER_PREFIX is not!\n"); |
165 |
| - return; |
166 |
| - } |
167 |
| - set_recording_path_prefix(getenv("MYSQLSH_RECORDER_PREFIX")); |
168 |
| - |
169 |
| - // Set up hooks for keeping track of opened sessions |
170 |
| - on_recorder_connect_hook = |
171 |
| - std::bind(&on_session_connect, std::placeholders::_1); |
172 |
| - on_recorder_close_hook = |
173 |
| - std::bind(&on_session_close, std::placeholders::_1); |
174 |
| - |
175 |
| - printf("Recording classic sessions to %s\n", g_recording_path_prefix); |
176 |
| - } else if (strcasecmp(mode, "replay") == 0) { |
177 |
| - set_mode(Mode::Replay, print_traces); |
178 |
| - |
179 |
| - if (!getenv("MYSQLSH_RECORDER_PREFIX")) { |
180 |
| - printf( |
181 |
| - "MYSQLSH_RECORDER_MODE set but MYSQLSH_RECORDER_PREFIX is not!\n"); |
182 |
| - return; |
183 |
| - } |
184 |
| - set_recording_path_prefix(getenv("MYSQLSH_RECORDER_PREFIX")); |
185 |
| - printf("Replaying classic sessions from %s\n", g_recording_path_prefix); |
186 |
| - } else { |
187 |
| - printf("Invalid value for MYSQLSH_RECORDER_MODE '%s'\n", mode); |
188 |
| - } |
189 |
| - } |
190 |
| -} |
191 |
| - |
192 |
| -void finalize_global() { |
193 |
| - // Automatically close recording sessions that may be still open |
194 |
| - on_recorder_connect_hook = {}; |
195 |
| - on_recorder_close_hook = {}; |
196 |
| - |
197 |
| - for (const auto& s : g_open_sessions) { |
198 |
| - if (auto session = s.lock()) { |
199 |
| - session->close(); |
200 |
| - } |
201 |
| - } |
202 |
| - g_open_sessions.clear(); |
203 |
| -} |
204 |
| - |
205 | 128 | static Mode g_active_session_injector_mode = Mode::Direct;
|
206 | 129 | static int g_active_session_print_trace_mode = 0;
|
207 | 130 |
|
|
0 commit comments