https://bugs.winehq.org/show_bug.cgi?id=48658
Bug ID: 48658 Summary: Fix error handling in the WineRun* scripts Product: Wine-Testbot Version: unspecified Hardware: x86 OS: Linux Status: NEW Severity: normal Priority: P2 Component: unknown Assignee: wine-bugs@winehq.org Reporter: fgouget@codeweavers.com Distribution: ---
Over time error handling in the WineRun* scripts has become complex and inconsistent. It's in need of a serious cleanup, particular so that errors can be reliably identified in the testbot.log file and shown on the JobDetails page.
There are three places where the WineRun* scripts can send errors: * To the global 'var/log' log file. Sending errors to the global file makes sense for errors which could be relevant to other operations on that VM such as the preceding or following revert. * To the per-task 'testbot.log' file. This is where most errors should go for long term storage. * To stderr which is redirected to 'testbot.log' nowadays.
Then there are a number of functions that report errors:
* LogMsg() This adds a message to the global log (errors and others alike). It is used to log the startup and exit of the WineRun* scripts in the global log, but also to save some errors there.
* Error() Prints the error on stderr if --log-only is not specified, and sends them to the global log (via LogMsg()). In particular things like usage errors thus end up in the global log which probably does not make sense.
* LogTaskError() Explicitly opens testbot.log and appends to it. It should really print to stderr instead. But some calls to LogTaskErrors
* FatalError() The main point of FatalError() is that it invokes WrapUpAndExit() with appropriate parameters. But it also sends the error message to both the global log and testbot.log (via LogTaskError()). That's probably not appropriate.
* FatalTAError() This is a specialized form of FatalError() which also notifies the administrator of network issues. That's ok except that depending on the codepath it may end up calling any of Error(), LogMsg(), LogTaskError() or FatalError().