diff options
author | Talank <talank@gces.edu.np> | 2021-12-01 14:01:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-01 14:01:50 +0300 |
commit | 331175502f6d4b89f0991951a687e2931ddc0fe0 (patch) | |
tree | f9db5d790b74ad67db7a8c13f572094411a81d16 /test | |
parent | 15e835f8a3e3b871946ba536cbca380b5962cf7b (diff) |
Stacktrace on crash (#9235)
Diffstat (limited to 'test')
-rw-r--r-- | test/gui/shared/scripts/helpers/SetupClientHelper.py | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/test/gui/shared/scripts/helpers/SetupClientHelper.py b/test/gui/shared/scripts/helpers/SetupClientHelper.py index 0d62e17b2..19d3783dc 100644 --- a/test/gui/shared/scripts/helpers/SetupClientHelper.py +++ b/test/gui/shared/scripts/helpers/SetupClientHelper.py @@ -1,7 +1,10 @@ from urllib.parse import urlparse import squish -from os import makedirs +from os import makedirs, environ from os.path import exists, join +import test +import subprocess +from configparser import ConfigParser confdir = '/tmp/bdd-tests-owncloud-client/' @@ -67,7 +70,7 @@ def getResourcePath(context, resource, user=None): def startClient(context): squish.startApplication( - "owncloud -s" + "owncloud OWNCLOUD_CORE_DUMP=1 -s" + " --logfile " + context.userData['clientConfigFile'] + " --logdebug" @@ -75,9 +78,71 @@ def startClient(context): + " --confdir " + confdir ) + squish.installEventHandler("Crash", "crashHandler") + squish.snooze(1) +def crashHandler(): + # The core dump is generated in the folder /var/lib/apport/coredump/ + coredumpFolderPath = '/var/lib/apport/coredump/' + cfg = ConfigParser() + + # Select appropriate AUT binary with respect to the test run environment + try: + if environ.get('CI'): + cfg.read('/drone/src/test/gui/drone/server.ini') + + else: + from pathlib import Path + + HOME = str(Path.home()) + cfg.read(HOME + '/.squish/ver1/server.ini') + + except Exception as err: + test.log("the binary path can not be read") + test.log(err) + + owncloudBinary = cfg.get('General', 'AUT/owncloud') + owncloudBinary = owncloudBinary.replace('"', '') + '/owncloud' + + # GUI test stacktrace on crash + test.log("Started printing the GUI test stacktrace of crash") + test.log("############################################################") + test.log("Backtracking...") + test.log("%s" % test.stackTrace()) + test.log("############################################################") + test.log("Finished printing GUI test stacktrace") + + test.log("Started printing the AUT stacktrace of crash") + test.log("############################################################") + ls = subprocess.run( + ['ls', '-t', coredumpFolderPath], stdout=subprocess.PIPE + ).stdout.decode('utf-8') + coredumpFilename = ls.split('\n')[0] + test.log("located latest core dump file: %s" % coredumpFilename) + + if coredumpFilename: + test.log("Backtracking...") + test.log( + "%s" + % subprocess.run( + [ + 'gdb', + owncloudBinary, + coredumpFolderPath + coredumpFilename.strip(), + '-batch', + '-ex', + 'bt full', + ], + stdout=subprocess.PIPE, + ).stdout.decode('utf-8') + ) + + test.log("############################################################") + test.log("Finished printing AUT stacktrace") + + def getPollingInterval(): pollingInterval = '''[ownCloud] remotePollInterval={pollingInterval} |