ipc/ipdl/test/cxx/IPDLUnitTests.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef mozilla__ipdltest_IPDLUnitTests_h
michael@0 7 #define mozilla__ipdltest_IPDLUnitTests_h 1
michael@0 8
michael@0 9 #include "base/message_loop.h"
michael@0 10 #include "base/process.h"
michael@0 11 #include "chrome/common/ipc_channel.h"
michael@0 12
michael@0 13 #include "nsIAppShell.h"
michael@0 14
michael@0 15 #include "nsCOMPtr.h"
michael@0 16 #include "nsDebug.h"
michael@0 17 #include "nsServiceManagerUtils.h" // do_GetService()
michael@0 18 #include "nsWidgetsCID.h" // NS_APPSHELL_CID
michael@0 19 #include "nsXULAppAPI.h"
michael@0 20
michael@0 21
michael@0 22 #define MOZ_IPDL_TESTFAIL_LABEL "TEST-UNEXPECTED-FAIL"
michael@0 23 #define MOZ_IPDL_TESTPASS_LABEL "TEST-PASS"
michael@0 24 #define MOZ_IPDL_TESTINFO_LABEL "TEST-INFO"
michael@0 25
michael@0 26
michael@0 27 namespace mozilla {
michael@0 28 namespace _ipdltest {
michael@0 29
michael@0 30 //-----------------------------------------------------------------------------
michael@0 31 // both processes
michael@0 32 const char* const IPDLUnitTestName();
michael@0 33
michael@0 34 // NB: these are named like the similar functions in
michael@0 35 // xpcom/test/TestHarness.h. The names should nominally be kept in
michael@0 36 // sync.
michael@0 37
michael@0 38 inline void fail(const char* fmt, ...)
michael@0 39 {
michael@0 40 va_list ap;
michael@0 41
michael@0 42 fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL " | %s | ", IPDLUnitTestName());
michael@0 43
michael@0 44 va_start(ap, fmt);
michael@0 45 vfprintf(stderr, fmt, ap);
michael@0 46 va_end(ap);
michael@0 47
michael@0 48 fputc('\n', stderr);
michael@0 49
michael@0 50 NS_RUNTIMEABORT("failed test");
michael@0 51 }
michael@0 52
michael@0 53 inline void passed(const char* fmt, ...)
michael@0 54 {
michael@0 55 va_list ap;
michael@0 56
michael@0 57 printf(MOZ_IPDL_TESTPASS_LABEL " | %s | ", IPDLUnitTestName());
michael@0 58
michael@0 59 va_start(ap, fmt);
michael@0 60 vprintf(fmt, ap);
michael@0 61 va_end(ap);
michael@0 62
michael@0 63 fputc('\n', stdout);
michael@0 64 }
michael@0 65
michael@0 66 //-----------------------------------------------------------------------------
michael@0 67 // parent process only
michael@0 68
michael@0 69 class IPDLUnitTestSubprocess;
michael@0 70
michael@0 71 extern void* gParentActor;
michael@0 72 extern IPDLUnitTestSubprocess* gSubprocess;
michael@0 73
michael@0 74 void IPDLUnitTestMain(void* aData);
michael@0 75
michael@0 76 void QuitParent();
michael@0 77
michael@0 78 //-----------------------------------------------------------------------------
michael@0 79 // child process only
michael@0 80
michael@0 81 extern void* gChildActor;
michael@0 82
michael@0 83 void IPDLUnitTestChildInit(IPC::Channel* transport,
michael@0 84 base::ProcessHandle parent,
michael@0 85 MessageLoop* worker);
michael@0 86
michael@0 87 void QuitChild();
michael@0 88
michael@0 89 } // namespace _ipdltest
michael@0 90 } // namespace mozilla
michael@0 91
michael@0 92
michael@0 93 #endif // ifndef mozilla__ipdltest_IPDLUnitTests_h

mercurial