MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / smokeTest

Function smokeTest

lib/core/testing.py:224–313  ·  view source on GitHub ↗

Runs the basic smoke testing of a program

()

Source from the content-addressed store, hash-verified

222 return retVal
223
224def smokeTest():
225 """
226 Runs the basic smoke testing of a program
227 """
228
229 unisonRandom()
230
231 with open(paths.ERRORS_XML, "r") as f:
232 content = f.read()
233
234 for regex in re.findall(r'<error regexp="(.+?)"/>', content):
235 try:
236 re.compile(regex)
237 except re.error:
238 errMsg = "smoke test failed at compiling '%s'" % regex
239 logger.error(errMsg)
240 return False
241
242 retVal = True
243 count, length = 0, 0
244
245 for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
246 if any(_ in root for _ in ("thirdparty", "extra", "interbase")):
247 continue
248
249 for filename in files:
250 if os.path.splitext(filename)[1].lower() == ".py" and filename != "__init__.py":
251 length += 1
252
253 for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
254 if any(_ in root for _ in ("thirdparty", "extra", "interbase")):
255 continue
256
257 for filename in files:
258 if os.path.splitext(filename)[1].lower() == ".py" and filename not in ("__init__.py", "gui.py"):
259 path = os.path.join(root, os.path.splitext(filename)[0])
260 path = path.replace(paths.SQLMAP_ROOT_PATH, '.')
261 path = path.replace(os.sep, '.').lstrip('.')
262 try:
263 __import__(path)
264 module = sys.modules[path]
265 except Exception as ex:
266 retVal = False
267 dataToStdout("\r")
268 errMsg = "smoke test failed at importing module '%s' (%s):\n%s" % (path, os.path.join(root, filename), ex)
269 logger.error(errMsg)
270 else:
271 logger.setLevel(logging.CRITICAL)
272 kb.smokeMode = True
273
274 (failure_count, _) = doctest.testmod(module)
275
276 kb.smokeMode = False
277 logger.setLevel(logging.INFO)
278
279 if failure_count > 0:
280 retVal = False
281

Callers 1

mainFunction · 0.90

Calls 9

unisonRandomFunction · 0.90
dataToStdoutFunction · 0.90
roundFunction · 0.90
clearConsoleLineFunction · 0.90
infoMethod · 0.80
_Function · 0.70
readMethod · 0.45
errorMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…