2001-09-29 00:14:13 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2003-01-18 05:15:14 +03:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-05-31 09:18:19 +04:00
|
|
|
*
|
2003-01-18 05:15:14 +03:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-05-31 09:18:19 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-05-31 09:18:19 +04:00
|
|
|
*
|
2003-01-18 05:15:14 +03:00
|
|
|
* The Original Code is Mozilla.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2003-01-18 05:15:14 +03:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
2003-01-18 05:15:14 +03:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2002
|
2001-09-29 00:14:13 +04:00
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2003-01-18 05:15:14 +03:00
|
|
|
* Darin Fisher <darin@netscape.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2003-01-18 05:15:14 +03:00
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
2001-09-29 00:14:13 +04:00
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2003-01-18 05:15:14 +03:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2003-01-18 05:15:14 +03:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2004-10-22 00:57:17 +04:00
|
|
|
#include "TestCommon.h"
|
2002-01-30 00:22:13 +03:00
|
|
|
#include "nsIComponentRegistrar.h"
|
2005-04-15 03:18:34 +04:00
|
|
|
#include "nsPISocketTransportService.h"
|
2003-01-18 05:15:14 +03:00
|
|
|
#include "nsISocketTransport.h"
|
|
|
|
#include "nsIAsyncInputStream.h"
|
|
|
|
#include "nsIAsyncOutputStream.h"
|
|
|
|
#include "nsIProgressEventSink.h"
|
2000-03-06 00:26:01 +03:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2003-01-18 05:15:14 +03:00
|
|
|
#include "nsIProxyObjectManager.h"
|
|
|
|
#include "nsIRequest.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsMemory.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIFileStreams.h"
|
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIEventQueueService.h"
|
|
|
|
#include "nsIEventQueue.h"
|
|
|
|
#include "nsILocalFile.h"
|
2001-01-24 01:10:34 +03:00
|
|
|
#include "nsNetUtil.h"
|
2003-01-18 05:15:14 +03:00
|
|
|
#include "nsAutoLock.h"
|
|
|
|
#include "prlog.h"
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
#if defined(PR_LOGGING)
|
1999-05-31 09:18:19 +04:00
|
|
|
//
|
2003-01-18 05:15:14 +03:00
|
|
|
// set NSPR_LOG_MODULES=Test:5
|
1999-05-31 09:18:19 +04:00
|
|
|
//
|
2003-01-18 05:15:14 +03:00
|
|
|
static PRLogModuleInfo *gTestLog = nsnull;
|
|
|
|
#endif
|
|
|
|
#define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
|
1999-10-06 12:26:01 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
|
|
|
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
1999-10-06 12:26:01 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
PRBool gDone = PR_FALSE;
|
|
|
|
nsIEventQueue* gEventQ = nsnull;
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
1999-10-06 12:26:01 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
static void *PR_CALLBACK
|
|
|
|
DoneEvent_Handler(PLEvent *ev)
|
1999-10-06 12:26:01 +04:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
gDone = PR_TRUE;
|
|
|
|
return nsnull;
|
1999-10-06 12:26:01 +04:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
static void PR_CALLBACK
|
|
|
|
DoneEvent_Cleanup(PLEvent *ev)
|
1999-10-06 12:26:01 +04:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
delete ev;
|
1999-10-06 12:26:01 +04:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
static void
|
|
|
|
PostDoneEvent()
|
1999-05-31 09:18:19 +04:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
LOG(("PostDoneEvent\n"));
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
PLEvent *ev = new PLEvent();
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
PL_InitEvent(ev, nsnull,
|
|
|
|
DoneEvent_Handler,
|
|
|
|
DoneEvent_Cleanup);
|
|
|
|
|
|
|
|
gEventQ->PostEvent(ev);
|
1999-05-31 09:18:19 +04:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-10-06 05:46:31 +04:00
|
|
|
class MyHandler : public nsIOutputStreamCallback
|
|
|
|
, public nsIInputStreamCallback
|
1999-05-31 09:18:19 +04:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
MyHandler(const char *path,
|
|
|
|
nsIAsyncInputStream *in,
|
|
|
|
nsIAsyncOutputStream *out)
|
|
|
|
: mInput(in)
|
|
|
|
, mOutput(out)
|
|
|
|
, mWriteOffset(0)
|
|
|
|
{
|
|
|
|
mBuf = NS_LITERAL_CSTRING("GET ")
|
|
|
|
+ nsDependentCString(path)
|
|
|
|
+ NS_LITERAL_CSTRING(" HTTP/1.0\r\n\r\n");
|
|
|
|
}
|
|
|
|
virtual ~MyHandler() {}
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
// called on any thread
|
|
|
|
NS_IMETHOD OnOutputStreamReady(nsIAsyncOutputStream *out)
|
|
|
|
{
|
|
|
|
LOG(("OnOutputStreamReady\n"));
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsresult rv;
|
|
|
|
PRUint32 n, count = mBuf.Length() - mWriteOffset;
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
rv = out->Write(mBuf.get() + mWriteOffset, count, &n);
|
1999-07-03 08:14:28 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
LOG((" write returned [rv=%x count=%u]\n", rv, n));
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
if (NS_FAILED(rv) || (n == 0)) {
|
|
|
|
if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
|
|
|
|
LOG((" done writing; starting to read\n"));
|
2003-10-06 05:46:31 +04:00
|
|
|
mInput->AsyncWait(this, 0, 0, nsnull);
|
2003-01-18 05:15:14 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
mWriteOffset += n;
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-10-06 05:46:31 +04:00
|
|
|
return out->AsyncWait(this, 0, 0, nsnull);
|
2000-03-06 00:26:01 +03:00
|
|
|
}
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
// called on any thread
|
|
|
|
NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream *in)
|
|
|
|
{
|
|
|
|
LOG(("OnInputStreamReady\n"));
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsresult rv;
|
|
|
|
PRUint32 n;
|
|
|
|
char buf[500];
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
rv = in->Read(buf, sizeof(buf), &n);
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
LOG((" read returned [rv=%x count=%u]\n", rv, n));
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
if (NS_FAILED(rv) || (n == 0)) {
|
|
|
|
if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
|
|
|
|
PostDoneEvent();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-07-12 10:22:39 +04:00
|
|
|
}
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-10-06 05:46:31 +04:00
|
|
|
return in->AsyncWait(this, 0, 0, nsnull);
|
1999-06-03 09:45:23 +04:00
|
|
|
}
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> mInput;
|
|
|
|
nsCOMPtr<nsIAsyncOutputStream> mOutput;
|
|
|
|
nsCString mBuf;
|
|
|
|
PRUint32 mWriteOffset;
|
|
|
|
};
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS2(MyHandler,
|
2003-10-06 05:46:31 +04:00
|
|
|
nsIOutputStreamCallback,
|
|
|
|
nsIInputStreamCallback)
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
/**
|
|
|
|
* create transport, open streams, and close
|
|
|
|
*/
|
|
|
|
static nsresult
|
|
|
|
RunCloseTest(nsISocketTransportService *sts,
|
|
|
|
const char *host, int port,
|
|
|
|
PRUint32 inFlags, PRUint32 outFlags)
|
1999-05-31 09:18:19 +04:00
|
|
|
{
|
2003-01-18 05:15:14 +03:00
|
|
|
nsresult rv;
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
LOG(("RunCloseTest\n"));
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsISocketTransport> transport;
|
|
|
|
rv = sts->CreateTransport(nsnull, 0,
|
|
|
|
nsDependentCString(host), port, nsnull,
|
|
|
|
getter_AddRefs(transport));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsIInputStream> in;
|
|
|
|
rv = transport->OpenInputStream(inFlags, 0, 0, getter_AddRefs(in));
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> asyncIn = do_QueryInterface(in, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsIOutputStream> out;
|
|
|
|
rv = transport->OpenOutputStream(outFlags, 0, 0, getter_AddRefs(out));
|
|
|
|
nsCOMPtr<nsIAsyncOutputStream> asyncOut = do_QueryInterface(out, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
LOG(("waiting 1 second before closing transport and streams...\n"));
|
|
|
|
PR_Sleep(PR_SecondsToInterval(1));
|
|
|
|
|
|
|
|
// let nsCOMPtr destructors close everything...
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-06-03 09:45:23 +04:00
|
|
|
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
/**
|
|
|
|
* asynchronously read socket stream
|
|
|
|
*/
|
|
|
|
static nsresult
|
|
|
|
RunTest(nsISocketTransportService *sts,
|
|
|
|
const char *host, int port, const char *path,
|
|
|
|
PRUint32 inFlags, PRUint32 outFlags)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
LOG(("RunTest\n"));
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsISocketTransport> transport;
|
|
|
|
rv = sts->CreateTransport(nsnull, 0,
|
|
|
|
nsDependentCString(host), port, nsnull,
|
|
|
|
getter_AddRefs(transport));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsIInputStream> in;
|
|
|
|
rv = transport->OpenInputStream(inFlags, 0, 0, getter_AddRefs(in));
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> asyncIn = do_QueryInterface(in, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsIOutputStream> out;
|
|
|
|
rv = transport->OpenOutputStream(outFlags, 0, 0, getter_AddRefs(out));
|
|
|
|
nsCOMPtr<nsIAsyncOutputStream> asyncOut = do_QueryInterface(out, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
MyHandler *handler = new MyHandler(path, asyncIn, asyncOut);
|
|
|
|
if (handler == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(handler);
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-10-06 05:46:31 +04:00
|
|
|
rv = asyncOut->AsyncWait(handler, 0, 0, nsnull);
|
1999-06-03 09:45:23 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
PLEvent* event;
|
|
|
|
gDone = PR_FALSE;
|
|
|
|
while (!gDone) {
|
|
|
|
rv = gEventQ->WaitForEvent(&event);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
rv = gEventQ->HandleEvent(event);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
1999-06-03 09:45:23 +04:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
NS_RELEASE(handler);
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-06-03 09:45:23 +04:00
|
|
|
}
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
1999-06-03 09:45:23 +04:00
|
|
|
|
1999-05-31 09:18:19 +04:00
|
|
|
int
|
|
|
|
main(int argc, char* argv[])
|
|
|
|
{
|
2004-10-22 00:57:17 +04:00
|
|
|
if (test_common_init(&argc, &argv) != 0)
|
|
|
|
return -1;
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsresult rv;
|
1999-08-14 02:18:34 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
if (argc < 4) {
|
|
|
|
printf("usage: TestSocketTransport <host> <port> <path>\n");
|
|
|
|
return -1;
|
2002-07-04 18:29:25 +04:00
|
|
|
}
|
1999-08-14 02:18:34 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIServiceManager> servMan;
|
|
|
|
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
|
|
|
|
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
|
|
|
|
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
|
|
|
|
if (registrar)
|
|
|
|
registrar->AutoRegister(nsnull);
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
#if defined(PR_LOGGING)
|
|
|
|
gTestLog = PR_NewLogModule("Test");
|
|
|
|
#endif
|
1999-05-31 09:18:19 +04:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
nsCOMPtr<nsIEventQueueService> eventQService =
|
|
|
|
do_GetService(kEventQueueServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = eventQService->CreateMonitoredThreadEventQueue();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2005-04-15 03:18:34 +04:00
|
|
|
nsCOMPtr<nsPISocketTransportService> sts =
|
2003-01-18 05:15:14 +03:00
|
|
|
do_GetService(kSocketTransportServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
LOG(("phase 1 tests...\n"));
|
|
|
|
|
|
|
|
LOG(("flags = { OPEN_UNBUFFERED, OPEN_UNBUFFERED }\n"));
|
|
|
|
rv = RunCloseTest(sts, argv[1], atoi(argv[2]),
|
|
|
|
nsITransport::OPEN_UNBUFFERED,
|
|
|
|
nsITransport::OPEN_UNBUFFERED);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "RunCloseTest failed");
|
|
|
|
|
|
|
|
LOG(("flags = { OPEN_BUFFERED, OPEN_UNBUFFERED }\n"));
|
|
|
|
rv = RunCloseTest(sts, argv[1], atoi(argv[2]),
|
|
|
|
0 /* nsITransport::OPEN_BUFFERED */,
|
|
|
|
nsITransport::OPEN_UNBUFFERED);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "RunCloseTest failed");
|
|
|
|
|
|
|
|
LOG(("flags = { OPEN_UNBUFFERED, OPEN_BUFFERED }\n"));
|
|
|
|
rv = RunCloseTest(sts, argv[1], atoi(argv[2]),
|
|
|
|
nsITransport::OPEN_UNBUFFERED,
|
|
|
|
0 /*nsITransport::OPEN_BUFFERED */);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "RunCloseTest failed");
|
|
|
|
|
|
|
|
LOG(("flags = { OPEN_BUFFERED, OPEN_BUFFERED }\n"));
|
|
|
|
rv = RunCloseTest(sts, argv[1], atoi(argv[2]),
|
|
|
|
0 /*nsITransport::OPEN_BUFFERED */,
|
|
|
|
0 /*nsITransport::OPEN_BUFFERED */);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "RunCloseTest failed");
|
|
|
|
|
|
|
|
LOG(("calling Shutdown on socket transport service:\n"));
|
|
|
|
sts->Shutdown();
|
|
|
|
|
|
|
|
LOG(("calling Init on socket transport service:\n"));
|
|
|
|
sts->Init();
|
|
|
|
|
|
|
|
LOG(("phase 2 tests...\n"));
|
|
|
|
|
|
|
|
LOG(("flags = { OPEN_UNBUFFERED, OPEN_UNBUFFERED }\n"));
|
|
|
|
rv = RunTest(sts, argv[1], atoi(argv[2]), argv[3],
|
|
|
|
nsITransport::OPEN_UNBUFFERED,
|
|
|
|
nsITransport::OPEN_UNBUFFERED);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
|
|
|
|
|
|
|
|
LOG(("flags = { OPEN_BUFFERED, OPEN_UNBUFFERED }\n"));
|
|
|
|
rv = RunTest(sts, argv[1], atoi(argv[2]), argv[3],
|
|
|
|
0 /* nsITransport::OPEN_BUFFERED */,
|
|
|
|
nsITransport::OPEN_UNBUFFERED);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
|
|
|
|
|
|
|
|
LOG(("flags = { OPEN_UNBUFFERED, OPEN_BUFFERED }\n"));
|
|
|
|
rv = RunTest(sts, argv[1], atoi(argv[2]), argv[3],
|
|
|
|
nsITransport::OPEN_UNBUFFERED,
|
|
|
|
0 /*nsITransport::OPEN_BUFFERED */);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
|
|
|
|
|
|
|
|
LOG(("flags = { OPEN_BUFFERED, OPEN_BUFFERED }\n"));
|
|
|
|
rv = RunTest(sts, argv[1], atoi(argv[2]), argv[3],
|
|
|
|
0 /*nsITransport::OPEN_BUFFERED */,
|
|
|
|
0 /*nsITransport::OPEN_BUFFERED */);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
|
|
|
|
|
|
|
|
LOG(("waiting 1 second before calling Shutdown...\n"));
|
|
|
|
PR_Sleep(PR_SecondsToInterval(1));
|
|
|
|
|
|
|
|
LOG(("calling Shutdown on socket transport service:\n"));
|
|
|
|
sts->Shutdown();
|
|
|
|
|
|
|
|
NS_RELEASE(gEventQ);
|
|
|
|
|
|
|
|
// give background threads a chance to finish whatever work they may
|
|
|
|
// be doing.
|
|
|
|
LOG(("waiting 1 second before exiting...\n"));
|
|
|
|
PR_Sleep(PR_SecondsToInterval(1));
|
|
|
|
} // this scopes the nsCOMPtrs
|
|
|
|
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
|
|
|
|
rv = NS_ShutdownXPCOM(nsnull);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
|
|
|
|
return NS_OK;
|
1999-05-31 09:18:19 +04:00
|
|
|
}
|