*not part of the buld*
blackConnect tests update git-svn-id: svn://10.0.0.236/trunk@99925 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
a3532005-66d4-4988-8067-dd1928c60138
|
||||
component://netscape/blackwood/blackconnect/test/mthreads/MThreadComponent1
|
||||
@mozilla/blackwood/blackconnect/test/mthreads/MThreadComponent1;1
|
||||
|
||||
@@ -29,48 +29,102 @@ import java.io.FileOutputStream;
|
||||
|
||||
public class MThreadComponent1 implements iMThreadComponent1, iMThreadComponent {
|
||||
private iMThreadContext context = null;
|
||||
private nsIComponentManager com=null;
|
||||
private int thr=0;
|
||||
private int stg=0;
|
||||
|
||||
public MThreadComponent1() {
|
||||
System.out.println("DEbug:avm:MThreadComponent1 constructor");
|
||||
}
|
||||
|
||||
|
||||
public void initialize(iMThreadContext context) {
|
||||
System.out.println("DEbug:avm:MThreadComponent1:initialize Thread is " + Thread.currentThread().getName());
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void tHack(nsIComponentManager cm) {
|
||||
nsIFactory factory = null;
|
||||
System.out.println("DEbug:avm:tHack");
|
||||
if(cm == null) {
|
||||
System.err.println("DEbug:avm:tHack:ComponentManager is NULL!!!!!");
|
||||
return;
|
||||
}
|
||||
com=cm;
|
||||
factory = cm.findFactory(iMThreadContextCID);
|
||||
|
||||
if(factory == null) {
|
||||
System.err.println("DEbug:avm:tHack:Factory is NULL!!!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
Object res = factory.createInstance(null, iMThreadContext.IID);
|
||||
if(res == null) {
|
||||
System.err.println("DEbug:avm:tHack:Instance is NULL!!!!!");
|
||||
return;
|
||||
}
|
||||
context = (iMThreadContext)res;
|
||||
if(context == null) {
|
||||
System.err.println("Create instance failed!! Server is NULLLLLLLLLLLLLLLLLLL");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public iMThreadComponent loadComponent(CID classID) {
|
||||
System.out.println("DEbug:avm:MThreadComponent1:loadComponent");
|
||||
nsIComponentManager cm = context.getComponentManager();
|
||||
|
||||
nsIFactory factory = cm.findFactory(classID);
|
||||
if(factory == null) {
|
||||
System.out.println("DEbug:avm:Factory is NULL!!!!!");
|
||||
System.err.println("DEbug:avm:loadComponent:Factory is NULL!!!!!");
|
||||
return null;
|
||||
}
|
||||
|
||||
iMThreadComponent component = (iMThreadComponent)factory.createInstance(null, iMThreadComponent.IID);
|
||||
return component;
|
||||
}
|
||||
|
||||
/* void Execute (); */
|
||||
public void execute(String tName) {
|
||||
|
||||
public void execute(int thread, int stage) {
|
||||
System.out.println("DEbug:avm:MThreadComponent1:execute.");
|
||||
String cThreadName = Thread.currentThread().getName();
|
||||
if(tName.equals(cThreadName)) {
|
||||
System.out.println("PASSED: original and expected names equals to " + tName);
|
||||
} else {
|
||||
System.out.println("FAILED: Current thread name is " + cThreadName + " instead of " + tName );
|
||||
}
|
||||
CID classID = new CID(context.getNext());
|
||||
iMThreadComponent component = loadComponent(classID);
|
||||
if(component == null) {
|
||||
System.out.println("Can't load component");
|
||||
return;
|
||||
}
|
||||
System.out.println("Initialize of " + component + " called in thread " + cThreadName);
|
||||
component.initialize(context);
|
||||
(new ExecutionThread(component)).run();
|
||||
//component.execute();
|
||||
|
||||
try{
|
||||
DataOutputStream f=new DataOutputStream(new FileOutputStream(context.getResFile(),true));
|
||||
f.writeBytes((new Integer(thread)).toString()+","+(new Integer(stage)).toString()+","+cThreadName+"\n");
|
||||
f.close();
|
||||
} catch(Exception e) {
|
||||
System.err.println("Exception during writing the file: " +e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CID classID = new CID(context.getContractID(thread+1,stage+1));
|
||||
|
||||
if (!(classID.toString().equals("org.mozilla.xpcom.CID@null"))){
|
||||
iMThreadComponent component = loadComponent(classID);
|
||||
if(component == null) {
|
||||
System.err.println("Can't load component");
|
||||
} else {
|
||||
component.initialize(context);
|
||||
component.tHack(com);
|
||||
(new ExecutionThread(component)).run(thread+1,stage+1);
|
||||
}
|
||||
}
|
||||
|
||||
classID = new CID(context.getContractID(thread,stage+1));
|
||||
|
||||
if (!(classID.toString().equals("org.mozilla.xpcom.CID@null"))){
|
||||
iMThreadComponent component = loadComponent(classID);
|
||||
if(component == null) {
|
||||
System.err.println("Can't load component");
|
||||
} else {
|
||||
component.initialize(context);
|
||||
component.tHack(com);
|
||||
component.execute(thread,stage+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Object queryInterface(IID iid) {
|
||||
System.out.println("DEbug:avm:MThreadComponent1::queryInterface iid="+iid);
|
||||
if ( iid.equals(nsISupports.IID)
|
||||
@@ -81,13 +135,12 @@ public class MThreadComponent1 implements iMThreadComponent1, iMThreadComponent
|
||||
}
|
||||
}
|
||||
|
||||
static CID J2XINServerCID = new CID("1ddc5b10-9852-11d4-aa22-00a024a8bbac");
|
||||
static CID iMThreadContextCID = new CID("139b8350-280a-46d0-8afc-f1939173c2ea");
|
||||
static {
|
||||
try {
|
||||
Class nsIComponentManagerClass =
|
||||
Class.forName("org.mozilla.xpcom.nsIComponentManager");
|
||||
InterfaceRegistry.register(nsIComponentManagerClass);
|
||||
|
||||
Class iMThreadComponentClass =
|
||||
Class.forName("org.mozilla.xpcom.iMThreadComponent");
|
||||
InterfaceRegistry.register(iMThreadComponentClass);
|
||||
@@ -104,11 +157,3 @@ public class MThreadComponent1 implements iMThreadComponent1, iMThreadComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=../../../../../..
|
||||
topsrcdir = $(DEPTH)
|
||||
|
||||
@@ -40,7 +40,7 @@ interface iMThreadComponent1 : nsISupports
|
||||
{0x80, 0x67, 0xdd, 0x19, 0x28, 0xc6, 0x01, 0x38} \
|
||||
}
|
||||
|
||||
#define MTHREADCOMPONENT1_PROGID "component://netscape/blackwood/blackconnect/test/mthreads/MThreadComponent1"
|
||||
#define MTHREADCOMPONENT1_PROGID "@mozilla/blackwood/blackconnect/test/mthreads/MThreadComponent1;1"
|
||||
|
||||
%}
|
||||
|
||||
|
||||
@@ -18,36 +18,41 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..\..\..
|
||||
topsrcdir = $(DEPTH)
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
include <$(topsrcdir)\config\rules.mak>
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
JAVA_SRC = \
|
||||
MThreadComponent1.java
|
||||
MThreadComponent1.java \
|
||||
$(NULL)
|
||||
|
||||
JDIRS = .
|
||||
JAVAC_PROG=$(JDKHOME)\bin\javac
|
||||
JAVAC_FLAGS=-classpath $(CLASSPATH);$(JAVA_DESTPATH) -d $(JAVA_DESTPATH)
|
||||
|
||||
include <$(topsrcdir)\config\rules.mak>
|
||||
include <$(topsrcdir)\config\javarules.mak>
|
||||
|
||||
JAVAI_SRC = \
|
||||
iMThreadComponent1.java
|
||||
MThreadComponent1.jar.comp: manifest MThreadComponent1.class
|
||||
$(JDKHOME)\bin\jar cvfm MThreadComponent1.jar.comp manifest *.class
|
||||
|
||||
MThreadComponent1.class:
|
||||
$(JDKHOME)\bin\javac -classpath $(DEPTH)\dist\classes $(JAVA_SRC)
|
||||
|
||||
export::
|
||||
$(JDKHOME)\bin\javac -classpath $(DEPTH)\dist\classes -d $(DEPTH)\dist\classes $(JAVAI_SRC)
|
||||
|
||||
install-component: MThreadComponent1.jar.comp MThreadComponent1.jar.info
|
||||
copy MThreadComponent1.jar* $(DIST)\bin\components
|
||||
clobber::
|
||||
del /f *.class *.jar.comp
|
||||
del /f $(DIST)\bin\components\MThreadComponent1.jar.*
|
||||
del /f $(DIST)\..\classes\org\mozilla\xpcom\iMThreadComponent1.class
|
||||
del /f $(DIST)\..\classes\MThreadComponent1.class
|
||||
|
||||
clobber_all:: clobber
|
||||
install:: install-component
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "stdio.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "MThreadComponent2.h"
|
||||
@@ -31,10 +32,25 @@
|
||||
#include <stdlib.h>
|
||||
#include "nsID.h"
|
||||
|
||||
iMThreadContext* context;
|
||||
void* iThread;
|
||||
void* eThread;
|
||||
|
||||
iMThreadContext* context=NULL;
|
||||
iMThreadComponent* tComponent=NULL;
|
||||
void* iThread=NULL;
|
||||
void* eThread=NULL;
|
||||
int newT=0, newS=0;
|
||||
|
||||
void Exec(void* arg) {
|
||||
tComponent->Initialize(context);
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "ERROR: Can't get GlobalComponentManager!!\n");
|
||||
return;
|
||||
}
|
||||
tComponent->THack(cm);
|
||||
tComponent->Execute(newT,newS);
|
||||
}
|
||||
|
||||
MThreadComponent2Impl::MThreadComponent2Impl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
@@ -54,37 +70,77 @@ NS_IMETHODIMP MThreadComponent2Impl::Initialize(iMThreadContext* c){
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MThreadComponent2Impl::Execute(const char* tName){
|
||||
printf("MThreadComponent2Impl::Execute. Thread is %s\n", tName);
|
||||
eThread = PR_GetCurrentThread();
|
||||
if(eThread == iThread) {
|
||||
printf("###Execute and initialize were executed in one thread\n");
|
||||
}else {
|
||||
printf("###Execute and initialize were executed in DIFFERENT threads\n");
|
||||
}
|
||||
char* progID;
|
||||
context->GetNext(&progID);
|
||||
nsCID classID;
|
||||
classID.Parse(progID);
|
||||
printf("MThreadComponent2Impl::Execute. progID is %s\n",progID);
|
||||
iMThreadComponent* tComponent;
|
||||
nsresult rv = nsComponentManager::CreateInstance(classID,
|
||||
nsnull,
|
||||
NS_GET_IID(iMThreadComponent),
|
||||
(void**)&tComponent);
|
||||
if(NS_FAILED(rv)) {
|
||||
printf("MThreadComponent2Impl:Create instance failed from %s!!!",classID.ToString());
|
||||
return rv;
|
||||
}
|
||||
tComponent->Initialize(context);
|
||||
tComponent->Execute(tName);
|
||||
|
||||
NS_IMETHODIMP MThreadComponent2Impl::THack(nsIComponentManager* cm){
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP MThreadComponent2Impl::Execute(int thread, int stage){
|
||||
|
||||
char* tmp=(char*)PR_Malloc(sizeof(char*));
|
||||
tmp="";
|
||||
FILE *file;
|
||||
|
||||
printf("MThreadComponent2Impl::Execute.\n");
|
||||
eThread = PR_GetCurrentThread();
|
||||
if(eThread == iThread) {
|
||||
printf("###Execute and initialize were executed in one thread\n");
|
||||
} else {
|
||||
printf("###Execute and initialize were executed in DIFFERENT threads\n");
|
||||
}
|
||||
|
||||
char* progID;
|
||||
char* res=(char*)PR_Malloc(sizeof(char*));
|
||||
|
||||
context->GetResFile(&res);
|
||||
|
||||
if ((file = fopen(res, "a+t")) == NULL) {
|
||||
fprintf(stderr, "ERROR: can't open file %s\n",res);
|
||||
return NS_OK;
|
||||
}
|
||||
sprintf(tmp,"%d,%d,",thread,stage);
|
||||
fwrite(tmp,1,strlen(tmp),file);
|
||||
sprintf(tmp,"%d\n",eThread);
|
||||
fwrite(tmp,1,strlen(tmp),file);
|
||||
fclose(file);
|
||||
|
||||
context->GetContractID(thread,stage+1,&progID);
|
||||
nsCID classID;
|
||||
|
||||
classID.Parse(progID);
|
||||
nsresult rv = nsComponentManager::CreateInstance(classID,
|
||||
nsnull,
|
||||
NS_GET_IID(iMThreadComponent),
|
||||
(void**)&tComponent);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "MThreadComponent2Impl:Create instance failed from %s!!!\n",classID.ToString());
|
||||
} else {
|
||||
tComponent->Initialize(context);
|
||||
nsIComponentManager* cm;
|
||||
rv = NS_GetGlobalComponentManager(&cm);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "ERROR: Can't get GlobalComponentManager!!\n");
|
||||
return NS_OK;
|
||||
}
|
||||
tComponent->THack(cm);
|
||||
tComponent->Execute(thread,stage+1);
|
||||
}
|
||||
|
||||
|
||||
context->GetContractID(thread+1,stage+1,&progID);
|
||||
classID.Parse(progID);
|
||||
rv = nsComponentManager::CreateInstance(classID, nsnull,
|
||||
NS_GET_IID(iMThreadComponent),
|
||||
(void**)&tComponent);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "MThreadComponent2Impl: 2: Create instance failed from %s!!!\n",progID);
|
||||
} else {
|
||||
newT=thread+1;
|
||||
newS=stage+1;
|
||||
PR_CreateThread(PR_USER_THREAD, Exec,
|
||||
this, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_IMTHREADCOMPONENT2
|
||||
NS_DECL_IMTHREADCOMPONENT
|
||||
NS_DECL_IMTHREADCOMPONENT
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -29,18 +29,10 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(MThreadComponent2Impl)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "X2JIN Client Test Component", MTHREADCOMPONENT2_CID, MTHREADCOMPONENT2_PROGID, MThreadComponent2ImplConstructor,
|
||||
{ "MultiThread Component 2", MTHREADCOMPONENT2_CID, MTHREADCOMPONENT2_PROGID, MThreadComponent2ImplConstructor,
|
||||
NULL /* NULL if you dont need one */,
|
||||
NULL /* NULL if you dont need one */
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("MThreadComponent2Factory", components)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=../../../../../..
|
||||
topsrcdir = $(DEPTH)
|
||||
|
||||
@@ -40,7 +40,7 @@ interface iMThreadComponent2 : nsISupports
|
||||
{0xb8, 0xdf, 0x4c, 0x28, 0xc0, 0x68, 0x68, 0x63} \
|
||||
}
|
||||
|
||||
#define MTHREADCOMPONENT2_PROGID "component://netscape/blackwood/blackconnect/test/mthreads/MThreadComponent2"
|
||||
#define MTHREADCOMPONENT2_PROGID "@mozilla/blackwood/blackconnect/test/mthreads/MThreadComponent2;1"
|
||||
|
||||
%}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..\..\..
|
||||
topsrcdir = $(DEPTH)
|
||||
@@ -29,6 +31,10 @@ MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = $(MODULE)
|
||||
DLL =.\$(OBJDIR)\$(DLLNAME).dll
|
||||
COMPONENT = 1
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\MThreadComponent2.obj \
|
||||
@@ -39,20 +45,19 @@ XPIDLSRCS = \
|
||||
.\iMThreadComponent2.idl \
|
||||
$(NULL)
|
||||
|
||||
JAVAI = iMThreadComponent2.java
|
||||
|
||||
LLIBS =$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib
|
||||
|
||||
JDIRS = .
|
||||
JAVAC_PROG=$(JDKHOME)\bin\javac
|
||||
JAVAC_FLAGS=-classpath $(CLASSPATH);$(JAVA_DESTPATH) -d $(JAVA_DESTPATH)
|
||||
|
||||
include <$(topsrcdir)\config\rules.mak>
|
||||
include <$(topsrcdir)\config\javarules.mak>
|
||||
|
||||
javai:
|
||||
echo $(JDKHOME)\bin\javac -classpath $(DEPTH)\dist\classes -d $(DEPTH)\dist\classes $(JAVAI)
|
||||
$(JDKHOME)\bin\javac -classpath $(DEPTH)\dist\classes -d $(DEPTH)\dist\classes $(JAVAI)
|
||||
|
||||
install:: $(DLL) javai
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
del /f $(DIST)\bin\components\$(DLLNAME).dll
|
||||
del /f $(DIST)\bin\components\$(DLLNAME).xpt
|
||||
del /f $(DIST)\..\classes\org\mozilla\xpcom\iMThreadComponent2.class
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=../../../../..
|
||||
topsrcdir = $(DEPTH)
|
||||
@@ -30,7 +32,6 @@ DIRS= \
|
||||
context \
|
||||
1 \
|
||||
2 \
|
||||
3 \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* ExecutionThread.java
|
||||
*/
|
||||
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/
|
||||
|
||||
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.
|
||||
|
||||
The Original Code is mozilla.org code.
|
||||
|
||||
The Initial Developer of the Original Code is Sun Microsystems,
|
||||
Inc. Portions created by Sun are
|
||||
Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Client QA Team, St. Petersburg, Russia
|
||||
*/
|
||||
|
||||
import org.mozilla.xpcom.*;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -34,14 +50,13 @@ public class ExecutionThread extends Thread {
|
||||
public int timeoutGen() {
|
||||
return (int)Math.round(Math.random()*MAX_TIMEOUT);
|
||||
}
|
||||
public void run(){
|
||||
public void run(int t, int s){
|
||||
try {
|
||||
if(timeout == Integer.MAX_VALUE) {
|
||||
timeout = timeoutGen();
|
||||
}
|
||||
System.out.println("ExecutionThread(" + getName() + ") sleep to " + timeout);
|
||||
sleep(timeout);
|
||||
component.execute(getName());
|
||||
component.execute(t,s);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Execution thread had been interrupted");
|
||||
}
|
||||
|
||||
@@ -30,16 +30,21 @@
|
||||
#include <stdlib.h>
|
||||
#include "MThreadContext.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
#include "nsID.h"
|
||||
#include "prio.h"
|
||||
#include "prprf.h"
|
||||
|
||||
nsIComponentManager* cm=NULL;
|
||||
char* resFile=(char*)PR_Malloc(sizeof(char*));
|
||||
char* inFile=(char*)PR_Malloc(sizeof(char*));
|
||||
char* outFile=(char*)PR_Malloc(sizeof(char*));
|
||||
|
||||
nsIComponentManager* cm;
|
||||
char **componentList;
|
||||
int currentPosition = 0;
|
||||
#define MT_COMPONENT_LIST_VAR_NAME "MT_COMPONENT_LIST"
|
||||
|
||||
|
||||
int threads=0, stages=0, nRead=0;
|
||||
|
||||
MThreadContextImpl::MThreadContextImpl()
|
||||
{
|
||||
@@ -48,8 +53,26 @@ MThreadContextImpl::MThreadContextImpl()
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "ERROR: Can't get GlobalComponentManager!!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!makeParamFile()) printf("Something is going wrong :-(.\n");
|
||||
|
||||
char* cont=(char*)PR_Malloc(sizeof(char*));
|
||||
GetPath(PR_TRUE, &cont);
|
||||
|
||||
int j=0, k=0;
|
||||
PRBool isEnd=PR_FALSE;
|
||||
for(PRUint32 i=0;i<PL_strlen(cont);i++) {
|
||||
switch(cont[i]) {
|
||||
case 10: j++;stages=k;k=0;break;
|
||||
case 13: break;
|
||||
case '-': isEnd=PR_TRUE;break;
|
||||
default: k++;break;
|
||||
}
|
||||
threads=j;
|
||||
if (isEnd) break;
|
||||
}
|
||||
componentList = LoadComponentList();
|
||||
}
|
||||
|
||||
MThreadContextImpl::~MThreadContextImpl()
|
||||
@@ -59,123 +82,242 @@ MThreadContextImpl::~MThreadContextImpl()
|
||||
|
||||
NS_IMPL_ISUPPORTS1(MThreadContextImpl, iMThreadContext);
|
||||
|
||||
|
||||
NS_IMETHODIMP MThreadContextImpl::GetNext(char **_retstr) {
|
||||
nsCID aClass;
|
||||
if(componentList == NULL) {
|
||||
*_retstr = NULL;
|
||||
return NS_OK; //nb
|
||||
}
|
||||
if(componentList[currentPosition]) {
|
||||
*_retstr = componentList[currentPosition];
|
||||
printf("MThreadContextImpl::GetNext. ContractID = %s\n",*_retstr);
|
||||
nsresult rv = cm->ContractIDToClassID(*_retstr, &aClass);
|
||||
if(NS_FAILED(rv)) {
|
||||
printf("MThreadContextImpl::GetNext. Can't convert ContractID to ClassID\n");
|
||||
*_retstr = NULL;
|
||||
return NS_OK;
|
||||
}else {
|
||||
printf("MThreadContextImpl::GetNext. SUCCESS convert ContractID to ClassID\n");
|
||||
}
|
||||
*_retstr = aClass.ToString();
|
||||
printf("MThreadContextImpl::GetNext. ClassID = %s\n",*_retstr);
|
||||
currentPosition++;
|
||||
} else {
|
||||
*_retstr = NULL;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
/*
|
||||
NS_IMETHODIMP MThreadContextImpl::Initialize(const char* serverProgID)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
NS_IMETHODIMP MThreadContextImpl::GetStages(int *_retval) {
|
||||
*_retval=stages;
|
||||
return *_retval;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MThreadContextImpl::Execute(){
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
NS_IMETHODIMP MThreadContextImpl::GetThreads(int *_retval) {
|
||||
*_retval=threads;
|
||||
return *_retval;
|
||||
}
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP MThreadContextImpl::GetResFile(char **_retval) {
|
||||
*_retval=resFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP MThreadContextImpl::GetContractID(int i, int j, char **_retstr) {
|
||||
|
||||
nsCID aClass;
|
||||
int stg=0, thr=0;
|
||||
char* tmp=NULL;
|
||||
char* tmp2=NULL;
|
||||
char* first=NULL;
|
||||
char* tokens[256];
|
||||
char* id[256];
|
||||
|
||||
GetStages(&stg);
|
||||
|
||||
if((i<0)||(i>stg)) {
|
||||
fprintf(stderr, "\nComponent index is out of array bounds!!!\n");
|
||||
*_retstr="NULL";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char* cont=(char*)PR_Malloc(sizeof(char*));
|
||||
GetPath(PR_FALSE, &cont);
|
||||
GetThreads(&thr);
|
||||
char** paths=(char**)PR_Malloc(sizeof(char*)*thr);
|
||||
int jj=0, kk=0;
|
||||
|
||||
tmp=(char*)PR_Malloc(sizeof(char*)*1);
|
||||
tmp2=(char*)PR_Malloc(sizeof(char*)*1);
|
||||
first=(char*)PR_Malloc(sizeof(char*)*1);
|
||||
|
||||
sprintf(tmp,"%d,%d,",i,j);
|
||||
|
||||
int strs=0;
|
||||
for(int h=0;h<nRead;h++) if(cont[h]=='\n') strs++;
|
||||
|
||||
first=strtok(cont,"\n");
|
||||
tokens[0]=first;
|
||||
|
||||
for(int g=0;g<strs-1;g++) {
|
||||
tokens[g+1]=strtok(NULL,"\n");
|
||||
}
|
||||
|
||||
PRBool is=PR_FALSE;
|
||||
|
||||
for(int hh=0;hh<strs;hh++) {
|
||||
|
||||
char* t1=strtok(tokens[hh],",");
|
||||
char* t2=strtok(NULL,",");
|
||||
id[hh]=strtok(NULL,",");
|
||||
sprintf(tmp2,"%s,%s,",t1,t2);
|
||||
|
||||
if(PL_strncmp(tmp,tmp2,PL_strlen(tmp))==0) {
|
||||
*_retstr=id[hh];
|
||||
is=PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(!is) {
|
||||
*_retstr="NULL";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult rv = cm->ContractIDToClassID(*_retstr, &aClass);
|
||||
|
||||
if(NS_FAILED(rv)) {
|
||||
printf("MThreadContextImpl::GetContractID. Can't convert ContractID to ClassID\n");
|
||||
*_retstr = "NULL";
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*_retstr = aClass.ToString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MThreadContextImpl::GetComponentManager(nsIComponentManager **_retval) {
|
||||
*_retval = cm;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char** MThreadContextImpl::LoadComponentList() {
|
||||
NS_IMETHODIMP MThreadContextImpl::GetPath(PRBool in, char **_retval) {
|
||||
|
||||
struct stat st;
|
||||
FILE *file = NULL;
|
||||
char *content;
|
||||
int nRead, nTests, count = 0;
|
||||
char *pos, *pos1;
|
||||
char **testList;
|
||||
char *lstFile = PR_GetEnv(MT_COMPONENT_LIST_VAR_NAME);
|
||||
if(lstFile == NULL) {
|
||||
fprintf(stderr, "ERROR: %s value is'n set\n",MT_COMPONENT_LIST_VAR_NAME);
|
||||
return NULL;
|
||||
}
|
||||
char* content=NULL;
|
||||
char* filo=NULL;
|
||||
int count = 0;
|
||||
|
||||
if (in) filo=inFile;
|
||||
else filo=outFile;
|
||||
|
||||
if (stat(lstFile, &st) < 0) {
|
||||
fprintf(stderr, "ERROR: can't get stat from file %s\n",lstFile);
|
||||
if(filo == NULL) {
|
||||
fprintf(stderr, "ERROR: %s value is'n set\n",MT_COMPONENT_LIST_VAR_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (stat(filo, &st) < 0) {
|
||||
fprintf(stderr, "ERROR: can't get stat from file %s\n",filo);
|
||||
return NULL;
|
||||
}
|
||||
content = (char*)calloc(1, st.st_size+1);
|
||||
if ((file = fopen(lstFile, "r")) == NULL) {
|
||||
fprintf(stderr, "ERROR: can't open file %s\n",lstFile);
|
||||
content = (char*)PR_Malloc(1*(st.st_size+1));
|
||||
if ((file = fopen(filo, "r+t")) == NULL) {
|
||||
fprintf(stderr, "ERROR: can't open file %s\n",filo);
|
||||
return NULL;
|
||||
}
|
||||
if ((nRead = fread(content, 1, st.st_size, file)) < st.st_size) {
|
||||
fprintf(stderr, "WARNING: can't read entire file in text mode (%d of %d) !\n", nRead, st.st_size);
|
||||
//return;
|
||||
}
|
||||
content[nRead] = 0;
|
||||
printf("File content: %s\n", content);
|
||||
fclose(file);
|
||||
|
||||
//allocate maximal possible size
|
||||
nTests = countChars(content, '\n') + 2;
|
||||
printf("nTests = %d\n", nTests);
|
||||
testList = (char**)calloc(sizeof(char*), nTests);
|
||||
testList[0] = 0;
|
||||
pos = content;
|
||||
while((pos1 = PL_strchr(pos, '\n'))) {
|
||||
*pos1 = 0;
|
||||
if(PL_strlen(pos) > 0 && *pos != '#') {
|
||||
//printf("First char: %c\n", *pos);
|
||||
testList[count++] = PL_strdup(pos);
|
||||
}
|
||||
pos = pos1+1;
|
||||
if (!(*pos)) {
|
||||
printf("Parser done: %d .. ", count);
|
||||
testList[count] = 0;
|
||||
printf("ok\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
//If there is no \n after last line
|
||||
if (PL_strlen(pos) > 0 && *pos != '#') {
|
||||
testList[count++] = PL_strdup(pos);
|
||||
testList[count] = 0;
|
||||
}
|
||||
//free(content);
|
||||
return testList;
|
||||
|
||||
fclose(file);
|
||||
*_retval=content;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int MThreadContextImpl::countChars(char* buf, char ch) {
|
||||
char *pos = buf;
|
||||
int count = 0;
|
||||
PRBool MThreadContextImpl::makeParamFile() {
|
||||
PRBool isMade=PR_FALSE;
|
||||
struct stat st;
|
||||
FILE *file=NULL, *file2=NULL;
|
||||
char* content=(char*)PR_Malloc(sizeof(char*));
|
||||
int j=0, k=0;
|
||||
int objects=0;
|
||||
char paths[100][100];
|
||||
|
||||
while((pos = PL_strchr(pos, ch))) {
|
||||
pos++;
|
||||
count++;
|
||||
sprintf(inFile,"%s%s",PR_GetEnv(MT_COMPONENT_LIST_VAR_NAME),"threads.dat");
|
||||
sprintf(outFile,"%s%s",PR_GetEnv(MT_COMPONENT_LIST_VAR_NAME),"MTTest.lst");
|
||||
sprintf(resFile,"%s%s",PR_GetEnv(MT_COMPONENT_LIST_VAR_NAME),"Results.dat");
|
||||
|
||||
if ((file = fopen(inFile, "r+t")) == NULL) {
|
||||
fprintf(stderr, "ERROR: can't open file %s\n",inFile);
|
||||
return isMade;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
stat(inFile,&st);
|
||||
content = (char*)PR_Malloc(1*(st.st_size+1));
|
||||
|
||||
if ((nRead = fread(content, 1, st.st_size, file)) < st.st_size) {
|
||||
fprintf(stderr, "WARNING: can't read entire file in text mode (%d of %d) !\n", nRead, st.st_size);
|
||||
}
|
||||
|
||||
int i=0; stages=0; threads=0;
|
||||
while(content[i]!='-') {
|
||||
if(content[i]=='\n') threads++;
|
||||
if((content[i]!='\n')&&(content[i]!=13)) stages=stages+1;
|
||||
i++;
|
||||
}
|
||||
|
||||
stages=stages/threads;
|
||||
|
||||
rewind(file);
|
||||
if ((nRead = fread(content, 1, st.st_size, file)) < st.st_size) {
|
||||
fprintf(stderr, "WARNING: can't read entire file in text mode (%d of %d) !\n", nRead, st.st_size);
|
||||
}
|
||||
|
||||
i=k=j=0;
|
||||
|
||||
while(content[i]!='-') {
|
||||
switch(content[i]) {
|
||||
case '0x0d':break;
|
||||
case '\n':j++;k=0;break;
|
||||
default:paths[j][k]=content[i];k++;if(content[i]!=' ') objects++;break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
if ((file2 = fopen(outFile, "w+t")) == NULL) {
|
||||
fprintf(stderr, "ERROR: can't open file %s\n",outFile);
|
||||
return isMade;
|
||||
}
|
||||
|
||||
char t[1];
|
||||
char tmp[256];
|
||||
|
||||
rewind(file);
|
||||
if ((nRead = fread(content, 1, st.st_size, file)) < st.st_size) {
|
||||
fprintf(stderr, "WARNING: can't read entire file in text mode (%d of %d) !\n", nRead, st.st_size);
|
||||
}
|
||||
|
||||
content=PL_strpbrk(content,"-");
|
||||
int contentLength=PL_strlen(content);
|
||||
|
||||
|
||||
for(int ii=0;ii<threads;ii++)
|
||||
for(int jj=0;jj<stages;jj++) {
|
||||
switch(paths[ii][jj]) {
|
||||
case ' ':
|
||||
case '\n':break;
|
||||
default: {
|
||||
sprintf(tmp,"%d",ii);
|
||||
fwrite((void*)tmp,1,PL_strlen(tmp),file2);
|
||||
|
||||
t[0]=',';
|
||||
fwrite((void*)t,1,1,file2);
|
||||
sprintf(tmp,"%d",jj);
|
||||
fwrite((void*)tmp,1,PL_strlen(tmp),file2);
|
||||
fwrite((void*)t,1,1,file2);
|
||||
|
||||
char con[256];
|
||||
|
||||
for(int h=0;h<contentLength;h++) {
|
||||
if((content[h]==',')&&(paths[ii][jj]==content[h-1])) {
|
||||
sprintf(tmp,"%c%c",content[h-1],content[h]);
|
||||
sprintf(tmp,"%s",PL_strstr(content,tmp));
|
||||
sprintf(tmp,"%s",strtok(tmp,"\n"));
|
||||
for(unsigned int hh=0;hh<PL_strlen(tmp);hh++)
|
||||
con[hh]=tmp[hh+2];
|
||||
con[hh+1]='\0';
|
||||
fwrite((void*)con,1,PL_strlen(con),file2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
t[0]='\n';
|
||||
fwrite((void*)t,1,1,file2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
fclose(file2);
|
||||
isMade=PR_TRUE;
|
||||
|
||||
return isMade;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ class MThreadContextImpl : public iMThreadContext
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMTHREADCONTEXT
|
||||
char** LoadComponentList();
|
||||
int countChars(char* buf, char ch);
|
||||
PRBool makeParamFile();
|
||||
|
||||
MThreadContextImpl();
|
||||
virtual ~MThreadContextImpl();
|
||||
@@ -46,13 +45,3 @@ public:
|
||||
virtual ~_MYCLASS_();
|
||||
/* additional members */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(MThreadContextImpl)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "J2XIN Server Test Component", MTHREADCONTEXT_CID, MTHREADCONTEXT_PROGID, MThreadContextImplConstructor,
|
||||
{ "MTContext Test Component", MTHREADCONTEXT_CID, MTHREADCONTEXT_PROGID, MThreadContextImplConstructor,
|
||||
NULL /* NULL if you dont need one */,
|
||||
NULL /* NULL if you dont need one */
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=../../../../../..
|
||||
topsrcdir = $(DEPTH)
|
||||
@@ -51,10 +53,3 @@ export::
|
||||
$(JDKHOME)/bin/javac -classpath $(DIST)/classes -d $(DIST)/classes $(JAVAI_SRC)
|
||||
$(JDKHOME)/bin/javac -classpath $(DIST)/classes -d $(DIST)/classes $(JAVA_SRC)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,5 +28,6 @@
|
||||
interface iMThreadComponent : nsISupports
|
||||
{
|
||||
void Initialize(in iMThreadContext c);
|
||||
void Execute(in string tName);
|
||||
void THack(in nsIComponentManager cm);
|
||||
void Execute(in long thread, in long stage);
|
||||
};
|
||||
|
||||
@@ -23,8 +23,11 @@ public interface iMThreadComponent extends nsISupports
|
||||
/* void Initialize (in iMThreadContext c); */
|
||||
public void initialize(iMThreadContext c);
|
||||
|
||||
/* void Execute (in string tName); */
|
||||
public void execute(String tName);
|
||||
/* void THack (in nsIComponentManager cm); */
|
||||
public void tHack(nsIComponentManager cm);
|
||||
|
||||
/* void Execute (in long thread, in long stage); */
|
||||
public void execute(int thread, int stage);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,19 @@
|
||||
#ifndef __gen_iMThreadContext_h__
|
||||
#define __gen_iMThreadContext_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#ifndef __gen_nsISupports_h__
|
||||
#include "nsISupports.h"
|
||||
#endif
|
||||
|
||||
#ifndef __gen_nsIComponentManager_h__
|
||||
#include "nsIComponentManager.h"
|
||||
#endif
|
||||
|
||||
/* For IDL files that don't want to include root IDL files. */
|
||||
#ifndef NS_NO_VTABLE
|
||||
#define NS_NO_VTABLE
|
||||
#endif
|
||||
|
||||
/* starting interface: iMThreadContext */
|
||||
#define IMTHREADCONTEXT_IID_STR "a7b26685-9816-4eb6-a075-36f539a7a823"
|
||||
@@ -21,8 +31,20 @@ class NS_NO_VTABLE iMThreadContext : public nsISupports {
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(IMTHREADCONTEXT_IID)
|
||||
|
||||
/* string GetNext (); */
|
||||
NS_IMETHOD GetNext(char **_retval) = 0;
|
||||
/* long GetStages (); */
|
||||
NS_IMETHOD GetStages(PRInt32 *_retval) = 0;
|
||||
|
||||
/* long GetThreads (); */
|
||||
NS_IMETHOD GetThreads(PRInt32 *_retval) = 0;
|
||||
|
||||
/* string GetResFile (); */
|
||||
NS_IMETHOD GetResFile(char **_retval) = 0;
|
||||
|
||||
/* string GetPath (in boolean i); */
|
||||
NS_IMETHOD GetPath(PRBool i, char **_retval) = 0;
|
||||
|
||||
/* string GetContractID (in long i, in long j); */
|
||||
NS_IMETHOD GetContractID(PRInt32 i, PRInt32 j, char **_retval) = 0;
|
||||
|
||||
/* nsIComponentManager GetComponentManager (); */
|
||||
NS_IMETHOD GetComponentManager(nsIComponentManager **_retval) = 0;
|
||||
@@ -31,14 +53,31 @@ class NS_NO_VTABLE iMThreadContext : public nsISupports {
|
||||
|
||||
/* Use this macro when declaring classes that implement this interface. */
|
||||
#define NS_DECL_IMTHREADCONTEXT \
|
||||
NS_IMETHOD GetNext(char **_retval); \
|
||||
NS_IMETHOD GetStages(PRInt32 *_retval); \
|
||||
NS_IMETHOD GetThreads(PRInt32 *_retval); \
|
||||
NS_IMETHOD GetResFile(char **_retval); \
|
||||
NS_IMETHOD GetPath(PRBool i, char **_retval); \
|
||||
NS_IMETHOD GetContractID(PRInt32 i, PRInt32 j, char **_retval); \
|
||||
NS_IMETHOD GetComponentManager(nsIComponentManager **_retval);
|
||||
|
||||
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
|
||||
#define NS_FORWARD_IMTHREADCONTEXT(_to) \
|
||||
NS_IMETHOD GetNext(char **_retval) { return _to ## GetNext(_retval); } \
|
||||
NS_IMETHOD GetStages(PRInt32 *_retval) { return _to ## GetStages(_retval); } \
|
||||
NS_IMETHOD GetThreads(PRInt32 *_retval) { return _to ## GetThreads(_retval); } \
|
||||
NS_IMETHOD GetResFile(char **_retval) { return _to ## GetResFile(_retval); } \
|
||||
NS_IMETHOD GetPath(PRBool i, char **_retval) { return _to ## GetPath(i, _retval); } \
|
||||
NS_IMETHOD GetContractID(PRInt32 i, PRInt32 j, char **_retval) { return _to ## GetContractID(i, j, _retval); } \
|
||||
NS_IMETHOD GetComponentManager(nsIComponentManager **_retval) { return _to ## GetComponentManager(_retval); }
|
||||
|
||||
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
|
||||
#define NS_FORWARD_SAFE_IMTHREADCONTEXT(_to) \
|
||||
NS_IMETHOD GetStages(PRInt32 *_retval) { return !_to ## ? NS_ERROR_NULL_POINTER : _to ##-> GetStages(_retval); } \
|
||||
NS_IMETHOD GetThreads(PRInt32 *_retval) { return !_to ## ? NS_ERROR_NULL_POINTER : _to ##-> GetThreads(_retval); } \
|
||||
NS_IMETHOD GetResFile(char **_retval) { return !_to ## ? NS_ERROR_NULL_POINTER : _to ##-> GetResFile(_retval); } \
|
||||
NS_IMETHOD GetPath(PRBool i, char **_retval) { return !_to ## ? NS_ERROR_NULL_POINTER : _to ##-> GetPath(i, _retval); } \
|
||||
NS_IMETHOD GetContractID(PRInt32 i, PRInt32 j, char **_retval) { return !_to ## ? NS_ERROR_NULL_POINTER : _to ##-> GetContractID(i, j, _retval); } \
|
||||
NS_IMETHOD GetComponentManager(nsIComponentManager **_retval) { return !_to ## ? NS_ERROR_NULL_POINTER : _to ##-> GetComponentManager(_retval); }
|
||||
|
||||
#if 0
|
||||
/* Use the code below as a template for the implementation class for this interface. */
|
||||
|
||||
@@ -68,8 +107,32 @@ _MYCLASS_::~_MYCLASS_()
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* string GetNext (); */
|
||||
NS_IMETHODIMP _MYCLASS_::GetNext(char **_retval)
|
||||
/* long GetStages (); */
|
||||
NS_IMETHODIMP _MYCLASS_::GetStages(PRInt32 *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* long GetThreads (); */
|
||||
NS_IMETHODIMP _MYCLASS_::GetThreads(PRInt32 *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* string GetResFile (); */
|
||||
NS_IMETHODIMP _MYCLASS_::GetResFile(char **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* string GetPath (in boolean i); */
|
||||
NS_IMETHODIMP _MYCLASS_::GetPath(PRBool i, char **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* string GetContractID (in long i, in long j); */
|
||||
NS_IMETHODIMP _MYCLASS_::GetContractID(PRInt32 i, PRInt32 j, char **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -90,6 +153,6 @@ NS_IMETHODIMP _MYCLASS_::GetComponentManager(nsIComponentManager **_retval)
|
||||
0x46d0, \
|
||||
{0x8a, 0xfc, 0xf1, 0x93, 0x91, 0x73, 0xc2, 0xea} \
|
||||
}
|
||||
#define MTHREADCONTEXT_PROGID "component://netscape/blackwood/blackconnect/test/mthreads/MThreadContext"
|
||||
#define MTHREADCONTEXT_PROGID "@mozilla/blackwood/blackconnect/test/params/MThreadContext;1"
|
||||
|
||||
#endif /* __gen_iMThreadContext_h__ */
|
||||
|
||||
@@ -27,7 +27,11 @@
|
||||
[scriptable, uuid(a7b26685-9816-4eb6-a075-36f539a7a823)]
|
||||
interface iMThreadContext : nsISupports
|
||||
{
|
||||
string GetNext();
|
||||
long GetStages();
|
||||
long GetThreads();
|
||||
string GetResFile();
|
||||
string GetPath(in boolean i);
|
||||
string GetContractID(in long i,in long j);
|
||||
nsIComponentManager GetComponentManager();
|
||||
};
|
||||
|
||||
@@ -40,6 +44,5 @@ interface iMThreadContext : nsISupports
|
||||
{0x8a, 0xfc, 0xf1, 0x93, 0x91, 0x73, 0xc2, 0xea} \
|
||||
}
|
||||
|
||||
#define MTHREADCONTEXT_PROGID "component://netscape/blackwood/blackconnect/test/mthreads/MThreadContext"
|
||||
|
||||
#define MTHREADCONTEXT_PROGID "@mozilla/blackwood/blackconnect/test/params/MThreadContext;1"
|
||||
%}
|
||||
|
||||
@@ -20,8 +20,20 @@ public interface iMThreadContext extends nsISupports
|
||||
new IID("a7b26685-9816-4eb6-a075-36f539a7a823");
|
||||
|
||||
|
||||
/* string GetNext (); */
|
||||
public String getNext();
|
||||
/* long GetStages (); */
|
||||
public int getStages();
|
||||
|
||||
/* long GetThreads (); */
|
||||
public int getThreads();
|
||||
|
||||
/* string GetResFile (); */
|
||||
public String getResFile();
|
||||
|
||||
/* string GetPath (in boolean i); */
|
||||
public String getPath(boolean i);
|
||||
|
||||
/* string GetContractID (in long i, in long j); */
|
||||
public String getContractID(int i, int j);
|
||||
|
||||
/* nsIComponentManager GetComponentManager (); */
|
||||
public nsIComponentManager getComponentManager();
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..\..
|
||||
topsrcdir = $(DEPTH)
|
||||
@@ -30,8 +32,6 @@ DIRS= \
|
||||
context \
|
||||
1 \
|
||||
2 \
|
||||
3 \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
*/
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "stdio.h"
|
||||
#include "prthread.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "iMThreadContext.h"
|
||||
#include "iMThreadComponent.h"
|
||||
@@ -32,7 +34,10 @@
|
||||
#include <stdlib.h>
|
||||
#include "nsID.h"
|
||||
|
||||
iMThreadContext* context;
|
||||
iMThreadContext* context=NULL;
|
||||
void* eThread=NULL;
|
||||
FILE *file=NULL;
|
||||
|
||||
MTStartImpl::MTStartImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
@@ -42,25 +47,47 @@ MTStartImpl::MTStartImpl()
|
||||
NS_GET_IID(iMThreadContext),
|
||||
(void**)&context);
|
||||
if(NS_FAILED(rv)) {
|
||||
printf("Create instance of context failed!!!");
|
||||
fprintf(stderr, "Create instance of context failed!!!");
|
||||
return;
|
||||
}
|
||||
char* first;
|
||||
context->GetNext(&first);
|
||||
char* first=(char*)PR_Malloc(sizeof(char*));
|
||||
|
||||
|
||||
context->GetContractID(0,1,&first);
|
||||
nsCID firstCID;
|
||||
firstCID.Parse(first);
|
||||
printf("ClassID is %s\n", firstCID.ToString());
|
||||
iMThreadComponent* tComponent;
|
||||
iMThreadComponent* tComponent=NULL;
|
||||
rv = nsComponentManager::CreateInstance(firstCID,
|
||||
nsnull,
|
||||
NS_GET_IID(iMThreadComponent),
|
||||
(void**)&tComponent);
|
||||
if(NS_FAILED(rv)) {
|
||||
printf("Create instance failed from %s!!!",first);
|
||||
fprintf(stderr, "Create instance failed from %s!!!",first);
|
||||
return;
|
||||
}
|
||||
|
||||
eThread = PR_GetCurrentThread();
|
||||
|
||||
char* res=(char*)PR_Malloc(sizeof(char*));
|
||||
context->GetResFile(&res);
|
||||
|
||||
if ((file = fopen(res, "w+t")) == NULL) {
|
||||
fprintf(stderr, "ERROR: can't open file %s\n",res);
|
||||
}
|
||||
char* tmp="0,0,";
|
||||
fwrite(tmp,1,PL_strlen(tmp),file);
|
||||
sprintf(tmp,"%d\n",eThread);
|
||||
fwrite(tmp,1,PL_strlen(tmp),file);
|
||||
fclose(file);
|
||||
|
||||
tComponent->Initialize(context);
|
||||
tComponent->Execute("First from MTStart");
|
||||
nsIComponentManager* cm;
|
||||
rv = NS_GetGlobalComponentManager(&cm);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "ERROR: Can't get GlobalComponentManager!!\n");
|
||||
}
|
||||
tComponent->THack(cm);
|
||||
tComponent->Execute(0,1);
|
||||
}
|
||||
|
||||
MTStartImpl::~MTStartImpl()
|
||||
@@ -68,12 +95,3 @@ MTStartImpl::~MTStartImpl()
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(MTStartImpl, iMTStart);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,11 +36,3 @@ static nsModuleComponentInfo components[] =
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("MTStartFactory", components)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=../../../../../..
|
||||
topsrcdir = $(DEPTH)
|
||||
|
||||
@@ -40,7 +40,7 @@ interface iMTStart : nsISupports
|
||||
{0x8a, 0xb2, 0x97, 0x83, 0xf8, 0x98, 0x06, 0x55} \
|
||||
}
|
||||
|
||||
#define MTSTART_PROGID "component://netscape/blackwood/blackconnect/test/mthreads/MTStart"
|
||||
#define MTSTART_PROGID "@mozilla/blackwood/blackconnect/test/mthreads/MTStart;1"
|
||||
|
||||
%}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Client QA Team, St. Petersburg, Russia
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..\..\..
|
||||
topsrcdir = $(DEPTH)
|
||||
@@ -29,10 +31,10 @@ MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = MTStart
|
||||
DLL =.\$(OBJDIR)\$(DLLNAME).dll
|
||||
COMPONENT = 1
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
JAVAI = \
|
||||
.\iMTStart.java \
|
||||
$(NULL)
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\iMTStart.idl \
|
||||
@@ -45,16 +47,17 @@ CPP_OBJS = \
|
||||
|
||||
LLIBS =$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib
|
||||
|
||||
JDIRS = .
|
||||
JAVAC_PROG=$(JDKHOME)\bin\javac
|
||||
JAVAC_FLAGS=-classpath $(CLASSPATH);$(JAVA_DESTPATH) -d $(JAVA_DESTPATH)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
include <$(DEPTH)\config\javarules.mak>
|
||||
|
||||
javai:
|
||||
echo $(JDKHOME)\bin\javac -classpath $(DEPTH)\dist\classes -d $(DEPTH)\dist\classes $(JAVAI)
|
||||
$(JDKHOME)\bin\javac -classpath $(DEPTH)\dist\classes -d $(DEPTH)\dist\classes $(JAVAI)
|
||||
|
||||
install:: $(DLL) javai
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
del /f $(DIST)\bin\components\$(DLLNAME).dll
|
||||
del /f $(DIST)\bin\components\$(DLLNAME).xpt
|
||||
del /f $(DIST)\..\classes\org\mozilla\xpcom\iMTStart.class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user