deleted file mode 100644
--- a/xpcom/tests/TestArguments.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <string.h>
-
-int main(int argc, char* argv[]) {
- if (argc != 9)
- return -1;
-
- if (strcmp("mozilla", argv[1]) != 0)
- return 1;
- if (strcmp("firefox", argv[2]) != 0)
- return 2;
- if (strcmp("thunderbird", argv[3]) != 0)
- return 3;
- if (strcmp("seamonkey", argv[4]) != 0)
- return 4;
- if (strcmp("foo", argv[5]) != 0)
- return 5;
- if (strcmp("bar", argv[6]) != 0)
- return 6;
- if (strcmp("argument with spaces", argv[7]) != 0)
- return 7;
- if (strcmp("\"argument with quotes\"", argv[8]) != 0)
- return 8;
-
- return 0;
-}
deleted file mode 100644
--- a/xpcom/tests/TestBase64.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TestHarness.h"
-
-#include "mozilla/Attributes.h"
-#include "nsIScriptableBase64Encoder.h"
-#include "nsIInputStream.h"
-#include "nsAutoPtr.h"
-#include "nsStringAPI.h"
-#include <wchar.h>
-
-struct Chunk {
- Chunk(uint32_t l, const char* c)
- : mLength(l), mData(c)
- {}
-
- uint32_t mLength;
- const char* mData;
-};
-
-struct Test {
- Test(Chunk* c, const char* r)
- : mChunks(c), mResult(r)
- {}
-
- Chunk* mChunks;
- const char* mResult;
-};
-
-static Chunk kTest1Chunks[] =
-{
- Chunk(9, "Hello sir"),
- Chunk(0, nullptr)
-};
-
-static Chunk kTest2Chunks[] =
-{
- Chunk(3, "Hel"),
- Chunk(3, "lo "),
- Chunk(3, "sir"),
- Chunk(0, nullptr)
-};
-
-static Chunk kTest3Chunks[] =
-{
- Chunk(1, "I"),
- Chunk(0, nullptr)
-};
-
-static Chunk kTest4Chunks[] =
-{
- Chunk(2, "Hi"),
- Chunk(0, nullptr)
-};
-
-static Chunk kTest5Chunks[] =
-{
- Chunk(1, "B"),
- Chunk(2, "ob"),
- Chunk(0, nullptr)
-};
-
-static Chunk kTest6Chunks[] =
-{
- Chunk(2, "Bo"),
- Chunk(1, "b"),
- Chunk(0, nullptr)
-};
-
-static Chunk kTest7Chunks[] =
-{
- Chunk(1, "F"), // Carry over 1
- Chunk(4, "iref"), // Carry over 2
- Chunk(2, "ox"), // 1
- Chunk(4, " is "), // 2
- Chunk(2, "aw"), // 1
- Chunk(4, "esom"), // 2
- Chunk(2, "e!"),
- Chunk(0, nullptr)
-};
-
-static Chunk kTest8Chunks[] =
-{
- Chunk(5, "ALL T"),
- Chunk(1, "H"),
- Chunk(4, "ESE "),
- Chunk(2, "WO"),
- Chunk(21, "RLDS ARE YOURS EXCEPT"),
- Chunk(9, " EUROPA. "),
- Chunk(25, "ATTEMPT NO LANDING THERE."),
- Chunk(0, nullptr)
-};
-
-static Test kTests[] =
- {
- // Test 1, test a simple round string in one chunk
- Test(
- kTest1Chunks,
- "SGVsbG8gc2ly"
- ),
- // Test 2, test a simple round string split into round chunks
- Test(
- kTest2Chunks,
- "SGVsbG8gc2ly"
- ),
- // Test 3, test a single chunk that's 2 short
- Test(
- kTest3Chunks,
- "SQ=="
- ),
- // Test 4, test a single chunk that's 1 short
- Test(
- kTest4Chunks,
- "SGk="
- ),
- // Test 5, test a single chunk that's 2 short, followed by a chunk of 2
- Test(
- kTest5Chunks,
- "Qm9i"
- ),
- // Test 6, test a single chunk that's 1 short, followed by a chunk of 1
- Test(
- kTest6Chunks,
- "Qm9i"
- ),
- // Test 7, test alternating carryovers
- Test(
- kTest7Chunks,
- "RmlyZWZveCBpcyBhd2Vzb21lIQ=="
- ),
- // Test 8, test a longish string
- Test(
- kTest8Chunks,
- "QUxMIFRIRVNFIFdPUkxEUyBBUkUgWU9VUlMgRVhDRVBUIEVVUk9QQS4gQVRURU1QVCBOTyBMQU5ESU5HIFRIRVJFLg=="
- ),
- // Terminator
- Test(
- nullptr,
- nullptr
- )
- };
-
-class FakeInputStream final : public nsIInputStream
-{
- ~FakeInputStream() {}
-
-public:
-
- FakeInputStream()
- : mTestNumber(0),
- mTest(&kTests[0]),
- mChunk(&mTest->mChunks[0]),
- mClosed(false)
- {}
-
- NS_DECL_ISUPPORTS
- NS_DECL_NSIINPUTSTREAM
-
- void Reset();
- bool NextTest();
- bool CheckTest(nsACString& aResult);
- bool CheckTest(nsAString& aResult);
-private:
- uint32_t mTestNumber;
- const Test* mTest;
- const Chunk* mChunk;
- bool mClosed;
-};
-
-NS_IMPL_ISUPPORTS(FakeInputStream, nsIInputStream)
-
-NS_IMETHODIMP
-FakeInputStream::Close()
-{
- mClosed = true;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-FakeInputStream::Available(uint64_t* aAvailable)
-{
- *aAvailable = 0;
-
- if (mClosed)
- return NS_BASE_STREAM_CLOSED;
-
- const Chunk* chunk = mChunk;
- while (chunk->mLength) {
- *aAvailable += chunk->mLength;
- chunk++;
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-FakeInputStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aOut)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-FakeInputStream::ReadSegments(nsWriteSegmentFun aWriter,
- void* aClosure,
- uint32_t aCount,
- uint32_t* aRead)
-{
- *aRead = 0;
-
- if (mClosed)
- return NS_BASE_STREAM_CLOSED;
-
- while (mChunk->mLength) {
- uint32_t written = 0;
-
- nsresult rv = (*aWriter)(this, aClosure, mChunk->mData,
- *aRead, mChunk->mLength, &written);
-
- *aRead += written;
- NS_ENSURE_SUCCESS(rv, rv);
-
- mChunk++;
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-FakeInputStream::IsNonBlocking(bool* aIsBlocking)
-{
- *aIsBlocking = false;
- return NS_OK;
-}
-
-void
-FakeInputStream::Reset()
-{
- mClosed = false;
- mChunk = &mTest->mChunks[0];
-}
-
-bool
-FakeInputStream::NextTest()
-{
- mTestNumber++;
- mTest = &kTests[mTestNumber];
- mChunk = &mTest->mChunks[0];
- mClosed = false;
-
- return mTest->mChunks ? true : false;
-}
-
-bool
-FakeInputStream::CheckTest(nsACString& aResult)
-{
- return !strcmp(aResult.BeginReading(), mTest->mResult) ? true : false;
-}
-
-#ifdef XP_WIN
-static inline int NS_tstrcmp(char16ptr_t x, char16ptr_t y) {
- return wcscmp(x, y);
-}
-#else
-#define NS_tstrcmp strcmp
-#endif
-
-bool
-FakeInputStream::CheckTest(nsAString& aResult)
-{
- return !NS_tstrcmp(aResult.BeginReading(),
- NS_ConvertASCIItoUTF16(mTest->mResult).BeginReading())
- ? true : false;
-}
-
-int main(int argc, char** argv)
-{
- ScopedXPCOM xpcom("Base64");
- NS_ENSURE_FALSE(xpcom.failed(), 1);
-
- nsCOMPtr<nsIScriptableBase64Encoder> encoder =
- do_CreateInstance("@mozilla.org/scriptablebase64encoder;1");
- NS_ENSURE_TRUE(encoder, 1);
-
- RefPtr<FakeInputStream> stream = new FakeInputStream();
- do {
- nsString wideString;
- nsCString string;
-
- nsresult rv;
- rv = encoder->EncodeToString(stream, 0, wideString);
- NS_ENSURE_SUCCESS(rv, 1);
-
- stream->Reset();
-
- rv = encoder->EncodeToCString(stream, 0, string);
- NS_ENSURE_SUCCESS(rv, 1);
-
- if (!stream->CheckTest(wideString) || !stream->CheckTest(string))
- fail("Failed to convert properly\n");
-
- } while (stream->NextTest());
-
- return 0;
-}
deleted file mode 100644
--- a/xpcom/tests/TestBlockingProcess.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <prthread.h>
-
-int main()
-{
- while(1) PR_Sleep(PR_SecondsToInterval(10));
-}
deleted file mode 100644
--- a/xpcom/tests/TestCallTemplates.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim:cindent:ts=8:et:sw=4:
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * This test is NOT intended to be run. It's a test to make sure
- * a group of functions BUILD correctly.
- */
-
-#include "nsISupportsUtils.h"
-#include "nsIWeakReference.h"
-#include "nsIComponentManager.h"
-#include "nsIServiceManager.h"
-#include "nsWeakReference.h"
-#include "nsIInterfaceRequestor.h"
-#include "nsIInterfaceRequestorUtils.h"
-#include "nsComponentManagerUtils.h"
-#include "nsServiceManagerUtils.h"
-#include "nsAutoPtr.h"
-#include "mozilla/Attributes.h"
-
-#define NS_ITESTSERVICE_IID \
- {0x127b5253, 0x37b1, 0x43c7, \
- { 0x96, 0x2b, 0xab, 0xf1, 0x2d, 0x22, 0x56, 0xae }}
-
-class NS_NO_VTABLE nsITestService : public nsISupports {
- public:
- NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITESTSERVICE_IID)
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsITestService, NS_ITESTSERVICE_IID)
-
-class nsTestService final : public nsITestService,
- public nsSupportsWeakReference
-{
- ~nsTestService() {}
- public:
- NS_DECL_ISUPPORTS
-};
-
-NS_IMPL_ISUPPORTS(nsTestService, nsITestService, nsISupportsWeakReference)
-
-#define NS_TEST_SERVICE_CONTRACTID "@mozilla.org/test/testservice;1"
-#define NS_TEST_SERVICE_CID \
- {0xa00c1406, 0x283a, 0x45c9, \
- {0xae, 0xd2, 0x1a, 0xb6, 0xdd, 0xba, 0xfe, 0x53}}
-static NS_DEFINE_CID(kTestServiceCID, NS_TEST_SERVICE_CID);
-
-int main()
-{
- /*
- * NOTE: This does NOT demonstrate how these functions are
- * intended to be used. They are intended for filling in out
- * parameters that need to be |AddRef|ed. I'm just too lazy
- * to write lots of little getter functions for a test program
- * when I don't need to.
- */
-
- NS_NOTREACHED("This test is not intended to run, only to compile!");
-
- /* Test CallQueryInterface */
-
- nsISupports *mySupportsPtr = reinterpret_cast<nsISupports*>(0x1000);
-
- nsITestService *myITestService = nullptr;
- CallQueryInterface(mySupportsPtr, &myITestService);
-
- nsTestService *myTestService =
- reinterpret_cast<nsTestService*>(mySupportsPtr);
- nsISupportsWeakReference *mySupportsWeakRef;
- CallQueryInterface(myTestService, &mySupportsWeakRef);
-
- nsCOMPtr<nsISupports> mySupportsCOMPtr = mySupportsPtr;
- CallQueryInterface(mySupportsCOMPtr, &myITestService);
-
- RefPtr<nsTestService> myTestServiceRefPtr = myTestService;
- CallQueryInterface(myTestServiceRefPtr, &mySupportsWeakRef);
-
- /* Test CallQueryReferent */
-
- nsIWeakReference *myWeakRef =
- static_cast<nsIWeakReference*>(mySupportsPtr);
- CallQueryReferent(myWeakRef, &myITestService);
-
- /* Test CallCreateInstance */
-
- CallCreateInstance(kTestServiceCID, mySupportsPtr, &myITestService);
- CallCreateInstance(kTestServiceCID, &myITestService);
- CallCreateInstance(NS_TEST_SERVICE_CONTRACTID, mySupportsPtr,
- &myITestService);
- CallCreateInstance(NS_TEST_SERVICE_CONTRACTID, &myITestService);
-
- /* Test CallGetService */
- CallGetService(kTestServiceCID, &myITestService);
- CallGetService(NS_TEST_SERVICE_CONTRACTID, &myITestService);
-
- /* Test CallGetInterface */
- nsIInterfaceRequestor *myInterfaceRequestor =
- static_cast<nsIInterfaceRequestor*>(mySupportsPtr);
- CallGetInterface(myInterfaceRequestor, &myITestService);
-
- return 0;
-}
deleted file mode 100644
--- a/xpcom/tests/TestINIParser.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <string.h>
-
-#include "nsXPCOM.h"
-#include "nsINIParser.h"
-#include "nsIFile.h"
-
-static bool
-StringCB(const char *aKey, const char *aValue, void* aClosure)
-{
- printf("%s=%s\n", aKey, aValue);
-
- return true;
-}
-
-static bool
-SectionCB(const char *aSection, void* aClosure)
-{
- nsINIParser *ini = reinterpret_cast<nsINIParser*>(aClosure);
-
- printf("[%s]\n", aSection);
-
- ini->GetStrings(aSection, StringCB, nullptr);
-
- printf("\n");
-
- return true;
-}
-
-int main(int argc, char **argv)
-{
- if (argc < 2) {
- fprintf(stderr, "Usage: %s <ini-file>\n", argv[0]);
- return 255;
- }
-
- nsCOMPtr<nsIFile> lf;
-
- nsresult rv = NS_NewNativeLocalFile(nsDependentCString(argv[1]),
- true,
- getter_AddRefs(lf));
- if (NS_FAILED(rv)) {
- fprintf(stderr, "Error: NS_NewNativeLocalFile failed\n");
- return 1;
- }
-
- nsINIParser ini;
- rv = ini.Init(lf);
- if (NS_FAILED(rv)) {
- fprintf(stderr, "Error: Init failed.");
- return 2;
- }
-
- ini.GetSections(SectionCB, &ini);
-
- return 0;
-}
-
deleted file mode 100644
--- a/xpcom/tests/TestPRIntN.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <stdint.h>
-#include "prtypes.h"
-
-// This test is NOT intended to be run. It's a test to make sure
-// PRInt{N} matches int{N}_t. If they don't match, we should get a
-// compiler warning or error in main().
-
-static void
-ClearNSPRIntTypes(PRInt8 *a, PRInt16 *b, PRInt32 *c, PRInt64 *d)
-{
- *a = 0; *b = 0; *c = 0; *d = 0;
-}
-
-static void
-ClearStdIntTypes(int8_t *w, int16_t *x, int32_t *y, int64_t *z)
-{
- *w = 0; *x = 0; *y = 0; *z = 0;
-}
-
-int
-main()
-{
- PRInt8 a; PRInt16 b; PRInt32 c; PRInt64 d;
- int8_t w; int16_t x; int32_t y; int64_t z;
-
- ClearNSPRIntTypes(&w, &x, &y, &z);
- ClearStdIntTypes(&a, &b, &c, &d);
- return 0;
-}
deleted file mode 100644
--- a/xpcom/tests/TestQuickReturn.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <stdio.h>
-
-int main (int argc, char* argv[]) {
- if (argc != 1)
- return -1;
-
- return 42;
-}
deleted file mode 100644
--- a/xpcom/tests/TestRacingServiceManager.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TestHarness.h"
-
-#include "nsIFactory.h"
-#include "mozilla/Module.h"
-#include "nsXULAppAPI.h"
-#include "nsIThread.h"
-#include "nsIComponentRegistrar.h"
-
-#include "nsAutoPtr.h"
-#include "nsThreadUtils.h"
-#include "nsXPCOMCIDInternal.h"
-#include "pratom.h"
-#include "prmon.h"
-#include "mozilla/Assertions.h"
-#include "mozilla/Attributes.h"
-
-#include "mozilla/ReentrantMonitor.h"
-using namespace mozilla;
-
-/* f93f6bdc-88af-42d7-9d64-1b43c649a3e5 */
-#define FACTORY_CID1 \
-{ \
- 0xf93f6bdc, \
- 0x88af, \
- 0x42d7, \
- { 0x9d, 0x64, 0x1b, 0x43, 0xc6, 0x49, 0xa3, 0xe5 } \
-}
-NS_DEFINE_CID(kFactoryCID1, FACTORY_CID1);
-
-/* ef38ad65-6595-49f0-8048-e819f81d15e2 */
-#define FACTORY_CID2 \
-{ \
- 0xef38ad65, \
- 0x6595, \
- 0x49f0, \
- { 0x80, 0x48, 0xe8, 0x19, 0xf8, 0x1d, 0x15, 0xe2 } \
-}
-NS_DEFINE_CID(kFactoryCID2, FACTORY_CID2);
-
-#define FACTORY_CONTRACTID \
- "TestRacingThreadManager/factory;1"
-
-int32_t gComponent1Count = 0;
-int32_t gComponent2Count = 0;
-
-ReentrantMonitor* gReentrantMonitor = nullptr;
-
-bool gCreateInstanceCalled = false;
-bool gMainThreadWaiting = false;
-
-class AutoCreateAndDestroyReentrantMonitor
-{
-public:
- explicit AutoCreateAndDestroyReentrantMonitor(ReentrantMonitor** aReentrantMonitorPtr)
- : mReentrantMonitorPtr(aReentrantMonitorPtr) {
- *aReentrantMonitorPtr =
- new ReentrantMonitor("TestRacingServiceManager::AutoMon");
- MOZ_RELEASE_ASSERT(*aReentrantMonitorPtr, "Out of memory!");
- }
-
- ~AutoCreateAndDestroyReentrantMonitor() {
- if (*mReentrantMonitorPtr) {
- delete *mReentrantMonitorPtr;
- *mReentrantMonitorPtr = nullptr;
- }
- }
-
-private:
- ReentrantMonitor** mReentrantMonitorPtr;
-};
-
-class Factory final : public nsIFactory
-{
- ~Factory() {}
-
-public:
- NS_DECL_THREADSAFE_ISUPPORTS
-
- Factory() : mFirstComponentCreated(false) { }
-
- NS_IMETHOD CreateInstance(nsISupports* aDelegate,
- const nsIID& aIID,
- void** aResult) override;
-
- NS_IMETHOD LockFactory(bool aLock) override {
- return NS_OK;
- }
-
- bool mFirstComponentCreated;
-};
-
-NS_IMPL_ISUPPORTS(Factory, nsIFactory)
-
-class Component1 final : public nsISupports
-{
- ~Component1() {}
-
-public:
- NS_DECL_THREADSAFE_ISUPPORTS
-
- Component1() {
- // This is the real test - make sure that only one instance is ever created.
- int32_t count = PR_AtomicIncrement(&gComponent1Count);
- MOZ_RELEASE_ASSERT(count == 1, "Too many components created!");
- }
-};
-
-NS_IMPL_ADDREF(Component1)
-NS_IMPL_RELEASE(Component1)
-
-NS_INTERFACE_MAP_BEGIN(Component1)
- NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-class Component2 final : public nsISupports
-{
- ~Component2() {}
-
-public:
- NS_DECL_THREADSAFE_ISUPPORTS
-
- Component2() {
- // This is the real test - make sure that only one instance is ever created.
- int32_t count = PR_AtomicIncrement(&gComponent2Count);
- MOZ_RELEASE_ASSERT(count == 1, "Too many components created!");
- }
-};
-
-NS_IMPL_ADDREF(Component2)
-NS_IMPL_RELEASE(Component2)
-
-NS_INTERFACE_MAP_BEGIN(Component2)
- NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMETHODIMP
-Factory::CreateInstance(nsISupports* aDelegate,
- const nsIID& aIID,
- void** aResult)
-{
- // Make sure that the second thread beat the main thread to the getService
- // call.
- MOZ_RELEASE_ASSERT(!NS_IsMainThread(), "Wrong thread!");
-
- {
- ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
-
- gCreateInstanceCalled = true;
- mon.Notify();
-
- mon.Wait(PR_MillisecondsToInterval(3000));
- }
-
- NS_ENSURE_FALSE(aDelegate, NS_ERROR_NO_AGGREGATION);
- NS_ENSURE_ARG_POINTER(aResult);
-
- nsCOMPtr<nsISupports> instance;
-
- if (!mFirstComponentCreated) {
- instance = new Component1();
- }
- else {
- instance = new Component2();
- }
- NS_ENSURE_TRUE(instance, NS_ERROR_OUT_OF_MEMORY);
-
- nsresult rv = instance->QueryInterface(aIID, aResult);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-class TestRunnable : public Runnable
-{
-public:
- NS_DECL_NSIRUNNABLE
-
- TestRunnable() : mFirstRunnableDone(false) { }
-
- bool mFirstRunnableDone;
-};
-
-NS_IMETHODIMP
-TestRunnable::Run()
-{
- {
- ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
-
- while (!gMainThreadWaiting) {
- mon.Wait();
- }
- }
-
- nsresult rv;
- nsCOMPtr<nsISupports> component;
-
- if (!mFirstRunnableDone) {
- component = do_GetService(kFactoryCID1, &rv);
- }
- else {
- component = do_GetService(FACTORY_CONTRACTID, &rv);
- }
- MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv), "GetService failed!");
-
- return NS_OK;
-}
-
-static Factory* gFactory;
-
-static already_AddRefed<nsIFactory>
-CreateFactory(const mozilla::Module& module, const mozilla::Module::CIDEntry& entry)
-{
- if (!gFactory) {
- gFactory = new Factory();
- NS_ADDREF(gFactory);
- }
- nsCOMPtr<nsIFactory> ret = gFactory;
- return ret.forget();
-}
-
-static const mozilla::Module::CIDEntry kLocalCIDs[] = {
- { &kFactoryCID1, false, CreateFactory, nullptr },
- { &kFactoryCID2, false, CreateFactory, nullptr },
- { nullptr }
-};
-
-static const mozilla::Module::ContractIDEntry kLocalContracts[] = {
- { FACTORY_CONTRACTID, &kFactoryCID2 },
- { nullptr }
-};
-
-static const mozilla::Module kLocalModule = {
- mozilla::Module::kVersion,
- kLocalCIDs,
- kLocalContracts
-};
-
-int main(int argc, char** argv)
-{
- nsresult rv;
- XRE_AddStaticComponent(&kLocalModule);
-
- ScopedXPCOM xpcom("RacingServiceManager");
- NS_ENSURE_FALSE(xpcom.failed(), 1);
-
- AutoCreateAndDestroyReentrantMonitor mon1(&gReentrantMonitor);
-
- RefPtr<TestRunnable> runnable = new TestRunnable();
- NS_ENSURE_TRUE(runnable, 1);
-
- // Run the classID test
- nsCOMPtr<nsIThread> newThread;
- rv = NS_NewThread(getter_AddRefs(newThread), runnable);
- NS_ENSURE_SUCCESS(rv, 1);
-
- {
- ReentrantMonitorAutoEnter mon2(*gReentrantMonitor);
-
- gMainThreadWaiting = true;
- mon2.Notify();
-
- while (!gCreateInstanceCalled) {
- mon2.Wait();
- }
- }
-
- nsCOMPtr<nsISupports> component(do_GetService(kFactoryCID1, &rv));
- NS_ENSURE_SUCCESS(rv, 1);
-
- // Reset for the contractID test
- gMainThreadWaiting = gCreateInstanceCalled = false;
- gFactory->mFirstComponentCreated = runnable->mFirstRunnableDone = true;
- component = nullptr;
-
- rv = newThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
- NS_ENSURE_SUCCESS(rv, 1);
-
- {
- ReentrantMonitorAutoEnter mon3(*gReentrantMonitor);
-
- gMainThreadWaiting = true;
- mon3.Notify();
-
- while (!gCreateInstanceCalled) {
- mon3.Wait();
- }
- }
-
- component = do_GetService(FACTORY_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, 1);
-
- NS_RELEASE(gFactory);
-
- return 0;
-}
deleted file mode 100644
--- a/xpcom/tests/TestRegistrationOrder.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TestHarness.h"
-#include "nsIFile.h"
-#include "nsIDirectoryService.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsCOMArray.h"
-#include "nsArrayEnumerator.h"
-#include "nsXULAppAPI.h"
-#include "nsIComponentRegistrar.h"
-
-#define SERVICE_A_CONTRACT_ID "@mozilla.org/RegTestServiceA;1"
-#define SERVICE_B_CONTRACT_ID "@mozilla.org/RegTestServiceB;1"
-
-// {56ab1cd4-ac44-4f86-8104-171f8b8f2fc7}
-#define CORE_SERVICE_A_CID \
- { 0x56ab1cd4, 0xac44, 0x4f86, \
- { 0x81, 0x04, 0x17, 0x1f, 0x8b, 0x8f, 0x2f, 0xc7} }
-NS_DEFINE_CID(kCoreServiceA_CID, CORE_SERVICE_A_CID);
-
-// {fe64efb7-c5ab-41a6-b639-e6c0f483181e}
-#define EXT_SERVICE_A_CID \
- { 0xfe64efb7, 0xc5ab, 0x41a6, \
- { 0xb6, 0x39, 0xe6, 0xc0, 0xf4, 0x83, 0x18, 0x1e} }
-NS_DEFINE_CID(kExtServiceA_CID, EXT_SERVICE_A_CID);
-
-// {d04d1298-6dac-459b-a13b-bcab235730a0}
-#define CORE_SERVICE_B_CID \
- { 0xd04d1298, 0x6dac, 0x459b, \
- { 0xa1, 0x3b, 0xbc, 0xab, 0x23, 0x57, 0x30, 0xa0 } }
-NS_DEFINE_CID(kCoreServiceB_CID, CORE_SERVICE_B_CID);
-
-// {e93dadeb-a6f6-4667-bbbc-ac8c6d440b20}
-#define EXT_SERVICE_B_CID \
- { 0xe93dadeb, 0xa6f6, 0x4667, \
- { 0xbb, 0xbc, 0xac, 0x8c, 0x6d, 0x44, 0x0b, 0x20 } }
-NS_DEFINE_CID(kExtServiceB_CID, EXT_SERVICE_B_CID);
-
-nsresult execRegOrderTest(const char *aTestName, const char *aContractID,
- const nsCID &aCoreCID, const nsCID &aExtCID)
-{
- // Make sure the core service loaded (it won't be found using contract ID).
- nsresult rv = NS_ERROR_FAILURE;
- nsCOMPtr<nsISupports> coreService = do_CreateInstance(aCoreCID, &rv);
-#ifdef DEBUG_brade
- if (rv) fprintf(stderr, "rv: %d (%x)\n", rv, rv);
- fprintf(stderr, "coreService: %p\n", coreService.get());
-#endif
- if (NS_FAILED(rv))
- {
- fail("%s FAILED - cannot create core service\n", aTestName);
- return rv;
- }
-
- // Get the extension service.
- nsCOMPtr<nsISupports> extService = do_CreateInstance(aExtCID, &rv);
-#ifdef DEBUG_brade
- if (rv) fprintf(stderr, "rv: %d (%x)\n", rv, rv);
- fprintf(stderr, "extService: %p\n", extService.get());
-#endif
- if (NS_FAILED(rv))
- {
- fail("%s FAILED - cannot create extension service\n", aTestName);
- return rv;
- }
-
- /*
- * Get the service by contract ID and make sure it is the extension
- * service (it should be, since the extension directory was registered
- * after the core one).
- */
- nsCOMPtr<nsISupports> service = do_CreateInstance(aContractID, &rv);
-#ifdef DEBUG_brade
- if (rv) fprintf(stderr, "rv: %d (%x)\n", rv, rv);
- fprintf(stderr, "service: %p\n", service.get());
-#endif
- if (NS_FAILED(rv))
- {
- fail("%s FAILED - cannot create service\n", aTestName);
- return rv;
- }
-
- if (service != extService)
- {
- fail("%s FAILED - wrong service registered\n", aTestName);
- return NS_ERROR_FAILURE;
- }
-
- passed(aTestName);
- return NS_OK;
-}
-
-nsresult TestRegular()
-{
- return execRegOrderTest("TestRegular", SERVICE_A_CONTRACT_ID,
- kCoreServiceA_CID, kExtServiceA_CID);
-}
-
-nsresult TestJar()
-{
- return execRegOrderTest("TestJar", SERVICE_B_CONTRACT_ID,
- kCoreServiceB_CID, kExtServiceB_CID);
-}
-
-bool TestContractFirst()
-{
- nsCOMPtr<nsIComponentRegistrar> r;
- NS_GetComponentRegistrar(getter_AddRefs(r));
-
- nsCID* cid = nullptr;
- nsresult rv = r->ContractIDToCID("@mozilla.org/RegTestOrderC;1", &cid);
- if (NS_FAILED(rv)) {
- fail("RegTestOrderC: contract not registered");
- return false;
- }
-
- nsCID goodcid;
- goodcid.Parse("{ada15884-bb89-473c-8b50-dcfbb8447ff4}");
-
- if (!goodcid.Equals(*cid)) {
- fail("RegTestOrderC: CID doesn't match");
- return false;
- }
-
- passed("RegTestOrderC");
- return true;
-}
-
-static already_AddRefed<nsIFile>
-GetRegDirectory(const char* basename, const char* dirname, const char* leafname)
-{
- nsCOMPtr<nsIFile> f;
- nsresult rv = NS_NewNativeLocalFile(nsDependentCString(basename), true,
- getter_AddRefs(f));
- if (NS_FAILED(rv))
- return nullptr;
-
- f->AppendNative(nsDependentCString(dirname));
- if (leafname)
- f->AppendNative(nsDependentCString(leafname));
- return f.forget();
-}
-
-
-
-int main(int argc, char** argv)
-{
- if (argc < 2)
- {
- fprintf(stderr, "not enough arguments -- need registration dir path\n");
- return 1;
- }
-
- ScopedLogging logging;
-
-#ifdef XP_WIN
- // On Windows, convert to backslashes
- size_t regPathLen = strlen(argv[1]);
- char* regPath = new char[regPathLen + 1];
- for (size_t i = 0; i < regPathLen; i++) {
- char curr = argv[1][i];
- regPath[i] = (curr == '/') ? '\\' : curr;
- }
- regPath[regPathLen] = '\0';
-#else
- const char *regPath = argv[1];
-#endif
-
- nsCOMPtr<nsIFile> file =
- GetRegDirectory(regPath, "core", "component.manifest");
- XRE_AddManifestLocation(NS_EXTENSION_LOCATION, file);
- file = GetRegDirectory(regPath, "extension", "extComponent.manifest");
- XRE_AddManifestLocation(NS_EXTENSION_LOCATION, file);
- file = GetRegDirectory(regPath, "extension2.jar", nullptr);
- XRE_AddJarManifestLocation(NS_EXTENSION_LOCATION, file);
- ScopedXPCOM xpcom("RegistrationOrder");
- if (xpcom.failed())
- return 1;
-
- int rv = 0;
- if (NS_FAILED(TestRegular()))
- rv = 1;
-
- if (NS_FAILED(TestJar()))
- rv = 1;
-
- if (!TestContractFirst())
- rv = 1;
-
- return rv;
-}
deleted file mode 100644
--- a/xpcom/tests/TestSTLWrappers.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <stdio.h>
-
-#include <algorithm>
-#ifndef mozilla_algorithm_h
-# error "failed to wrap <algorithm>"
-#endif
-
-#include <vector>
-#ifndef mozilla_vector_h
-# error "failed to wrap <vector>"
-#endif
-
-// gcc errors out if we |try ... catch| with -fno-exceptions, but we
-// can still test on windows
-#ifdef _MSC_VER
- // C4530 will be generated whenever try...catch is used without
- // enabling exceptions. We know we don't enbale exceptions.
-# pragma warning( disable : 4530 )
-# define TRY try
-# define CATCH(e) catch (e)
-#else
-# define TRY
-# define CATCH(e) if (0)
-#endif
-
-int main() {
- std::vector<int> v;
- int rv = 1;
-
- TRY {
- // v.at(1) on empty v should abort; NOT throw an exception
-
- // (Do some arithmetic with result of v.at() to avoid
- // compiler warnings for unused variable/result.)
- rv += v.at(1) ? 1 : 2;
- } CATCH(const std::out_of_range&) {
- fputs("TEST-FAIL | TestSTLWrappers.cpp | caught an exception?\n",
- stderr);
- return 1;
- }
-
- fputs("TEST-FAIL | TestSTLWrappers.cpp | didn't abort()?\n",
- stderr);
- return rv;
-}
deleted file mode 100644
--- a/xpcom/tests/TestThreadPoolListener.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TestHarness.h"
-
-#include "nsIThread.h"
-#include "nsIThreadPool.h"
-
-#include "nsThreadUtils.h"
-#include "nsXPCOMCIDInternal.h"
-#include "pratom.h"
-#include "prinrval.h"
-#include "prmon.h"
-#include "prthread.h"
-#include "mozilla/Assertions.h"
-#include "mozilla/Attributes.h"
-
-#include "mozilla/ReentrantMonitor.h"
-using namespace mozilla;
-
-#define NUMBER_OF_THREADS 4
-
-// One hour... because test boxes can be slow!
-#define IDLE_THREAD_TIMEOUT 3600000
-
-static nsIThread** gCreatedThreadList = nullptr;
-static nsIThread** gShutDownThreadList = nullptr;
-
-static ReentrantMonitor* gReentrantMonitor = nullptr;
-
-static bool gAllRunnablesPosted = false;
-static bool gAllThreadsCreated = false;
-static bool gAllThreadsShutDown = false;
-
-class Listener final : public nsIThreadPoolListener
-{
- ~Listener() {}
-
-public:
- NS_DECL_THREADSAFE_ISUPPORTS
- NS_DECL_NSITHREADPOOLLISTENER
-};
-
-NS_IMPL_ISUPPORTS(Listener, nsIThreadPoolListener)
-
-NS_IMETHODIMP
-Listener::OnThreadCreated()
-{
- nsCOMPtr<nsIThread> current(do_GetCurrentThread());
- MOZ_RELEASE_ASSERT(current, "Couldn't get current thread!");
-
- ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
-
- while (!gAllRunnablesPosted) {
- mon.Wait();
- }
-
- for (uint32_t i = 0; i < NUMBER_OF_THREADS; i++) {
- nsIThread* thread = gCreatedThreadList[i];
- MOZ_RELEASE_ASSERT(thread != current, "Saw the same thread twice!");
-
- if (!thread) {
- gCreatedThreadList[i] = current;
- if (i == (NUMBER_OF_THREADS - 1)) {
- gAllThreadsCreated = true;
- mon.NotifyAll();
- }
- return NS_OK;
- }
- }
-
- MOZ_RELEASE_ASSERT(false, "Too many threads!");
- return NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-Listener::OnThreadShuttingDown()
-{
- nsCOMPtr<nsIThread> current(do_GetCurrentThread());
- MOZ_RELEASE_ASSERT(current, "Couldn't get current thread!");
-
- ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
-
- for (uint32_t i = 0; i < NUMBER_OF_THREADS; i++) {
- nsIThread* thread = gShutDownThreadList[i];
- MOZ_RELEASE_ASSERT(thread != current, "Saw the same thread twice!");
-
- if (!thread) {
- gShutDownThreadList[i] = current;
- if (i == (NUMBER_OF_THREADS - 1)) {
- gAllThreadsShutDown = true;
- mon.NotifyAll();
- }
- return NS_OK;
- }
- }
-
- MOZ_RELEASE_ASSERT(false, "Too many threads!");
- return NS_ERROR_FAILURE;
-}
-
-class AutoCreateAndDestroyReentrantMonitor
-{
-public:
- explicit AutoCreateAndDestroyReentrantMonitor(ReentrantMonitor** aReentrantMonitorPtr)
- : mReentrantMonitorPtr(aReentrantMonitorPtr) {
- *aReentrantMonitorPtr = new ReentrantMonitor("TestThreadPoolListener::AutoMon");
- MOZ_RELEASE_ASSERT(*aReentrantMonitorPtr, "Out of memory!");
- }
-
- ~AutoCreateAndDestroyReentrantMonitor() {
- delete *mReentrantMonitorPtr;
- *mReentrantMonitorPtr = nullptr;
- }
-
-private:
- ReentrantMonitor** mReentrantMonitorPtr;
-};
-
-int main(int argc, char** argv)
-{
- ScopedXPCOM xpcom("ThreadPoolListener");
- NS_ENSURE_FALSE(xpcom.failed(), 1);
-
- nsIThread* createdThreadList[NUMBER_OF_THREADS] = { nullptr };
- gCreatedThreadList = createdThreadList;
-
- nsIThread* shutDownThreadList[NUMBER_OF_THREADS] = { nullptr };
- gShutDownThreadList = shutDownThreadList;
-
- AutoCreateAndDestroyReentrantMonitor newMon(&gReentrantMonitor);
- NS_ENSURE_TRUE(gReentrantMonitor, 1);
-
- nsresult rv;
-
- nsCOMPtr<nsIThreadPool> pool =
- do_CreateInstance(NS_THREADPOOL_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, 1);
-
- rv = pool->SetThreadLimit(NUMBER_OF_THREADS);
- NS_ENSURE_SUCCESS(rv, 1);
-
- rv = pool->SetIdleThreadLimit(NUMBER_OF_THREADS);
- NS_ENSURE_SUCCESS(rv, 1);
-
- rv = pool->SetIdleThreadTimeout(IDLE_THREAD_TIMEOUT);
- NS_ENSURE_SUCCESS(rv, 1);
-
- nsCOMPtr<nsIThreadPoolListener> listener = new Listener();
- NS_ENSURE_TRUE(listener, 1);
-
- rv = pool->SetListener(listener);
- NS_ENSURE_SUCCESS(rv, 1);
-
- {
- ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
-
- for (uint32_t i = 0; i < NUMBER_OF_THREADS; i++) {
- nsCOMPtr<nsIRunnable> runnable = new Runnable();
- NS_ENSURE_TRUE(runnable, 1);
-
- rv = pool->Dispatch(runnable, NS_DISPATCH_NORMAL);
- NS_ENSURE_SUCCESS(rv, 1);
- }
-
- gAllRunnablesPosted = true;
- mon.NotifyAll();
- }
-
- {
- ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
- while (!gAllThreadsCreated) {
- mon.Wait();
- }
- }
-
- rv = pool->Shutdown();
- NS_ENSURE_SUCCESS(rv, 1);
-
- {
- ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
- while (!gAllThreadsShutDown) {
- mon.Wait();
- }
- }
-
- for (uint32_t i = 0; i < NUMBER_OF_THREADS; i++) {
- nsIThread* created = gCreatedThreadList[i];
- NS_ENSURE_TRUE(created, 1);
-
- bool match = false;
- for (uint32_t j = 0; j < NUMBER_OF_THREADS; j++) {
- nsIThread* destroyed = gShutDownThreadList[j];
- NS_ENSURE_TRUE(destroyed, 1);
-
- if (destroyed == created) {
- match = true;
- break;
- }
- }
-
- NS_ENSURE_TRUE(match, 1);
- }
-
- return 0;
-}
deleted file mode 100644
--- a/xpcom/tests/TestUnicodeArguments.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * On Windows, a Unicode argument is passed as UTF-16 using ShellExecuteExW.
- * On other platforms, it is passed as UTF-8
- */
-
-static const int args_length = 4;
-#if defined(XP_WIN) && defined(_MSC_VER)
-#define _UNICODE
-#include <tchar.h>
-#include <stdio.h>
-
-static const _TCHAR* expected_utf16[args_length] = {
- // Latin-1
- L"M\xF8z\xEEll\xE5",
- // Cyrillic
- L"\x41C\x43E\x437\x438\x43B\x43B\x430",
- // Bengali
- L"\x9AE\x9CB\x99C\x9BF\x9B2\x9BE",
- // Cuneiform
- L"\xD808\xDE2C\xD808\xDF63\xD808\xDDB7"
-};
-
-int wmain(int argc, _TCHAR* argv[]) {
- printf("argc = %d\n", argc);
-
- if (argc != args_length + 1)
- return -1;
-
- for (int i = 1; i < argc; ++i) {
- printf("expected[%d]: ", i - 1);
- for (size_t j = 0; j < _tcslen(expected_utf16[i - 1]); ++j) {
- printf("%x ", *(expected_utf16[i - 1] + j));
- }
- printf("\n");
-
- printf("argv[%d]: ", i);
- for (size_t j = 0; j < _tcslen(argv[i]); ++j) {
- printf("%x ", *(argv[i] + j));
- }
- printf("\n");
-
- if (_tcscmp(expected_utf16[i - 1], argv[i])) {
- return i;
- }
- }
-
- return 0;
-}
-#else
-#include <string.h>
-#include <stdio.h>
-
-static const char* expected_utf8[args_length] = {
- // Latin-1
- "M\xC3\xB8z\xC3\xAEll\xC3\xA5",
- // Cyrillic
- "\xD0\x9C\xD0\xBE\xD0\xB7\xD0\xB8\xD0\xBB\xD0\xBB\xD0\xB0",
- // Bengali
- "\xE0\xA6\xAE\xE0\xA7\x8B\xE0\xA6\x9C\xE0\xA6\xBF\xE0\xA6\xB2\xE0\xA6\xBE",
- // Cuneiform
- "\xF0\x92\x88\xAC\xF0\x92\x8D\xA3\xF0\x92\x86\xB7"
-};
-
-int main(int argc, char* argv[]) {
- if (argc != args_length + 1)
- return -1;
-
- for (int i = 1; i < argc; ++i) {
- printf("argv[%d] = %s; expected = %s\n", i, argv[i], expected_utf8[i - 1]);
- if (strcmp(expected_utf8[i - 1], argv[i])) {
- return i;
- }
- }
-
- return 0;
-}
-#endif
--- a/xpcom/tests/moz.build
+++ b/xpcom/tests/moz.build
@@ -14,40 +14,16 @@ TEST_DIRS += [
if CONFIG['OS_ARCH'] == 'WINNT':
TEST_DIRS += ['windows']
EXPORTS.testing += [
'TestHarness.h',
]
-SimplePrograms([
- 'nsIFileEnumerator',
- 'TestArguments',
- 'TestBlockingProcess',
- 'TestCallTemplates',
- 'TestINIParser',
- 'TestPRIntN',
- 'TestQuickReturn',
- 'TestRacingServiceManager',
- 'TestRegistrationOrder',
- 'TestThreadPoolListener',
- 'TestUnicodeArguments',
-])
-
-if CONFIG['OS_TARGET'] == 'WINNT':
- GeckoSimplePrograms([
- 'TestBase64',
- ])
-
-if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']:
- GeckoSimplePrograms([
- 'TestSTLWrappers',
- ])
-
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
GeckoCppUnitTests([
'TestTimers'
])
if CONFIG['MOZ_MEMORY']:
GeckoCppUnitTests([
deleted file mode 100644
--- a/xpcom/tests/nsIFileEnumerator.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "nsIFile.h"
-#include "nsStringGlue.h"
-
-#include <stdio.h>
-#include "nsIComponentRegistrar.h"
-#include "nsIComponentManager.h"
-#include "nsIServiceManager.h"
-#include "nsMemory.h"
-#include "nsISimpleEnumerator.h"
-#include "nsCOMPtr.h"
-
-static bool LoopInDir(nsIFile* aFile)
-{
- nsresult rv;
- nsCOMPtr<nsISimpleEnumerator> entries;
- rv = aFile->GetDirectoryEntries(getter_AddRefs(entries));
- if(NS_FAILED(rv) || !entries)
- return false;
-
- bool hasMore;
- while(NS_SUCCEEDED(entries->HasMoreElements(&hasMore)) && hasMore)
- {
- nsCOMPtr<nsISupports> sup;
- entries->GetNext(getter_AddRefs(sup));
- if(!sup)
- return false;
-
- nsCOMPtr<nsIFile> nextFile = do_QueryInterface(sup);
- if (!nextFile)
- return false;
-
- nsAutoCString name;
- if(NS_FAILED(nextFile->GetNativeLeafName(name)))
- return false;
-
- bool isDir;
- printf("%s\n", name.get());
- rv = nextFile->IsDirectory(&isDir);
- if (NS_FAILED(rv))
- {
- printf("IsDirectory Failed!!!\n");
- return false;
- }
-
- if (isDir)
- {
- LoopInDir(nextFile);
- }
- }
- return true;
-}
-
-
-int
-main(int argc, char* argv[])
-{
- nsresult rv;
- {
- nsCOMPtr<nsIFile> topDir;
-
- nsCOMPtr<nsIServiceManager> servMan;
- rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
- if (NS_FAILED(rv)) return -1;
-
- if (argc > 1 && argv[1] != nullptr)
- {
- char* pathStr = argv[1];
- NS_NewNativeLocalFile(nsDependentCString(pathStr), false, getter_AddRefs(topDir));
- }
-
- if (!topDir)
- {
- printf("No Top Dir\n");
- return -1;
- }
- int32_t startTime = PR_IntervalNow();
-
- LoopInDir(topDir);
-
- int32_t endTime = PR_IntervalNow();
-
- printf("\nTime: %d\n", PR_IntervalToMilliseconds(endTime - startTime));
- } // this scopes the nsCOMPtrs
- // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
- rv = NS_ShutdownXPCOM(nullptr);
- NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
- return 0;
-}