mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[CrashReporting] Breakpad everywhere, session detection, symbol CI (inc 3)
Breakpad on all platforms (no crashpad packaging); remove the Windows MiniDumpWithFullMemory filter and the installer WER LocalDumps full-dump registration. QLockFile per-process session tracking replaces the Windows-only .dmp scan, placed after parser.process and the instance hand-off so help/version exits and handed-off secondaries never leak a lock. CI: Release-only DSN bake from SENTRY_DSN secret, tag-only sentry-cli symbol upload (org cockatrice, project native). Tests: 533/533 ctest green, format clean, code gate PASS.
This commit is contained in:
parent
69b421f1c2
commit
c40763e61d
8 changed files with 362 additions and 102 deletions
|
|
@ -1,10 +1,14 @@
|
|||
#include "client/crash/crash_reporter.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QLockFile>
|
||||
#include <QString>
|
||||
#include <QSysInfo>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTextStream>
|
||||
#include <gtest/gtest.h>
|
||||
#include <libcockatrice/settings/personal_settings.h>
|
||||
#include <string>
|
||||
|
|
@ -339,6 +343,81 @@ TEST(CrashReporterTest, AttachSkipsNoteWhenEmptyAndFindsRunDirEnvelopes)
|
|||
ASSERT_FALSE(content.contains(QByteArrayLiteral("user-note.txt")));
|
||||
}
|
||||
|
||||
TEST(CrashReporterTest, BeginSessionOnEmptyDirReportsClean)
|
||||
{
|
||||
QTemporaryDir dir;
|
||||
ASSERT_TRUE(dir.isValid());
|
||||
CrashReporter reporter;
|
||||
ASSERT_FALSE(reporter.beginSession(dir.path()));
|
||||
reporter.endSession();
|
||||
}
|
||||
|
||||
TEST(CrashReporterTest, BeginSessionIgnoresLiveConcurrentInstance)
|
||||
{
|
||||
QTemporaryDir dir;
|
||||
ASSERT_TRUE(dir.isValid());
|
||||
// A second QLockFile held in-process stands in for a live concurrent instance: same
|
||||
// pid, alive, so the scan must leave it alone and report a clean start.
|
||||
QLockFile liveInstance(dir.filePath(QStringLiteral("session-424242")));
|
||||
ASSERT_TRUE(liveInstance.tryLock(0));
|
||||
CrashReporter reporter;
|
||||
ASSERT_FALSE(reporter.beginSession(dir.path()));
|
||||
ASSERT_TRUE(QFile::exists(liveInstance.fileName()));
|
||||
reporter.endSession();
|
||||
liveInstance.unlock();
|
||||
}
|
||||
|
||||
TEST(CrashReporterTest, BeginSessionDetectsStaleDeadOwnerLock)
|
||||
{
|
||||
QTemporaryDir dir;
|
||||
ASSERT_TRUE(dir.isValid());
|
||||
// A well-formed lock whose owner is dead: our own pid (so the host matches) but a
|
||||
// process name that cannot match, which is how QLockFile spots pid reuse. Must be
|
||||
// reported unclean and cleaned up, even though the file is brand new (this is why
|
||||
// the scan probes with staleLockTime 0 rather than the 30 s default).
|
||||
const QString stalePath = dir.filePath(QStringLiteral("session-stale-owner"));
|
||||
QFile stale(stalePath);
|
||||
ASSERT_TRUE(stale.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||
QTextStream out(&stale);
|
||||
out << QCoreApplication::applicationPid() << '\n'
|
||||
<< QStringLiteral("definitely-not-the-test-binary") << '\n'
|
||||
<< QSysInfo::machineHostName() << '\n';
|
||||
stale.close();
|
||||
|
||||
CrashReporter reporter;
|
||||
ASSERT_TRUE(reporter.beginSession(dir.path()));
|
||||
ASSERT_FALSE(QFile::exists(stalePath));
|
||||
reporter.endSession();
|
||||
}
|
||||
|
||||
TEST(CrashReporterTest, BeginSessionCleansGarbageFileAndReportsUnclean)
|
||||
{
|
||||
QTemporaryDir dir;
|
||||
ASSERT_TRUE(dir.isValid());
|
||||
// An unreadable lock file has no live owner by definition: report unclean and remove it.
|
||||
const QString garbagePath = dir.filePath(QStringLiteral("session-garbage"));
|
||||
QFile garbage(garbagePath);
|
||||
ASSERT_TRUE(garbage.open(QIODevice::WriteOnly));
|
||||
garbage.write("not-a-lock-file\x00\xff", 17);
|
||||
garbage.close();
|
||||
|
||||
CrashReporter reporter;
|
||||
ASSERT_TRUE(reporter.beginSession(dir.path()));
|
||||
ASSERT_FALSE(QFile::exists(garbagePath));
|
||||
reporter.endSession();
|
||||
}
|
||||
|
||||
TEST(CrashReporterTest, BeginSessionEndSessionRoundTripReportsClean)
|
||||
{
|
||||
QTemporaryDir dir;
|
||||
ASSERT_TRUE(dir.isValid());
|
||||
CrashReporter reporter;
|
||||
ASSERT_FALSE(reporter.beginSession(dir.path()));
|
||||
reporter.endSession();
|
||||
ASSERT_FALSE(reporter.beginSession(dir.path()));
|
||||
reporter.endSession();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue