From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.cpp | 27 -- ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.h | 28 -- ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.cpp | 19 -- ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.h | 34 -- ipc/ipdl/test/cxx/IPDLUnitTestTypes.h | 43 --- ipc/ipdl/test/cxx/IPDLUnitTestUtils.h | 28 -- ipc/ipdl/test/cxx/IPDLUnitTests.h | 85 ----- ipc/ipdl/test/cxx/IPDLUnitTests.template.cpp | 345 --------------------- ipc/ipdl/test/cxx/Makefile.in | 45 --- ipc/ipdl/test/cxx/PTestIndirectProtocolParam.ipdlh | 15 - .../test/cxx/PTestIndirectProtocolParamFirst.ipdl | 20 -- .../test/cxx/PTestIndirectProtocolParamManage.ipdl | 18 -- .../test/cxx/PTestIndirectProtocolParamSecond.ipdl | 14 - ipc/ipdl/test/cxx/PTestPaintThread.ipdl | 15 - ipc/ipdl/test/cxx/PTestPriority.ipdl | 24 -- ipc/ipdl/test/cxx/README.txt | 61 ---- ipc/ipdl/test/cxx/app/TestIPDL.cpp | 24 -- ipc/ipdl/test/cxx/app/moz.build | 20 -- ipc/ipdl/test/cxx/genIPDLUnitTests.py | 193 ------------ ipc/ipdl/test/cxx/moz.build | 38 --- 20 files changed, 1096 deletions(-) delete mode 100644 ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.cpp delete mode 100644 ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.h delete mode 100644 ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.cpp delete mode 100644 ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.h delete mode 100644 ipc/ipdl/test/cxx/IPDLUnitTestTypes.h delete mode 100644 ipc/ipdl/test/cxx/IPDLUnitTestUtils.h delete mode 100644 ipc/ipdl/test/cxx/IPDLUnitTests.h delete mode 100644 ipc/ipdl/test/cxx/IPDLUnitTests.template.cpp delete mode 100644 ipc/ipdl/test/cxx/Makefile.in delete mode 100644 ipc/ipdl/test/cxx/PTestIndirectProtocolParam.ipdlh delete mode 100644 ipc/ipdl/test/cxx/PTestIndirectProtocolParamFirst.ipdl delete mode 100644 ipc/ipdl/test/cxx/PTestIndirectProtocolParamManage.ipdl delete mode 100644 ipc/ipdl/test/cxx/PTestIndirectProtocolParamSecond.ipdl delete mode 100644 ipc/ipdl/test/cxx/PTestPaintThread.ipdl delete mode 100644 ipc/ipdl/test/cxx/PTestPriority.ipdl delete mode 100644 ipc/ipdl/test/cxx/README.txt delete mode 100644 ipc/ipdl/test/cxx/app/TestIPDL.cpp delete mode 100644 ipc/ipdl/test/cxx/app/moz.build delete mode 100644 ipc/ipdl/test/cxx/genIPDLUnitTests.py delete mode 100644 ipc/ipdl/test/cxx/moz.build (limited to 'ipc/ipdl/test/cxx') diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.cpp b/ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.cpp deleted file mode 100644 index 7683808535..0000000000 --- a/ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* 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 "mozilla/ipc/IOThreadChild.h" - -#include "IPDLUnitTestProcessChild.h" -#include "IPDLUnitTests.h" - -#include "nsRegion.h" - -using mozilla::ipc::IOThreadChild; - -namespace mozilla { -namespace _ipdltest { - -bool IPDLUnitTestProcessChild::Init(int aArgc, char* aArgv[]) { - // FIXME(nika): this is quite clearly broken and needs to be fixed. - IPDLUnitTestChildInit(IOThreadChild::TakeChannel(), ParentPid(), - IOThreadChild::message_loop()); - - return true; -} - -} // namespace _ipdltest -} // namespace mozilla diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.h b/ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.h deleted file mode 100644 index 94578e3520..0000000000 --- a/ipc/ipdl/test/cxx/IPDLUnitTestProcessChild.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* 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/. */ - -#ifndef mozilla__ipdltest_IPDLUnitTestThreadChild_h -#define mozilla__ipdltest_IPDLUnitTestThreadChild_h 1 - -#include "mozilla/ipc/ProcessChild.h" - -namespace mozilla { -namespace _ipdltest { - -class IPDLUnitTestProcessChild : public mozilla::ipc::ProcessChild { - typedef mozilla::ipc::ProcessChild ProcessChild; - - public: - using ProcessChild::ProcessChild; - - ~IPDLUnitTestProcessChild() {} - - virtual bool Init(int aArgc, char* aArgv[]) override; -}; - -} // namespace _ipdltest -} // namespace mozilla - -#endif // ifndef mozilla__ipdltest_IPDLUnitTestThreadChild_h diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.cpp b/ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.cpp deleted file mode 100644 index 660e5928d3..0000000000 --- a/ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* 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 "IPDLUnitTestSubprocess.h" - -using mozilla::ipc::GeckoChildProcessHost; - -namespace mozilla { -namespace _ipdltest { - -IPDLUnitTestSubprocess::IPDLUnitTestSubprocess() - : GeckoChildProcessHost(GeckoProcessType_IPDLUnitTest) {} - -IPDLUnitTestSubprocess::~IPDLUnitTestSubprocess() {} - -} // namespace _ipdltest -} // namespace mozilla diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.h b/ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.h deleted file mode 100644 index 384cf25ce9..0000000000 --- a/ipc/ipdl/test/cxx/IPDLUnitTestSubprocess.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* 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/. */ - -#ifndef mozilla__ipdltest_IPDLUnitTestTestSubprocess_h -#define mozilla__ipdltest_IPDLUnitTestTestSubprocess_h 1 - -#include "mozilla/ipc/GeckoChildProcessHost.h" - -namespace mozilla { -namespace _ipdltest { -//----------------------------------------------------------------------------- - -class IPDLUnitTestSubprocess : public mozilla::ipc::GeckoChildProcessHost { - public: - IPDLUnitTestSubprocess(); - - /** - * Asynchronously launch the plugin process. - */ - // Could override parent Launch, but don't need to here - // bool Launch(); - - private: - ~IPDLUnitTestSubprocess(); - - DISALLOW_EVIL_CONSTRUCTORS(IPDLUnitTestSubprocess); -}; - -} // namespace _ipdltest -} // namespace mozilla - -#endif // ifndef mozilla__ipdltest_IPDLUnitTestTestSubprocess_h diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h b/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h deleted file mode 100644 index 02696f7df7..0000000000 --- a/ipc/ipdl/test/cxx/IPDLUnitTestTypes.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* 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/. */ - -#ifndef mozilla__ipdltest_IPDLUnitTestTypes_h -#define mozilla__ipdltest_IPDLUnitTestTypes_h - -#include "mozilla/ipc/ProtocolUtils.h" // ActorDestroyReason - -namespace mozilla { -namespace _ipdltest { - -struct DirtyRect { - int x; - int y; - int w; - int h; -}; - -} // namespace _ipdltest -} // namespace mozilla - -namespace IPC { -template <> -struct ParamTraits { - typedef mozilla::_ipdltest::DirtyRect paramType; - static void Write(MessageWriter* aWriter, const paramType& aParam) { - WriteParam(aWriter, aParam.x); - WriteParam(aWriter, aParam.y); - WriteParam(aWriter, aParam.w); - WriteParam(aWriter, aParam.h); - } - static bool Read(MessageReader* aReader, void** aIter, paramType* aResult) { - return (ReadParam(aReader, aIter, &aResult->x) && - ReadParam(aReader, aIter, &aResult->y) && - ReadParam(aReader, aIter, &aResult->w) && - ReadParam(aReader, aIter, &aResult->h)); - } -}; -} // namespace IPC - -#endif // ifndef mozilla__ipdltest_IPDLUnitTestTypes_h diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h b/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h deleted file mode 100644 index e454ae7b61..0000000000 --- a/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h +++ /dev/null @@ -1,28 +0,0 @@ - -#ifndef mozilla__ipdltest_IPDLUnitTestUtils -#define mozilla__ipdltest_IPDLUnitTestUtils 1 - -#include "ipc/IPCMessageUtils.h" - -namespace mozilla { -namespace _ipdltest { - -struct Bad {}; - -} // namespace _ipdltest -} // namespace mozilla - -namespace IPC { - -template <> -struct ParamTraits { - typedef mozilla::_ipdltest::Bad paramType; - - // Defined in TestActorPunning.cpp. - static void Write(MessageWriter* aWriter, const paramType& aParam); - static bool Read(MessageReader* aReader, paramType* aResult); -}; - -} // namespace IPC - -#endif // mozilla__ipdltest_IPDLUnitTestUtils diff --git a/ipc/ipdl/test/cxx/IPDLUnitTests.h b/ipc/ipdl/test/cxx/IPDLUnitTests.h deleted file mode 100644 index 28fc4ee372..0000000000 --- a/ipc/ipdl/test/cxx/IPDLUnitTests.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* 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/. */ - -#ifndef mozilla__ipdltest_IPDLUnitTests_h -#define mozilla__ipdltest_IPDLUnitTests_h 1 - -#include "base/message_loop.h" -#include "base/process.h" -#include "chrome/common/ipc_channel.h" - -#include "nsCOMPtr.h" -#include "nsDebug.h" -#include "nsServiceManagerUtils.h" // do_GetService() -#include "nsWidgetsCID.h" // NS_APPSHELL_CID -#include "nsXULAppAPI.h" - -#define MOZ_IPDL_TESTFAIL_LABEL "TEST-UNEXPECTED-FAIL" -#define MOZ_IPDL_TESTPASS_LABEL "TEST-PASS" -#define MOZ_IPDL_TESTINFO_LABEL "TEST-INFO" - -namespace mozilla { -namespace _ipdltest { - -//----------------------------------------------------------------------------- -// both processes -const char* IPDLUnitTestName(); - -// NB: these are named like the similar functions in -// xpcom/test/TestHarness.h. The names should nominally be kept in -// sync. - -inline void fail(const char* fmt, ...) { - va_list ap; - - fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL " | %s | ", IPDLUnitTestName()); - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - - fputc('\n', stderr); - - MOZ_CRASH("failed test"); -} - -inline void passed(const char* fmt, ...) { - va_list ap; - - printf(MOZ_IPDL_TESTPASS_LABEL " | %s | ", IPDLUnitTestName()); - - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); - - fputc('\n', stdout); -} - -//----------------------------------------------------------------------------- -// parent process only - -class IPDLUnitTestSubprocess; - -extern void* gParentActor; -extern IPDLUnitTestSubprocess* gSubprocess; - -void IPDLUnitTestMain(void* aData); - -void QuitParent(); - -//----------------------------------------------------------------------------- -// child process only - -extern void* gChildActor; - -void IPDLUnitTestChildInit(IPC::Channel* transport, base::ProcessId parentPid, - MessageLoop* worker); - -void QuitChild(); - -} // namespace _ipdltest -} // namespace mozilla - -#endif // ifndef mozilla__ipdltest_IPDLUnitTests_h diff --git a/ipc/ipdl/test/cxx/IPDLUnitTests.template.cpp b/ipc/ipdl/test/cxx/IPDLUnitTests.template.cpp deleted file mode 100644 index 113e7cd287..0000000000 --- a/ipc/ipdl/test/cxx/IPDLUnitTests.template.cpp +++ /dev/null @@ -1,345 +0,0 @@ -// -// Autogenerated from Python template. Hands off. -// - -#include -#include - -#include "IPDLUnitTests.h" - -#include "base/command_line.h" -#include "base/string_util.h" -#include "base/task.h" -#include "base/thread.h" - -#include "nsRegion.h" - -#include "IPDLUnitTestSubprocess.h" - -// clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${INCLUDES} -//----------------------------------------------------------------------------- -// clang-format on - -using namespace std; - -using base::Thread; - -namespace mozilla { -namespace _ipdltest { - -void* gParentActor; -IPDLUnitTestSubprocess* gSubprocess; - -void* gChildActor; - -// Note: in threaded mode, this will be non-null (for both parent and -// child, since they share one set of globals). -Thread* gChildThread; -MessageLoop* gParentMessageLoop; -bool gParentDone; -bool gChildDone; - -void DeleteChildActor(); - -//----------------------------------------------------------------------------- -// data/functions accessed by both parent and child processes - -char* gIPDLUnitTestName = nullptr; - -const char* IPDLUnitTestName() { - if (!gIPDLUnitTestName) { -#if defined(XP_WIN) - vector args = CommandLine::ForCurrentProcess()->GetLooseValues(); - gIPDLUnitTestName = ::strdup(WideToUTF8(args[0]).c_str()); -#else - vector argv = CommandLine::ForCurrentProcess()->argv(); - gIPDLUnitTestName = ::moz_xstrdup(argv[1].c_str()); -#endif - } - return gIPDLUnitTestName; -} - -} // namespace _ipdltest -} // namespace mozilla - -namespace { - -enum IPDLUnitTestType { - NoneTest = 0, - - // clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${ENUM_VALUES} - - LastTest = ${LAST_ENUM} -//----------------------------------------------------------------------------- -//clang-format on -}; - -IPDLUnitTestType IPDLUnitTestFromString(const char* const aString) { - if (!aString) return static_cast(0); -// clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${STRING_TO_ENUMS} -//----------------------------------------------------------------------------- - // clang-format on - else return static_cast(0); -} - -IPDLUnitTestType IPDLUnitTest() { - return IPDLUnitTestFromString(::mozilla::_ipdltest::IPDLUnitTestName()); -} - -} // namespace - -//----------------------------------------------------------------------------- -// parent process only - -namespace mozilla { -namespace _ipdltest { - -void DeferredParentShutdown(); - -void IPDLUnitTestThreadMain(char* testString); - -void IPDLUnitTestMain(void* aData) { - char* testString = reinterpret_cast(aData); - - // Check if we are to run the test using threads instead: - const char* prefix = "thread:"; - const int prefixLen = strlen(prefix); - if (!strncmp(testString, prefix, prefixLen)) { - IPDLUnitTestThreadMain(testString + prefixLen); - return; - } - - IPDLUnitTestType test = IPDLUnitTestFromString(testString); - if (!test) { - // use this instead of |fail()| because we don't know what the test is - fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL "| %s | unknown unit test %s\n", - "<--->", testString); - MOZ_CRASH("can't continue"); - } - gIPDLUnitTestName = testString; - - // Check whether this test is enabled for processes: - switch (test) { - // clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${PARENT_ENABLED_CASES_PROC} -//----------------------------------------------------------------------------- - // clang-format on - - default: - fail("not reached"); - return; // unreached - } - - printf(MOZ_IPDL_TESTINFO_LABEL "| running test | %s\n", gIPDLUnitTestName); - - std::vector testCaseArgs; - testCaseArgs.push_back(testString); - - gSubprocess = new IPDLUnitTestSubprocess(); - if (!gSubprocess->SyncLaunch(testCaseArgs)) - fail("problem launching subprocess"); - - IPC::Channel* transport = gSubprocess->GetChannel(); - if (!transport) fail("no transport"); - - base::ProcessId child = base::GetProcId(gSubprocess->GetChildProcessHandle()); - - switch (test) { - // clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${PARENT_MAIN_CASES_PROC} -//----------------------------------------------------------------------------- - // clang-format on - - default: - fail("not reached"); - return; // unreached - } -} - -void IPDLUnitTestThreadMain(char* testString) { - IPDLUnitTestType test = IPDLUnitTestFromString(testString); - if (!test) { - // use this instead of |fail()| because we don't know what the test is - fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL "| %s | unknown unit test %s\n", - "<--->", testString); - MOZ_CRASH("can't continue"); - } - gIPDLUnitTestName = testString; - - // Check whether this test is enabled for threads: - switch (test) { - // clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${PARENT_ENABLED_CASES_THREAD} -//----------------------------------------------------------------------------- - // clang-format on - - default: - fail("not reached"); - return; // unreached - } - - printf(MOZ_IPDL_TESTINFO_LABEL "| running test | %s\n", gIPDLUnitTestName); - - std::vector testCaseArgs; - testCaseArgs.push_back(testString); - - gChildThread = new Thread("ParentThread"); - if (!gChildThread->Start()) fail("starting parent thread"); - - gParentMessageLoop = MessageLoop::current(); - MessageLoop* childMessageLoop = gChildThread->message_loop(); - - switch (test) { - // clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${PARENT_MAIN_CASES_THREAD} -//----------------------------------------------------------------------------- - // clang-format on - - default: - fail("not reached"); - return; // unreached - } -} - -void DeleteParentActor() { - if (!gParentActor) return; - - switch (IPDLUnitTest()) { - // clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${PARENT_DELETE_CASES} -//----------------------------------------------------------------------------- - // clang-format on - default: - ::mozilla::_ipdltest::fail("???"); - } -} - -void QuitXPCOM() { - DeleteParentActor(); - - static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); - nsCOMPtr appShell(do_GetService(kAppShellCID)); - appShell->Exit(); -} - -void DeleteSubprocess(MessageLoop* uiLoop) { - // pong to QuitXPCOM - gSubprocess->Destroy(); - gSubprocess = nullptr; - uiLoop->PostTask(NewRunnableFunction("QuitXPCOM", QuitXPCOM)); -} - -void DeferredParentShutdown() { - // ping to DeleteSubprocess - XRE_GetIOMessageLoop()->PostTask(NewRunnableFunction( - "DeleteSubprocess", DeleteSubprocess, MessageLoop::current())); -} - -void TryThreadedShutdown() { - // Stop if either: - // - the child has not finished, - // - the parent has not finished, - // - or this code has already executed. - // Remember: this TryThreadedShutdown() task is enqueued - // by both parent and child (though always on parent's msg loop). - if (!gChildDone || !gParentDone || !gChildThread) return; - - delete gChildThread; - gChildThread = 0; - DeferredParentShutdown(); -} - -void ChildCompleted() { - // Executes on the parent message loop once child has completed. - gChildDone = true; - TryThreadedShutdown(); -} - -void QuitParent() { - if (gChildThread) { - gParentDone = true; - MessageLoop::current()->PostTask( - NewRunnableFunction("TryThreadedShutdown", TryThreadedShutdown)); - } else { - // defer "real" shutdown to avoid *Channel::Close() racing with the - // deletion of the subprocess - MessageLoop::current()->PostTask( - NewRunnableFunction("DeferredParentShutdown", DeferredParentShutdown)); - } -} - -static void ChildDie() { - DeleteChildActor(); - XRE_ShutdownChildProcess(); -} - -void QuitChild() { - if (gChildThread) { // Threaded-mode test - gParentMessageLoop->PostTask( - NewRunnableFunction("ChildCompleted", ChildCompleted)); - } else { // Process-mode test - MessageLoop::current()->PostTask(NewRunnableFunction("ChildDie", ChildDie)); - } -} - -} // namespace _ipdltest -} // namespace mozilla - -//----------------------------------------------------------------------------- -// child process only - -namespace mozilla { -namespace _ipdltest { - -void DeleteChildActor() { - if (!gChildActor) return; - - switch (IPDLUnitTest()) { - // clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${CHILD_DELETE_CASES} -//----------------------------------------------------------------------------- - // clang-format on - default: - ::mozilla::_ipdltest::fail("???"); - } -} - -void IPDLUnitTestChildInit(IPC::Channel* transport, base::ProcessId parentPid, - MessageLoop* worker) { - switch (IPDLUnitTest()) { - // clang-format off -//----------------------------------------------------------------------------- -//===== TEMPLATED ===== -${CHILD_INIT_CASES} -//----------------------------------------------------------------------------- - // clang-format on - - default: - fail("not reached"); - return; // unreached - } -} - -} // namespace _ipdltest -} // namespace mozilla diff --git a/ipc/ipdl/test/cxx/Makefile.in b/ipc/ipdl/test/cxx/Makefile.in deleted file mode 100644 index b32533a648..0000000000 --- a/ipc/ipdl/test/cxx/Makefile.in +++ /dev/null @@ -1,45 +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/. - -IPDLTESTSRCS = $(filter Test%,$(CPPSRCS)) -IPDLTESTS = $(IPDLTESTSRCS:.cpp=) - -EXTRA_PROTOCOLS = \ - TestEndpointBridgeSub \ - $(NULL) - -IPDLTESTHDRS = $(addprefix $(srcdir)/,$(addsuffix .h,$(IPDLTESTS))) - -TESTER_TEMPLATE := $(srcdir)/IPDLUnitTests.template.cpp -GENTESTER := $(srcdir)/genIPDLUnitTests.py - -include $(topsrcdir)/config/rules.mk - - -IPDLUNITTEST_BIN = $(DEPTH)/dist/bin/ipdlunittest$(BIN_SUFFIX) - -IPDLUnitTests.cpp : Makefile.in moz.build $(GENTESTER) $(TESTER_TEMPLATE) $(IPDLTESTHDRS) - $(PYTHON3) $(GENTESTER) $(TESTER_TEMPLATE) -t $(IPDLTESTS) -e $(EXTRA_PROTOCOLS) > $@ - -check-proc:: - @$(EXIT_ON_ERROR) \ - for test in $(IPDLTESTS); do \ - $(RUN_TEST_PROGRAM) $(IPDLUNITTEST_BIN) $$test ; \ - done - -check-thread:: - @$(EXIT_ON_ERROR) \ - for test in $(IPDLTESTS); do \ - $(RUN_TEST_PROGRAM) $(IPDLUNITTEST_BIN) thread:$$test ; \ - done - -check:: check-proc check-thread - -check-valgrind:: - @$(EXIT_ON_ERROR) \ - for test in $(IPDLTESTS); do \ - $(RUN_TEST_PROGRAM) -g -d \ - valgrind -a '--leak-check=full --trace-children=yes -q' \ - $(IPDLUNITTEST_BIN) $$test ; \ - done diff --git a/ipc/ipdl/test/cxx/PTestIndirectProtocolParam.ipdlh b/ipc/ipdl/test/cxx/PTestIndirectProtocolParam.ipdlh deleted file mode 100644 index a81fcdee46..0000000000 --- a/ipc/ipdl/test/cxx/PTestIndirectProtocolParam.ipdlh +++ /dev/null @@ -1,15 +0,0 @@ -include protocol PTestIndirectProtocolParamSecond; - -namespace mozilla { -namespace _ipdltest { - -struct IndirectParamStruct { - PTestIndirectProtocolParamSecond actor; -}; - -union IndirectParamUnion { - IndirectParamStruct; -}; - -} -} diff --git a/ipc/ipdl/test/cxx/PTestIndirectProtocolParamFirst.ipdl b/ipc/ipdl/test/cxx/PTestIndirectProtocolParamFirst.ipdl deleted file mode 100644 index 5364d79ffb..0000000000 --- a/ipc/ipdl/test/cxx/PTestIndirectProtocolParamFirst.ipdl +++ /dev/null @@ -1,20 +0,0 @@ -include protocol PTestIndirectProtocolParamManage; -// FIXME/bug 792908 protocol PTestIndirectProtocolParamSecond is -// already included in PTestIndirectProtocolParam.ipdlh -include protocol PTestIndirectProtocolParamSecond; -include PTestIndirectProtocolParam; - -namespace mozilla { -namespace _ipdltest { - -[ManualDealloc, ChildImpl=virtual, ParentImpl=virtual] -sync protocol PTestIndirectProtocolParamFirst { - manager PTestIndirectProtocolParamManage; -parent: - sync Test(IndirectParamUnion actor); -both: - async __delete__(); -}; - -} -} diff --git a/ipc/ipdl/test/cxx/PTestIndirectProtocolParamManage.ipdl b/ipc/ipdl/test/cxx/PTestIndirectProtocolParamManage.ipdl deleted file mode 100644 index 8d3c6f81b1..0000000000 --- a/ipc/ipdl/test/cxx/PTestIndirectProtocolParamManage.ipdl +++ /dev/null @@ -1,18 +0,0 @@ -include protocol PTestIndirectProtocolParamFirst; -include protocol PTestIndirectProtocolParamSecond; - -namespace mozilla { -namespace _ipdltest { - -[ManualDealloc, ChildImpl=virtual, ParentImpl=virtual] -sync protocol PTestIndirectProtocolParamManage { - manages PTestIndirectProtocolParamFirst; - manages PTestIndirectProtocolParamSecond; -both: - async PTestIndirectProtocolParamFirst(); - async PTestIndirectProtocolParamSecond(); - async __delete__(); -}; - -} -} diff --git a/ipc/ipdl/test/cxx/PTestIndirectProtocolParamSecond.ipdl b/ipc/ipdl/test/cxx/PTestIndirectProtocolParamSecond.ipdl deleted file mode 100644 index 27545ca2cb..0000000000 --- a/ipc/ipdl/test/cxx/PTestIndirectProtocolParamSecond.ipdl +++ /dev/null @@ -1,14 +0,0 @@ -include protocol PTestIndirectProtocolParamManage; - -namespace mozilla { -namespace _ipdltest { - -[ManualDealloc, ChildImpl=virtual, ParentImpl=virtual] -sync protocol PTestIndirectProtocolParamSecond { - manager PTestIndirectProtocolParamManage; -both: - async __delete__(); -}; - -} -} diff --git a/ipc/ipdl/test/cxx/PTestPaintThread.ipdl b/ipc/ipdl/test/cxx/PTestPaintThread.ipdl deleted file mode 100644 index 00d46c9757..0000000000 --- a/ipc/ipdl/test/cxx/PTestPaintThread.ipdl +++ /dev/null @@ -1,15 +0,0 @@ -include "mozilla/_ipdltest/TestOffMainThreadPainting.h"; - -namespace mozilla { -namespace _ipdltest { - -// This is supposed to be analagous to PPaintingBridge. -[ManualDealloc, ChildImpl="TestPaintThreadChild", ParentImpl="TestPaintThreadParent"] -sync protocol PTestPaintThread -{ -parent: - sync FinishedPaint(uint64_t aTxnId); -}; - -} // namespace mozilla -} // namespace _ipdltest diff --git a/ipc/ipdl/test/cxx/PTestPriority.ipdl b/ipc/ipdl/test/cxx/PTestPriority.ipdl deleted file mode 100644 index 8b85368072..0000000000 --- a/ipc/ipdl/test/cxx/PTestPriority.ipdl +++ /dev/null @@ -1,24 +0,0 @@ -namespace mozilla { -namespace _ipdltest { - -[ManualDealloc, ChildImpl=virtual, ParentImpl=virtual] -sync protocol PTestPriority { -parent: - [Priority=input] async PMsg1(); - [Priority=input] sync PMsg2(); - [Priority=vsync] async PMsg3(); - [Priority=vsync] sync PMsg4(); - [Priority=mediumhigh] async PMsg5(); - [Priority=mediumhigh] sync PMsg6(); - [Priority=control] async PMsg7(); - [Priority=control] sync PMsg8(); - -child: - [Priority=input] async CMsg1(); - [Priority=vsync] async CMsg2(); - [Priority=mediumhigh] async CMsg3(); - [Priority=control] async CMsg4(); -}; - -} // namespace _ipdltest -} // namespace mozilla diff --git a/ipc/ipdl/test/cxx/README.txt b/ipc/ipdl/test/cxx/README.txt deleted file mode 100644 index 0fe6c07320..0000000000 --- a/ipc/ipdl/test/cxx/README.txt +++ /dev/null @@ -1,61 +0,0 @@ -To add a new IPDL C++ unit test, you need to create (at least) the -following files (for a test "TestFoo"): - - - PTestFoo.ipdl, specifying the top-level protocol used for the test - - - TestFoo.h, declaring the top-level parent/child actors used for - the test - - - TestFoo.cpp, defining the top-level actors - - - (make sure all are in the namespace mozilla::_ipdltest) - -Next - - - add PTestFoo.ipdl to ipdl.mk - - - append TestFoo to the variable IPDLTESTS in Makefile.in - -You must define three methods in your |TestFooParent| class: - - - static methods |bool RunTestInProcesses()| and - |bool RunTestInThreads()|. These methods control whether - to execute the test using actors in separate processes and - threads respectively. Generally, both should return true. - - - an instance method |void Main()|. The test harness wil first - initialize the processes or threads, create and open both actors, - and then kick off the test using |Main()|. Make sure you define - it. - -If your test passes its criteria, please call -|MOZ_IPDL_TESTPASS("msg")| and "exit gracefully". - -If your tests fails, please call |MOZ_IPDL_TESTFAIL("msg")| and "exit -ungracefully", preferably by abort()ing. - - -If all goes well, running - - make -C $OBJDIR/ipc/ipdl/test/cxx - -will update the file IPDLUnitTests.cpp (the test launcher), and your -new code will be built automatically. - - -You can launch your new test by invoking one of - - make -C $OBJDIR/ipc/ipdl/test/cxx check-proc (test process-based tests) - make -C $OBJDIR/ipc/ipdl/test/cxx check-threads (test thread-based tests) - make -C $OBJDIR/ipc/ipdl/test/cxx check (tests both) - -If you want to launch only your test, run - - cd $OBJDIR/dist/bin - ./run-mozilla.sh ./ipdlunittest TestFoo (test in two processes, if appl.) - ./run-mozilla.sh ./ipdlunittest thread:TestFoo (test in two threads, if appl.) - - -For a bare-bones example of adding a test, take a look at -PTestSanity.ipdl, TestSanity.h, TestSanity.cpp, and how "TestSanity" -is included in ipdl.mk and Makefile.in. diff --git a/ipc/ipdl/test/cxx/app/TestIPDL.cpp b/ipc/ipdl/test/cxx/app/TestIPDL.cpp deleted file mode 100644 index 3891aead62..0000000000 --- a/ipc/ipdl/test/cxx/app/TestIPDL.cpp +++ /dev/null @@ -1,24 +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/. */ - -#define MOZ_IPDL_TESTS -#include "mozilla/Bootstrap.h" - -#if defined(XP_WIN) -# include -# include "nsWindowsWMain.cpp" -#endif - -using namespace mozilla; - -int main(int argc, char** argv) { - // the first argument specifies which IPDL test case/suite to load - if (argc < 2) return 1; - - Bootstrap::UniquePtr bootstrap = GetBootstrap(); - if (!bootstrap) { - return 2; - } - return bootstrap->XRE_RunIPDLTest(argc, argv); -} diff --git a/ipc/ipdl/test/cxx/app/moz.build b/ipc/ipdl/test/cxx/app/moz.build deleted file mode 100644 index 909360062a..0000000000 --- a/ipc/ipdl/test/cxx/app/moz.build +++ /dev/null @@ -1,20 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -GeckoProgram("ipdlunittest", linkage="dependent") - -SOURCES += [ - "TestIPDL.cpp", -] -include("/ipc/chromium/chromium-config.mozbuild") - -LOCAL_INCLUDES += [ - "/toolkit/xre", - "/xpcom/base", -] - -if CONFIG["CC_TYPE"] == "clang-cl": - WIN32_EXE_LDFLAGS += ["-ENTRY:wmainCRTStartup"] diff --git a/ipc/ipdl/test/cxx/genIPDLUnitTests.py b/ipc/ipdl/test/cxx/genIPDLUnitTests.py deleted file mode 100644 index 160b90a031..0000000000 --- a/ipc/ipdl/test/cxx/genIPDLUnitTests.py +++ /dev/null @@ -1,193 +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/. - -import string -import sys - - -def usage(): - print( - """ -%s template_file -t unit_tests... -e extra_protocols... - - TEMPLATE_FILE is used to generate to generate the unit-tester .cpp - UNIT_TESTS are the top-level protocols defining unit tests - EXTRA_PROTOCOLS are top-level protocols for subprocesses that can be - spawned in tests but are not unit tests in and of - themselves -""" - % (sys.argv[0]), - file=sys.stderr, - ) - sys.exit(1) - - -def main(argv): - template = argv[1] - - if argv[2] != "-t": - usage() - i = 3 - unittests = [] - while argv[i] != "-e": - unittests.append(argv[i]) - i += 1 - - extras = argv[(i + 1) :] - - includes = "\n".join(['#include "%s.h"' % (t) for t in unittests]) - - enum_values = "\n".join([" %s," % (t) for t in unittests + extras]) - last_enum = unittests[-1] - - string_to_enums = "\n".join( - [ - """ else if (!strcmp(aString, "%s")) - return %s;""" - % (t, t) - for t in unittests + extras - ] - ) - - enum_to_strings = "\n".join( - [ - """ case %s: - return "%s";""" - % (t, t) - for t in unittests + extras - ] - ) - - parent_delete_cases = "\n".join( - [ - """ case %s: { - delete reinterpret_cast<%sParent*>(gParentActor); - return; - } -""" - % (t, t) - for t in unittests - ] - ) - - parent_enabled_cases_proc = "\n".join( - [ - """ case %s: { - if (!%sParent::RunTestInProcesses()) { - passed("N/A to proc"); - DeferredParentShutdown(); - return; - } - break; - } -""" - % (t, t) - for t in unittests - ] - ) - - parent_main_cases_proc = "\n".join( - [ - """ case %s: { - %sParent** parent = - reinterpret_cast<%sParent**>(&gParentActor); - *parent = new %sParent(); - (*parent)->Open(transport, child); - return (*parent)->Main(); - } -""" - % (t, t, t, t) - for t in unittests - ] - ) - - parent_enabled_cases_thread = "\n".join( - [ - """ case %s: { - if (!%sParent::RunTestInThreads()) { - passed("N/A to threads"); - DeferredParentShutdown(); - return; - } - break; - } -""" - % (t, t) - for t in unittests - ] - ) - - parent_main_cases_thread = "\n".join( - [ - """ case %s: { - %sParent** parent = - reinterpret_cast<%sParent**>(&gParentActor); - *parent = new %sParent(); - - %sChild** child = - reinterpret_cast<%sChild**>(&gChildActor); - *child = new %sChild(); - - ::mozilla::ipc::MessageChannel *childChannel = (*child)->GetIPCChannel(); - ::mozilla::ipc::Side parentSide = - ::mozilla::ipc::ParentSide; - - (*parent)->Open(childChannel, childMessageLoop, parentSide); - return (*parent)->Main(); - } -""" - % (t, t, t, t, t, t, t) - for t in unittests - ] - ) - - child_delete_cases = "\n".join( - [ - """ case %s: { - delete reinterpret_cast<%sChild*>(gChildActor); - return; - } -""" - % (t, t) - for t in unittests + extras - ] - ) - - child_init_cases = "\n".join( - [ - """ case %s: { - %sChild** child = - reinterpret_cast<%sChild**>(&gChildActor); - *child = new %sChild(); - (*child)->Open(transport, parentPid, worker); - return; - } -""" - % (t, t, t, t) - for t in unittests + extras - ] - ) - - templatefile = open(template, "r", encoding="utf-8") - sys.stdout.write( - string.Template(templatefile.read()).substitute( - INCLUDES=includes, - ENUM_VALUES=enum_values, - LAST_ENUM=last_enum, - STRING_TO_ENUMS=string_to_enums, - ENUM_TO_STRINGS=enum_to_strings, - PARENT_DELETE_CASES=parent_delete_cases, - PARENT_ENABLED_CASES_PROC=parent_enabled_cases_proc, - PARENT_MAIN_CASES_PROC=parent_main_cases_proc, - PARENT_ENABLED_CASES_THREAD=parent_enabled_cases_thread, - PARENT_MAIN_CASES_THREAD=parent_main_cases_thread, - CHILD_DELETE_CASES=child_delete_cases, - CHILD_INIT_CASES=child_init_cases, - ) - ) - templatefile.close() - - -if __name__ == "__main__": - main(sys.argv) diff --git a/ipc/ipdl/test/cxx/moz.build b/ipc/ipdl/test/cxx/moz.build deleted file mode 100644 index 196dc09add..0000000000 --- a/ipc/ipdl/test/cxx/moz.build +++ /dev/null @@ -1,38 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -DIRS += ["app"] - -EXPORTS.mozilla._ipdltest += [ - "IPDLUnitTestProcessChild.h", - "IPDLUnitTests.h", - "IPDLUnitTestTypes.h", - "IPDLUnitTestUtils.h", - "TestOffMainThreadPainting.h", -] - -SOURCES += [ - "TestOffMainThreadPainting.cpp", -] - -SOURCES += [ - "!IPDLUnitTests.cpp", - "IPDLUnitTestProcessChild.cpp", - "IPDLUnitTestSubprocess.cpp", -] - -IPDL_SOURCES += [ - "PTestIndirectProtocolParam.ipdlh", - "PTestIndirectProtocolParamFirst.ipdl", - "PTestIndirectProtocolParamManage.ipdl", - "PTestIndirectProtocolParamSecond.ipdl", - "PTestPaintThread.ipdl", - "PTestPriority.ipdl", -] - -include("/ipc/chromium/chromium-config.mozbuild") - -FINAL_LIBRARY = "xul" -- cgit v1.2.3