Backed out 9 changesets (bug 1839918) for causing a top crash as in Bug 1852357....
[gecko.git] / xpcom / tests / TestShutdown.cpp
blob4b277d423c7e76599ae67e0f04f16e622b98f788
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsIServiceManager.h"
8 // Gee this seems simple! It's for testing for memory leaks with Purify.
10 void main(int argc, char* argv[]) {
11 nsIServiceManager* servMgr;
12 nsresult rv = NS_InitXPCOM(&servMgr, nullptr, nullptr);
13 MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
15 // try loading a component and releasing it to see if it leaks
16 if (argc > 1 && argv[1] != nullptr) {
17 char* cidStr = argv[1];
18 nsISupports* obj = nullptr;
19 if (cidStr[0] == '{') {
20 nsCID cid;
21 cid.Parse(cidStr);
22 rv = CallCreateInstance(cid, &obj);
23 } else {
24 // contractID case:
25 rv = CallCreateInstance(cidStr, &obj);
27 if (NS_SUCCEEDED(rv)) {
28 printf("Successfully created %s\n", cidStr);
29 NS_RELEASE(obj);
30 } else {
31 printf("Failed to create %s (%x)\n", cidStr, rv);
35 rv = NS_ShutdownXPCOM(servMgr);
36 MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");