Bug 1756057 - In GTest have FOG init when the runner runs, instead of in some random test r=janerik

Depends on D147448

Differential Revision: https://phabricator.services.mozilla.com/D147449
This commit is contained in:
Chris H-C 2022-07-18 14:24:32 +00:00
parent 41067177bd
commit b4a877fed5
2 changed files with 11 additions and 10 deletions

View File

@ -6,7 +6,10 @@
#include "GTestRunner.h"
#include "gtest/gtest.h"
#include "mozilla/Attributes.h"
#include "mozilla/Preferences.h"
#include "mozilla/glean/fog_ffi_generated.h"
#include "nsICrashReporter.h"
#include "nsString.h"
#include "testing/TestHarness.h"
#include "prenv.h"
#ifdef ANDROID
@ -153,6 +156,14 @@ int RunGTestFunc(int* argc, char** argv) {
}
}
// FOG should init exactly once, as early into running as possible, to enable
// instrumentation tests to work properly.
// However, at init, Glean may decide to send a ping. So let's first tell FOG
// that these pings shouldn't actually be uploaded.
Preferences::SetInt("telemetry.fog.test.localhost_port", -1);
const nsCString empty;
glean::impl::fog_init(&empty, &empty);
return RUN_ALL_TESTS();
}

View File

@ -32,16 +32,6 @@ void GTest_FOG_ExpectFailure(const char* aMessage) {
}
}
// Initialize FOG exactly once.
// This needs to be the first test to run!
TEST(FOG, FogInitDoesntCrash)
{
Preferences::SetInt("telemetry.fog.test.localhost_port", -1);
const nsCString empty;
ASSERT_EQ(NS_OK, fog_init(&empty, &empty));
ASSERT_EQ(NS_OK, fog_test_reset(&empty, &empty));
}
TEST(FOG, BuiltinPingsRegistered)
{
Preferences::SetInt("telemetry.fog.test.localhost_port", -1);