Bug 1492664 - generate portable URLs for Android mach commands; r=nalexander
[gecko.git] / xpcom / tests / TestShutdown.cpp
blobc6e6cbfb806886a8cdbf6272197f5e285f2bb74f
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 nsresult rv;
12 nsIServiceManager* servMgr;
13 rv = NS_InitXPCOM2(&servMgr, nullptr, nullptr);
14 NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
16 // try loading a component and releasing it to see if it leaks
17 if (argc > 1 && argv[1] != nullptr) {
18 char* cidStr = argv[1];
19 nsISupports* obj = nullptr;
20 if (cidStr[0] == '{') {
21 nsCID cid;
22 cid.Parse(cidStr);
23 rv = CallCreateInstance(cid, &obj);
24 } else {
25 // contractID case:
26 rv = CallCreateInstance(cidStr, &obj);
28 if (NS_SUCCEEDED(rv)) {
29 printf("Successfully created %s\n", cidStr);
30 NS_RELEASE(obj);
31 } else {
32 printf("Failed to create %s (%x)\n", cidStr, rv);
36 rv = NS_ShutdownXPCOM(servMgr);
37 NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");