Add some missing unit test tools
parent
6ed45fef0b
commit
94ad75bb72
@ -0,0 +1,214 @@
|
||||
/*
|
||||
backup_service_interface test
|
||||
|
||||
project: RYZOM / TEST
|
||||
*/
|
||||
|
||||
#include "nel/misc/variable.h"
|
||||
#include "game_share/backup_service_interface.h"
|
||||
#include "game_share/singleton_registry.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
class CBackupFileReceiveCallbackTest: public IBackupFileReceiveCallback
|
||||
{
|
||||
public:
|
||||
virtual void callback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream)
|
||||
{
|
||||
std::string s;
|
||||
dataStream.serial(s);
|
||||
nlinfo("Received file: %s (timestamp:%d, size:%d) containing string: %s",fileDescription.FileName.c_str(),fileDescription.FileTimeStamp,fileDescription.FileSize,s.c_str());
|
||||
}
|
||||
|
||||
~CBackupFileReceiveCallbackTest()
|
||||
{
|
||||
nlinfo("~CBackupFileReceiveCallbackTest()");
|
||||
}
|
||||
};
|
||||
|
||||
class CBackupFileListReceiveCallbackTest: public IBackupFileListReceiveCallback
|
||||
{
|
||||
public:
|
||||
virtual void callback(const CFileDescriptionContainer& fileList)
|
||||
{
|
||||
nlinfo("Received file list");
|
||||
fileList.display(NLMISC::InfoLog);
|
||||
}
|
||||
|
||||
~CBackupFileListReceiveCallbackTest()
|
||||
{
|
||||
nlinfo("~CBackupFileListReceiveCallbackTest()");
|
||||
}
|
||||
};
|
||||
|
||||
extern NLMISC::CVariable<bool> UseBS;
|
||||
|
||||
class CBackupServiceInterfaceTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
void init()
|
||||
{
|
||||
|
||||
// *** TODO !!!! ***
|
||||
// need to ensure that BS interface internals are OK - the queues should be empty here...
|
||||
}
|
||||
};
|
||||
|
||||
static CBackupServiceInterfaceTest Test;
|
||||
|
||||
NLMISC_COMMAND(backupTestRequestFile,"","")
|
||||
{
|
||||
bool oldUseBS= UseBS;
|
||||
|
||||
// test CBackupServiceInterface::requestFile()
|
||||
{
|
||||
UseBS= true;
|
||||
nlinfo("----- request file using BS -----");
|
||||
Bsi.requestFile("backup_service_interface_test0.bin",new CBackupFileReceiveCallbackTest);
|
||||
|
||||
UseBS= false;
|
||||
nlinfo("----- request file no BS -----");
|
||||
Bsi.requestFile("backup_service_interface_test1.bin",new CBackupFileReceiveCallbackTest);
|
||||
}
|
||||
|
||||
nlinfo("----- END OF REQUEST FILE TEST -----");
|
||||
UseBS= oldUseBS;
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(backupTestRequestFileList,"","")
|
||||
{
|
||||
bool oldUseBS= UseBS;
|
||||
|
||||
// test CBackupServiceInterface::requestFileList()
|
||||
{
|
||||
UseBS= true;
|
||||
nlinfo("----- request file list using BS => * -----");
|
||||
Bsi.requestFileList("data_shard", new CBackupFileListReceiveCallbackTest);
|
||||
nlinfo("----- request file list using BS => egs* -----");
|
||||
Bsi.requestFileList("data_shard", "egs*", new CBackupFileListReceiveCallbackTest,true);
|
||||
|
||||
std::vector<std::string> vect;
|
||||
vect.push_back("ais*");
|
||||
vect.push_back("*.rbank");
|
||||
nlinfo("----- request file list using BS => ais*,*.rbank -----");
|
||||
Bsi.requestFileList("data_shard", vect, new CBackupFileListReceiveCallbackTest,true);
|
||||
|
||||
UseBS= false;
|
||||
nlinfo("----- request file list no BS -----");
|
||||
Bsi.requestFileList("data_shard", new CBackupFileListReceiveCallbackTest);
|
||||
}
|
||||
|
||||
nlinfo("----- END OF REQUEST FILE LIST TEST -----");
|
||||
UseBS= oldUseBS;
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(backupTestSendFile,"","")
|
||||
{
|
||||
bool oldUseBS= UseBS;
|
||||
|
||||
// test CBackupServiceInterface::sendFile()
|
||||
{
|
||||
std::string s ="Hello World";
|
||||
|
||||
UseBS= true;
|
||||
nlinfo("----- save file using BS => backup_service_interface_test0.bin -----");
|
||||
CBackupMsgSaveFile saveFileMsg("backup_service_interface_test0.bin", CBackupMsgSaveFile::SaveFile, Bsi );
|
||||
saveFileMsg.DataMsg.serial(s);
|
||||
saveFileMsg.DataMsg.serial(s);
|
||||
Bsi.sendFile(saveFileMsg);
|
||||
|
||||
UseBS= false;
|
||||
nlinfo("----- save file no BS => backup_service_interface_test1.bin -----");
|
||||
CBackupMsgSaveFile saveFileMsg2("backup_service_interface_test1.bin", CBackupMsgSaveFile::SaveFile, Bsi );
|
||||
saveFileMsg2.DataMsg.serial(s);
|
||||
saveFileMsg2.DataMsg.serial(s);
|
||||
Bsi.sendFile(saveFileMsg2);
|
||||
}
|
||||
|
||||
nlinfo("----- END OF SEND FILE TEST -----");
|
||||
UseBS= oldUseBS;
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(backupTestOutputStream,"","")
|
||||
{
|
||||
bool oldUseBS= UseBS;
|
||||
|
||||
// test CBackupOutputStream - with BS
|
||||
{
|
||||
UseBS=true;
|
||||
CBackupOutputStream outputStream("backup_service_interface_test2.bin","remote_","local_");
|
||||
NLMISC::IStream& stream= outputStream.getStream();
|
||||
std::string s="CBackupOutputStream test - with BS";
|
||||
stream.serial(s);
|
||||
}
|
||||
|
||||
// test CBackupOutputStream - without BS
|
||||
{
|
||||
UseBS=false;
|
||||
CBackupOutputStream outputStream("backup_service_interface_test3.bin","remote_","local_");
|
||||
NLMISC::IStream& stream= outputStream.getStream();
|
||||
std::string s="CBackupOutputStream test- without BS";
|
||||
stream.serial(s);
|
||||
}
|
||||
|
||||
nlinfo("----- END OF OUTPUT STREAM TEST -----");
|
||||
UseBS= oldUseBS;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CBackupServiceInterface BSInterface;
|
||||
|
||||
void cbBackupAppend(CBackupMsgAppendCallback& append)
|
||||
{
|
||||
uint i;
|
||||
for (i=0; i<append.Appends.size(); ++i)
|
||||
nlinfo("Appended '%s' to file '%s'", append.Appends[i].c_str(), append.FileName.c_str());
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(listenTo, "test bs listen to", "filename")
|
||||
{
|
||||
if (args.size() < 1)
|
||||
return false;
|
||||
|
||||
BSInterface.listenTo(args[0], cbBackupAppend, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(endListenTo, "test bs end listen to", "filename")
|
||||
{
|
||||
if (args.size() < 1)
|
||||
return false;
|
||||
|
||||
BSInterface.endListenTo(args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(bsAppend, "test bs append", "filename value")
|
||||
{
|
||||
if (args.size() < 2)
|
||||
return false;
|
||||
|
||||
BSInterface.append(args[0], args[1]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,169 @@
|
||||
/*
|
||||
command for alain
|
||||
|
||||
project: RYZOM / TEST
|
||||
*/
|
||||
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/o_xml.h"
|
||||
#include "nel/misc/command.h"
|
||||
#include "game_share/file_description_container.h"
|
||||
#include "game_share/singleton_registry.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
NLMISC_COMMAND(buildBannedNameFromFile,"","<input file>")
|
||||
{
|
||||
if (args.size()!=1)
|
||||
return false;
|
||||
|
||||
std::map<string,uint32> result;
|
||||
|
||||
FILE *inf=fopen(args[0].c_str(),"rb");
|
||||
if (inf==NULL)
|
||||
{
|
||||
nlwarning("Failed to open file: %s",args[0].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
CSString input;
|
||||
input.resize(CFile::getFileSize(inf));
|
||||
uint32 bytesRead= fread(&input[0],1,input.size(),inf);
|
||||
fclose(inf);
|
||||
if (bytesRead!=input.size())
|
||||
{
|
||||
nlwarning("Failed to read contents of file: %s",args[0].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
while(!input.empty())
|
||||
{
|
||||
CSString line=input.firstLine(true);
|
||||
if ()
|
||||
continue;
|
||||
CSString account= line.first
|
||||
CSString
|
||||
}
|
||||
|
||||
const char* outputName= "c:/banned_names.xml";
|
||||
nlinfo("Writing output: %s",outputName);
|
||||
try
|
||||
{
|
||||
COFile f;
|
||||
f.open(outputName);
|
||||
COXml fx;
|
||||
fx.init(&f,"1.0");
|
||||
fx.serialCont(result);
|
||||
fx.flush();
|
||||
f.close();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
nlinfo("Problem with output file: %s",outputName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(buildReservedNameListFromFile,"","<input file>")
|
||||
{
|
||||
if (args.size()!=1)
|
||||
return false;
|
||||
|
||||
std::map<string,uint32> result;
|
||||
|
||||
|
||||
const char* outputName= "c:/reserved_names.xml";
|
||||
nlinfo("Writing output: %s",outputName);
|
||||
try
|
||||
{
|
||||
COFile f;
|
||||
f.open(outputName);
|
||||
COXml fx;
|
||||
fx.init(&f,"1.0");
|
||||
fx.serialCont(result);
|
||||
fx.flush();
|
||||
f.close();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
nlinfo("Problem with output file: %s",outputName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(buildReservedNameListFromBinFiles,"","<path>[<path>...]")
|
||||
{
|
||||
if (args.size()<1)
|
||||
return false;
|
||||
|
||||
CFileDescriptionContainer fdc;
|
||||
for (uint32 j=0;j<args.size();++j)
|
||||
fdc.addFileSpec(args[j]);
|
||||
|
||||
typedef std::map<std::string,CFileDescription const*> TMyMap;
|
||||
TMyMap myMap;
|
||||
|
||||
for (uint32 i=0;i<fdc.size();++i)
|
||||
{
|
||||
std::string fileName=NLMISC::CFile::getFilename(fdc[i].FileName);
|
||||
if (myMap.find(fileName)!=myMap.end())
|
||||
{
|
||||
if (myMap[fileName]->FileTimeStamp>fdc[i].FileTimeStamp)
|
||||
continue;
|
||||
}
|
||||
myMap[fileName]= &fdc[i];
|
||||
}
|
||||
|
||||
std::map<ucstring,uint32> result;
|
||||
uint32 lastAccount=~0u;
|
||||
for (TMyMap::iterator it=myMap.begin();it!=myMap.end();++it)
|
||||
{
|
||||
CSString s= (*it).first;
|
||||
s.strtok("_");
|
||||
uint32 account=s.strtok("_").atoi();
|
||||
|
||||
if (account!=lastAccount)
|
||||
{
|
||||
lastAccount=account;
|
||||
|
||||
try
|
||||
{
|
||||
CIFile f;
|
||||
ucstring ucs;
|
||||
f.open((*it).second->FileName);
|
||||
f.seek(18,NLMISC::IStream::begin);
|
||||
f.serial(ucs);
|
||||
f.close();
|
||||
result[ucs]=account;
|
||||
nlinfo("%s: name: %s",(*it).second->FileName.c_str(),ucs.toUtf8().c_str());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
nlinfo("Problem with: %s",(*it).second->FileName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* outputName= "c:/reserved_names_from_bin_files.xml";
|
||||
nlinfo("Writing output: %s",outputName);
|
||||
try
|
||||
{
|
||||
COFile f;
|
||||
f.open(outputName);
|
||||
COXml fx;
|
||||
fx.init(&f,"1.0");
|
||||
fx.serialCont(result);
|
||||
fx.flush();
|
||||
f.close();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
nlinfo("Problem with output file: %s",outputName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
file_description_container test
|
||||
|
||||
project: RYZOM / TEST
|
||||
*/
|
||||
|
||||
#include "nel/misc/file.h"
|
||||
#include "game_share/file_description_container.h"
|
||||
#include "game_share/singleton_registry.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
class CFileDescriptionTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
void init()
|
||||
{
|
||||
CFileDescriptionContainer fdc;
|
||||
nlassert(fdc.empty());
|
||||
|
||||
fdc.addFile("some file that doesn't exist 0");
|
||||
fdc.addFile("some file that doesn't exist 1",0,0);
|
||||
fdc.addFileSpec("some file that doesn't exist 2");
|
||||
nlassert(!fdc.empty());
|
||||
|
||||
fdc.addFileSpec("*");
|
||||
|
||||
for (uint32 i=0;i<fdc.size();++i)
|
||||
{
|
||||
nlinfo(fdc[i].FileName.c_str());
|
||||
}
|
||||
|
||||
COFile outf;
|
||||
outf.open("file_description_container_test.bin");
|
||||
outf.serial(fdc);
|
||||
outf.close();
|
||||
|
||||
nlassert(!fdc.empty());
|
||||
fdc.clear();
|
||||
nlassert(fdc.empty());
|
||||
|
||||
CFileDescriptionContainer fdc2;
|
||||
CIFile inf;
|
||||
inf.open("file_description_container_test.bin");
|
||||
inf.serial(fdc2);
|
||||
inf.close();
|
||||
|
||||
fdc2.display(NLMISC::InfoLog);
|
||||
}
|
||||
};
|
||||
|
||||
static CFileDescriptionTest Test;
|
@ -0,0 +1,172 @@
|
||||
/*
|
||||
Handy utility commands
|
||||
|
||||
project: RYZOM / TEST
|
||||
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// includes
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "stdpch.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/command.h"
|
||||
#include "nel/misc/algo.h"
|
||||
#include "game_share/persistent_data.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Handy utility commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,pdrBin2xml,"convert a binary pdr file to xml","<input file name> <output file name>")
|
||||
{
|
||||
if (args.size()!=2)
|
||||
return false;
|
||||
|
||||
CPersistentDataRecord pdr;
|
||||
pdr.readFromBinFile(args[0].c_str());
|
||||
pdr.writeToTxtFile(args[1].c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,pdrXml2bin,"convert a text pdr file to binary","<input file name> <output file name>")
|
||||
{
|
||||
if (args.size()!=2)
|
||||
return false;
|
||||
|
||||
CPersistentDataRecord pdr;
|
||||
pdr.readFromTxtFile(args[0].c_str());
|
||||
pdr.writeToBinFile(args[1].c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,quickFileCompare,"compare 2 files (by comparing timestamp and size)","<file0> <file1>")
|
||||
{
|
||||
if (args.size()!=2)
|
||||
return false;
|
||||
|
||||
log.displayNL("comparing files ...");
|
||||
bool result= NLMISC::CFile::quickFileCompare(args[0], args[1]);
|
||||
log.displayNL("- %s",result?"Same":"Different");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,thoroughFileCompare,"compare 2 files (by comparing data)","<file0> <file1> [<max mem footprint>]")
|
||||
{
|
||||
if (args.size()!=2 && args.size()!=3)
|
||||
return false;
|
||||
|
||||
bool result;
|
||||
log.displayNL("comparing files ...");
|
||||
|
||||
if (args.size()==3)
|
||||
{
|
||||
uint32 size=atoi(args[2].c_str());
|
||||
if (size<2)
|
||||
{
|
||||
log.displayNL("The third parameter must be a value >= 2 : The following value is not valid: %s",args[2].c_str());
|
||||
return true;
|
||||
}
|
||||
result= NLMISC::CFile::thoroughFileCompare(args[0], args[1], size);
|
||||
}
|
||||
else
|
||||
{
|
||||
result= NLMISC::CFile::thoroughFileCompare(args[0], args[1]);
|
||||
}
|
||||
|
||||
log.displayNL("- %s",result?"Same":"Different");
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,cd,"change directory or display current working directory","[<path>]")
|
||||
{
|
||||
if (args.size()!=0 && args.size()!=1)
|
||||
return false;
|
||||
|
||||
if (args.size()==1)
|
||||
{
|
||||
NLMISC::CPath::setCurrentPath(args[0].c_str());
|
||||
}
|
||||
|
||||
log.displayNL("Current directory: %s",NLMISC::CPath::getCurrentPath().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,md,"create a new directory (or directory tree)","<path>")
|
||||
{
|
||||
if (args.size()!=1)
|
||||
return false;
|
||||
|
||||
NLMISC::CFile::createDirectoryTree(args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,copyFile,"copy a file","<src> <dest>")
|
||||
{
|
||||
if (args.size()!=2)
|
||||
return false;
|
||||
|
||||
NLMISC::CFile::copyFile(args[1].c_str(),args[0].c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,del,"delete a file","<fileName>")
|
||||
{
|
||||
if (args.size()!=1)
|
||||
return false;
|
||||
|
||||
NLMISC::CFile::deleteFile(args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_CATEGORISED_COMMAND(utils,dir,"list files in the current directory","[<wildcard>]")
|
||||
{
|
||||
if (args.size()!=1 && args.size()!=0)
|
||||
return false;
|
||||
|
||||
std::string wildcard="*";
|
||||
if (args.size()==1)
|
||||
wildcard=args[0];
|
||||
|
||||
std::vector<std::string> directories;
|
||||
NLMISC::CPath::getPathContent(".",false,true,false,directories);
|
||||
for (uint32 i=directories.size();i--;)
|
||||
{
|
||||
if (!NLMISC::testWildCard(directories[i],wildcard))
|
||||
{
|
||||
directories[i]=directories.back();
|
||||
directories.pop_back();
|
||||
}
|
||||
}
|
||||
std::sort(directories.begin(),directories.end());
|
||||
for (uint32 i=0;i<directories.size();++i)
|
||||
{
|
||||
log.displayNL("%s/",directories[i].c_str());
|
||||
}
|
||||
|
||||
std::vector<std::string> files;
|
||||
NLMISC::CPath::getPathContent(".",false,false,true,files);
|
||||
for (uint32 i=files.size();i--;)
|
||||
{
|
||||
if (!NLMISC::testWildCard(files[i],wildcard))
|
||||
{
|
||||
files[i]=files.back();
|
||||
files.pop_back();
|
||||
}
|
||||
}
|
||||
std::sort(files.begin(),files.end());
|
||||
for (uint32 i=0;i<files.size();++i)
|
||||
{
|
||||
log.displayNL("%-40s %10d",files[i].c_str(),NLMISC::CFile::getFileSize(files[i]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,151 @@
|
||||
/*
|
||||
Patch generation test
|
||||
|
||||
project: RYZOM / TEST
|
||||
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// includes
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "patch.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/command.h"
|
||||
#include "game_share/singleton_registry.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Handy utility functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void normalisePackageDescriptionFileName(std::string& fileName)
|
||||
{
|
||||
if (fileName.empty())
|
||||
fileName="package_description";
|
||||
if (NLMISC::CFile::getExtension(fileName).empty() && fileName[fileName.size()-1]!='.')
|
||||
fileName+=".xml";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// class CPatchTest
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CPatchTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
void init()
|
||||
{
|
||||
if (!NLMISC::CFile::fileExists("patch_test/test0/test_package.xml"))
|
||||
createPackage("patch_test/test0/test_package.xml");
|
||||
}
|
||||
|
||||
void serviceUpdate()
|
||||
{
|
||||
static uint32 count=~0u;
|
||||
if (count++>=20)
|
||||
{
|
||||
count=0;
|
||||
if (!NLMISC::CFile::fileExists("patch_test/test0/test_package.wip"))
|
||||
processPackage("patch_test/test0/test_package.xml");
|
||||
else
|
||||
nlinfo("skipping 'process package' because test_package.wip 'work in progress' marker exists");
|
||||
}
|
||||
}
|
||||
|
||||
static bool createPackage(std::string fileName)
|
||||
{
|
||||
// normalise the file name (and path)
|
||||
normalisePackageDescriptionFileName(fileName);
|
||||
|
||||
// make sure the file doesn't exist
|
||||
BOMB_IF(NLMISC::CFile::fileExists(fileName),("Failed to careate new package because file already exists: "+fileName).c_str(),return false);
|
||||
|
||||
// create the directory tree required for the file
|
||||
NLMISC::CFile::createDirectoryTree(NLMISC::CFile::getPath(fileName));
|
||||
|
||||
// create a new package, store it to a persistent data record and write the latter to a file
|
||||
CPackageDescription package;
|
||||
CPersistentDataRecord pdr;
|
||||
package.storeToPdr(pdr);
|
||||
pdr.writeToTxtFile(fileName.c_str());
|
||||
package.setup(fileName);
|
||||
package.createDirectories();
|
||||
package.buildDefaultFileList();
|
||||
package.storeToPdr(pdr);
|
||||
pdr.writeToTxtFile(fileName.c_str());
|
||||
BOMB_IF(!NLMISC::CFile::fileExists(fileName),("Failed to create new package file: "+fileName).c_str(),return false);
|
||||
nlinfo("New package description file created successfully: %s",fileName.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool processPackage(std::string fileName)
|
||||
{
|
||||
// normalise the file name (and path)
|
||||
normalisePackageDescriptionFileName(fileName);
|
||||
|
||||
// make sure the file exists
|
||||
BOMB_IF(!NLMISC::CFile::fileExists(fileName),("Failed to process package because file not found: "+fileName).c_str(),return false);
|
||||
|
||||
// read the package description file
|
||||
CPackageDescription thePackage;
|
||||
thePackage.setup(fileName);
|
||||
|
||||
// read the index file for the package
|
||||
CBNPFileSet packageIndex;
|
||||
thePackage.readIndex(packageIndex);
|
||||
|
||||
// update the files list in the index
|
||||
thePackage.updateIndexFileList(packageIndex);
|
||||
|
||||
// update the index for the package
|
||||
thePackage.addVersion(packageIndex);
|
||||
|
||||
// save the updated index file
|
||||
thePackage.writeIndex(packageIndex);
|
||||
|
||||
// generate patches as required
|
||||
thePackage.generatePatches(packageIndex);
|
||||
|
||||
// generate client index file
|
||||
CPackageDescriptionForClient theClientPackage;
|
||||
thePackage.generateClientIndex(theClientPackage,packageIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static CPatchTest PatchTest;
|
||||
|
||||
NLMISC_COMMAND(createPackage,"create a new package description file","<package description file name>")
|
||||
{
|
||||
if (args.size()!=1)
|
||||
return false;
|
||||
|
||||
PatchTest.createPackage(args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(processPackage,"process a package","<package description file name>")
|
||||
{
|
||||
if (args.size()!=1)
|
||||
return false;
|
||||
|
||||
PatchTest.processPackage(args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NLMISC_COMMAND(bin2xml,"convert a binary pdr file to xml","<input file name> <output file name>")
|
||||
{
|
||||
if (args.size()!=2)
|
||||
return false;
|
||||
|
||||
CPersistentDataRecord pdr;
|
||||
pdr.readFromBinFile(args[0].c_str());
|
||||
pdr.writeToTxtFile(args[1].c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,75 @@
|
||||
/** \file r2_entry_point_test.cpp
|
||||
*
|
||||
* $id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "nel/misc/hierarchical_timer.h"
|
||||
#include "game_share/utils.h"
|
||||
#include "game_share/timer.h"
|
||||
#include "r2_share/scenario_entry_points.h"
|
||||
|
||||
// #define ENABLE_TESTS
|
||||
#include "game_share/sadge_tests.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
|
||||
class CR2EntryPointTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
void test1(const CSString& packageDefinition)
|
||||
{
|
||||
// display a fancy title line
|
||||
nlinfo("<------------------------------------------------------------------------------------------------------>");
|
||||
nlinfo("Displaying scenario entry points correspoding to package definition: '%s'",packageDefinition.c_str());
|
||||
|
||||
// get the vector of islands that we are allowed access to
|
||||
CVectorSString islands;
|
||||
R2::CScenarioEntryPoints::getInstance().getIslands(packageDefinition,islands);
|
||||
|
||||
// run through the islands displaying them with their lists of entry points
|
||||
for (uint32 i=0;i<islands.size();++i)
|
||||
{
|
||||
nlinfo("- Island: %s", islands[i].c_str());
|
||||
|
||||
// get the set of valid entry points for this island
|
||||
CVectorSString entryPoints;
|
||||
R2::CScenarioEntryPoints::getInstance().getEntryPoints(packageDefinition,islands[i],entryPoints);
|
||||
|
||||
// for each entry point...
|
||||
for (uint32 j=0;j<entryPoints.size();++j)
|
||||
{
|
||||
// lookup the entry point id from the package definition, island name and entry point name
|
||||
uint32 entryPointId= R2::CScenarioEntryPoints::getInstance().getEntryPointId(packageDefinition,islands[i],entryPoints[j]);
|
||||
|
||||
// get the coordinates for the given entry point
|
||||
sint32 x, y;
|
||||
R2::CScenarioEntryPoints::getInstance().getEntryPointCoordsFromId(packageDefinition,entryPointId,x,y);
|
||||
|
||||
// display a debug message
|
||||
nlinfo(" - Entry point %d: %s (%d,%d)", entryPointId, entryPoints[j].c_str(), x, y);
|
||||
}
|
||||
}
|
||||
nlinfo(">------------------------------------------------------------------------------------------------------<");
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
CPath::addSearchPath("./data_common/r2",1,0);
|
||||
test1("j");
|
||||
test1("j1");
|
||||
test1("j2");
|
||||
test1("j1:j2");
|
||||
}
|
||||
|
||||
void serviceUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
static CR2EntryPointTest R2EntryPointTest;
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
Singleton test
|
||||
|
||||
project: RYZOM / TEST
|
||||
|
||||
*/
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "game_share/singleton_registry.h"
|
||||
|
||||
class CSingletonTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
void init()
|
||||
{
|
||||
nlinfo("CSingletonTest::init()");
|
||||
serviceCounter=0;
|
||||
tickCounter=0;
|
||||
}
|
||||
|
||||
void serviceUpdate()
|
||||
{
|
||||
++serviceCounter;
|
||||
if (serviceCounter>=50)
|
||||
{
|
||||
nlinfo("CSingletonTest::serviceUpdate() @50");
|
||||
serviceCounter=0;
|
||||
}
|
||||
}
|
||||
|
||||
void tickUpdate()
|
||||
{
|
||||
++tickCounter;
|
||||
if (tickCounter>=25)
|
||||
{
|
||||
nlinfo("CSingletonTest::tickUpdate() @25");
|
||||
tickCounter=0;
|
||||
}
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
nlinfo("CSingletonTest::release()");
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 tickCounter;
|
||||
uint32 serviceCounter;
|
||||
};
|
||||
|
||||
static CSingletonTest SingletonTest;
|
@ -0,0 +1,249 @@
|
||||
/*
|
||||
SString test
|
||||
|
||||
project: RYZOM / TEST
|
||||
*/
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "game_share/singleton_registry.h"
|
||||
#include "nel/misc/sstring.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
|
||||
static void xmlTest(const NLMISC::CSString& s,bool isCompat,bool isCompatParam,bool isEncoded,const char* encode,const char* encodeParam,const char* decode)
|
||||
{
|
||||
nlinfo("%s: isXMLCompat(f):%s isXMLCompat(t):%s isXMLCode:%s encode(f):%s encode(t):%s decode:%s",s.c_str(),s.isXMLCompatible()?"Y":"N",s.isXMLCompatible(true)?"Y":"N",s.isEncodedXML()?"Y":"N",s.encodeXML().c_str(),s.encodeXML(true).c_str(),s.decodeXML().c_str());
|
||||
nlassert(s.isXMLCompatible()==isCompat);
|
||||
nlassert(s.isXMLCompatible(true)==isCompatParam);
|
||||
nlassert(s.isEncodedXML()==isEncoded);
|
||||
nlassert(s.encodeXML()==encode);
|
||||
nlassert(s.encodeXML(true)==encodeParam);
|
||||
nlassert(s.decodeXML()==decode);
|
||||
}
|
||||
|
||||
static void xmlTestSet()
|
||||
{
|
||||
xmlTest("&hello&",false,false,false,"&hello&","&hello&","&hello&");
|
||||
xmlTest("&&",false,false,false,"&amp;&","&amp;&","&&");
|
||||
xmlTest("&",true,true,true,"&amp;","&amp;","&");
|
||||
xmlTest("&_",true,true,true,"&amp;_","&amp;_","&_");
|
||||
xmlTest("_&",true,true,true,"_&amp;","_&amp;","_&");
|
||||
xmlTest("_&_",true,true,true,"_&amp;_","_&amp;_","_&_");
|
||||
xmlTest(""",true,true,true,"&quot;","&quot;","\"");
|
||||
xmlTest("<",true,true,true,"&lt;","&lt;","<");
|
||||
xmlTest(">",true,true,true,"&gt;","&gt;",">");
|
||||
xmlTest("<",false,false,false,"<","<","<");
|
||||
xmlTest(">",false,false,false,">",">",">");
|
||||
xmlTest("&",false,false,false,"&","&","&");
|
||||
xmlTest("\"",false,false,false,""",""","\"");
|
||||
xmlTest("\t",true,false,false,"\t","	","\t");
|
||||
xmlTest("\n",true,false,false,"\n","
","\n");
|
||||
xmlTest("\r",true,false,false,"\r","
","\r");
|
||||
xmlTest("\x9A",false,false,false,"š","š","\x9A");
|
||||
xmlTest("\xC3",false,false,false,"Ã","Ã","\xC3");
|
||||
xmlTest("	",true,true,true,"&#x09;","&#x09;","\t");
|
||||
xmlTest("Z",true,true,true,"&#x5A;","&#x5A;","\x5A");
|
||||
xmlTest("¥",true,true,true,"&#xA5;","&#xA5;","\xA5");
|
||||
xmlTest("¥Z",true,true,true,"&#xA5;&#x5A;","&#xA5;&#x5A;","\xA5\x5A");
|
||||
xmlTest("

",true,true,true,"&#xA;&#xD;","&#xA;&#xD;","\n\r");
|
||||
}
|
||||
|
||||
static void quoteTest(const NLMISC::CSString& raw,const NLMISC::CSString& quoted)
|
||||
{
|
||||
nlinfo("Testing quotes: %s",quoted.c_str());
|
||||
nlassert(raw.quote().unquote()==raw);
|
||||
nlassert(quoted.unquote().quote()==quoted);
|
||||
nlassert(quoted.quote().unquote()==quoted);
|
||||
nlassert(raw.quote()==quoted);
|
||||
nlassert(quoted.unquote()==raw);
|
||||
}
|
||||
|
||||
static void quoteTestSet()
|
||||
{
|
||||
quoteTest("\"","\"\\\"\"");
|
||||
quoteTest("\\","\"\\\\\"");
|
||||
quoteTest("\a","\"\\a\"");
|
||||
quoteTest("\b","\"\\b\"");
|
||||
quoteTest("\f","\"\\f\"");
|
||||
quoteTest("\n","\"\\n\"");
|
||||
quoteTest("\r","\"\\r\"");
|
||||
quoteTest("\t","\"\\t\"");
|
||||
quoteTest("\v","\"\\v\"");
|
||||
quoteTest("\x01","\"\\x01\"");
|
||||
quoteTest("\xFE","\"\\xFE\"");
|
||||
quoteTest("\xef","\"\\xef\"");
|
||||
}
|
||||
|
||||
static void splitWordsTest(const NLMISC::CSString& pre,char separator,const NLMISC::CSString& post)
|
||||
{
|
||||
nlinfo("Testing split: %s",pre.c_str());
|
||||
|
||||
NLMISC::CVectorSString words;
|
||||
pre.splitWords(words);
|
||||
|
||||
NLMISC::CSString joined;
|
||||
joined.join(words,separator);
|
||||
nlassert(joined==post);
|
||||
|
||||
joined.clear();
|
||||
joined.join(words,NLMISC::CSString(separator));
|
||||
nlassert(joined==post);
|
||||
}
|
||||
|
||||
static void splitJoinTestSet()
|
||||
{
|
||||
splitWordsTest("bob bub",',',"bob,bub");
|
||||
splitWordsTest("\t bob\t bub\t ",',',"bob,bub");
|
||||
splitWordsTest("\t +bob\t -bub\t ",',',"+,bob,-,bub");
|
||||
}
|
||||
|
||||
static void splitToLineCommentTest(const NLMISC::CSString& pre, const NLMISC::CSString& post)
|
||||
{
|
||||
CSString s= pre;
|
||||
|
||||
// make sure post matches result of split
|
||||
nlassert(post==s.splitToLineComment());
|
||||
// make sure split is non destructive
|
||||
nlassert(s==pre);
|
||||
|
||||
// try splitting destructively
|
||||
CSString s2= s.splitToLineComment(true);
|
||||
nlassert((s2+s)==pre);
|
||||
}
|
||||
|
||||
static void splitToLineCommentTest2(const NLMISC::CSString& pre, const NLMISC::CSString& postWithEscape, const NLMISC::CSString& postWithoutEscape)
|
||||
{
|
||||
CSString s= pre;
|
||||
|
||||
// make sure post matches result of split
|
||||
nlassert(postWithEscape==s.splitToLineComment(false,true));
|
||||
// make sure split is non destructive
|
||||
nlassert(s==pre);
|
||||
|
||||
// make sure post matches result of split
|
||||
nlassert(postWithoutEscape==s.splitToLineComment(false,false));
|
||||
// make sure split is non destructive
|
||||
nlassert(s==pre);
|
||||
}
|
||||
|
||||
static void splitToLineCommentTestSet()
|
||||
{
|
||||
// some basic strings with no comments
|
||||
splitToLineCommentTest("a","a");
|
||||
splitToLineCommentTest(" a "," a ");
|
||||
splitToLineCommentTest("\"\"","\"\"");
|
||||
splitToLineCommentTest(" \" \" "," \" \" ");
|
||||
splitToLineCommentTest("\"a","\"a");
|
||||
splitToLineCommentTest(" \" a "," \" a ");
|
||||
splitToLineCommentTest("a\"","a\"");
|
||||
splitToLineCommentTest(" a \" "," a \" ");
|
||||
splitToLineCommentTest("/","/");
|
||||
splitToLineCommentTest("/ /","/ /");
|
||||
splitToLineCommentTest(" / "," / ");
|
||||
splitToLineCommentTest("/ ","/ ");
|
||||
splitToLineCommentTest(" /"," /");
|
||||
|
||||
// some basic cases with a comment
|
||||
splitToLineCommentTest("//","");
|
||||
splitToLineCommentTest("a//","a");
|
||||
splitToLineCommentTest("//a","");
|
||||
splitToLineCommentTest("a//b","a");
|
||||
splitToLineCommentTest("\"a\"//b","\"a\"");
|
||||
splitToLineCommentTest("a//\"b\"","a");
|
||||
|
||||
// some basic cases with a '//' in a string (no comment)
|
||||
splitToLineCommentTest("\"//\"","\"//\"");
|
||||
splitToLineCommentTest(" \" // \" "," \" // \" ");
|
||||
splitToLineCommentTest("\" // a \"","\" // a \"");
|
||||
|
||||
// some cases with a bit of everything
|
||||
splitToLineCommentTest("a\"//b\"//c","a\"//b\"");
|
||||
splitToLineCommentTest(" a \" // b \" // c "," a \" // b \" ");
|
||||
splitToLineCommentTest("\" // a \" b // c ","\" // a \" b ");
|
||||
|
||||
// test some simeple escape cases
|
||||
splitToLineCommentTest2("\\", "\\", "\\" );
|
||||
splitToLineCommentTest2("a\\bc", "a\\bc", "a\\bc" );
|
||||
splitToLineCommentTest2("\\/", "\\/", "\\/" );
|
||||
splitToLineCommentTest2("\\//", "\\//", "\\" );
|
||||
splitToLineCommentTest2("\\///", "\\/", "\\" );
|
||||
splitToLineCommentTest2("\"//\"", "\"//\"", "\"//\"" );
|
||||
splitToLineCommentTest2("\\\"//\"//", "\\\"", "\\\"//\"" );
|
||||
splitToLineCommentTest2("\"\\//\"//", "\"\\//\"", "\"\\//\"" );
|
||||
splitToLineCommentTest2("\"//\\\"//", "\"//\\\"//", "\"//\\\"" );
|
||||
splitToLineCommentTest2("\"//\"\\//", "\"//\"\\//", "\"//\"\\" );
|
||||
splitToLineCommentTest2("\"//\"//\\", "\"//\"", "\"//\"" );
|
||||
}
|
||||
|
||||
static void atoiTest()
|
||||
{
|
||||
// atosi - valid values
|
||||
nlassert(NLMISC::CSString("-2147483648").atosi()==-(int)0x80000000u);
|
||||
nlassert(NLMISC::CSString("-1").atosi()==-1);
|
||||
nlassert(NLMISC::CSString("0").atosi()==0);
|
||||
nlassert(NLMISC::CSString("1").atosi()==1);
|
||||
nlassert(NLMISC::CSString("2147483647").atosi()==0x7FFFFFFF);
|
||||
nlassert(NLMISC::CSString("+2147483647").atosi()==0x7FFFFFFF);
|
||||
|
||||
// atosi - invalid values
|
||||
nlassert(NLMISC::CSString("-2147483649").atosi()==0);
|
||||
nlassert(NLMISC::CSString("2147483648").atosi()==0);
|
||||
nlassert(NLMISC::CSString("123abc").atosi()==0);
|
||||
nlassert(NLMISC::CSString("++1").atosi()==0);
|
||||
nlassert(NLMISC::CSString("--1").atosi()==0);
|
||||
nlassert(NLMISC::CSString("").atosi()==0);
|
||||
|
||||
// atoui - valid values
|
||||
nlassert(NLMISC::CSString("0").atoui()==0);
|
||||
nlassert(NLMISC::CSString("1").atoui()==1);
|
||||
nlassert(NLMISC::CSString("2147483648").atoui()==0x80000000u);
|
||||
nlassert(NLMISC::CSString("4294967295").atoui()==0xFFFFFFFFu);
|
||||
|
||||
// atoui - invalid values
|
||||
nlassert(NLMISC::CSString("").atoui()==0);
|
||||
nlassert(NLMISC::CSString("-1").atoui()==0);
|
||||
nlassert(NLMISC::CSString("+1").atoui()==0);
|
||||
nlassert(NLMISC::CSString("4294967296").atoui()==0);
|
||||
}
|
||||
|
||||
static void loadAndSaveTest()
|
||||
{
|
||||
const char* normalFile= "string_test.tmp";
|
||||
const char* lockedFile= "a/b/c/d/non_existent_directory/string_test_locked.tmp";
|
||||
|
||||
// test a normal case - write text to a file and read it back...
|
||||
NLMISC::CSString s0="hello world";
|
||||
NLMISC::CSString s1="moby";
|
||||
bool r0=s0.writeToFile(normalFile);
|
||||
nlassert(r0);
|
||||
bool r1=s1.readFromFile(normalFile);
|
||||
nlassert(r1);
|
||||
nlassert(s0==s1);
|
||||
|
||||
// test a case with an inaccessible file...
|
||||
NLMISC::CSString s2="bye bye blackbird";
|
||||
NLMISC::CSString s3="mop mop";
|
||||
bool r2=s2.writeToFile(lockedFile);
|
||||
nlassert(!r2);
|
||||
bool r3=s3.readFromFile(lockedFile);
|
||||
nlassert(!r3);
|
||||
nlassert(s3.empty());
|
||||
}
|
||||
|
||||
class CSStringTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
void init()
|
||||
{
|
||||
xmlTestSet();
|
||||
quoteTestSet();
|
||||
splitJoinTestSet();
|
||||
splitToLineCommentTestSet();
|
||||
atoiTest();
|
||||
loadAndSaveTest();
|
||||
}
|
||||
};
|
||||
|
||||
static CSStringTest Test;
|
@ -0,0 +1,69 @@
|
||||
/** \file tick_service.cpp
|
||||
* The TICK SERVICE deals with time management in the shard
|
||||
*
|
||||
* $Id: test.cpp,v 1.4 2005/04/25 23:55:00 miller Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "nel/misc/command.h"
|
||||
#include "nel/misc/variable.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/file.h"
|
||||
|
||||
#include "game_share/ryzom_version.h"
|
||||
#include "game_share/tick_event_handler.h"
|
||||
#include "game_share/singleton_registry.h"
|
||||
#include "game_share/handy_commands.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NLNET;
|
||||
|
||||
|
||||
/*
|
||||
* Initialise the service
|
||||
*/
|
||||
void CTest::init()
|
||||
{
|
||||
setVersion (RYZOM_VERSION);
|
||||
|
||||
// if we are connecting to a shard then start by initializing the tick interface
|
||||
if (IService::getInstance()->ConfigFile.getVarPtr("DontUseTS")==NULL || IService::getInstance()->ConfigFile.getVarPtr("DontUseTS")->asInt()==0)
|
||||
CTickEventHandler::init(CTest::tickUpdate);
|
||||
|
||||
CSingletonRegistry::getInstance()->init();
|
||||
}
|
||||
|
||||
/*
|
||||
* Update
|
||||
*/
|
||||
bool CTest::update()
|
||||
{
|
||||
CSingletonRegistry::getInstance()->serviceUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update
|
||||
*/
|
||||
void CTest::tickUpdate()
|
||||
{
|
||||
CSingletonRegistry::getInstance()->tickUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
* Release
|
||||
*/
|
||||
void CTest::release()
|
||||
{
|
||||
CSingletonRegistry::getInstance()->release();
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
// NLNET_SERVICE_MAIN
|
||||
//-----------------------------------------------
|
||||
NLNET_SERVICE_MAIN( CTest, "TEST", "test_service", 0, EmptyCallbackArray, "", "" );
|
||||
|
@ -0,0 +1,42 @@
|
||||
/** \file tick_service.h
|
||||
* The TICK SERVICE deals with time management in the shard
|
||||
*
|
||||
* $Id: test.h,v 1.1 2004/06/07 15:26:49 miller Exp $
|
||||
*/
|
||||
|
||||
#ifndef TEST_H
|
||||
#define TEST_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/time_nl.h"
|
||||
#include "nel/misc/common.h"
|
||||
|
||||
#include "nel/net/service.h"
|
||||
|
||||
/**
|
||||
* CTest
|
||||
*
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2001
|
||||
*/
|
||||
class CTest : public NLNET::IService
|
||||
{
|
||||
public :
|
||||
|
||||
/// Initialise the service
|
||||
void init();
|
||||
|
||||
/// Update
|
||||
bool update();
|
||||
|
||||
/// Tick Update
|
||||
static void tickUpdate();
|
||||
|
||||
/// Release
|
||||
void release();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //TICK_S_H
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Timer test
|
||||
|
||||
project: RYZOM / TEST
|
||||
*/
|
||||
|
||||
#include "game_share/timer.h"
|
||||
|
||||
class CTimerTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
class CTimerTestTimerEvent:public CTimerEvent
|
||||
{
|
||||
public:
|
||||
void timerCallback(CTimer* owner)
|
||||
{
|
||||
nlinfo("tick!");
|
||||
// repeat every 20 ticks
|
||||
owner->setRemaining(20,this);
|
||||
}
|
||||
};
|
||||
|
||||
void init()
|
||||
{
|
||||
_Timer.setRemaining(20,new CTimerTestTimerEvent);
|
||||
}
|
||||
|
||||
private:
|
||||
CTimer _Timer;
|
||||
};
|
||||
|
||||
static CTimerTest Test;
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
Utils test
|
||||
|
||||
project: RYZOM / TEST
|
||||
|
||||
*/
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
#include "game_share/singleton_registry.h"
|
||||
#include "game_share/utils.h"
|
||||
|
||||
void traceTest2(int i)
|
||||
{
|
||||
CSTRACE;
|
||||
if (i<2)
|
||||
traceTest2(++i);
|
||||
else
|
||||
SHOW_CALLSTACK;
|
||||
}
|
||||
|
||||
void traceTest()
|
||||
{
|
||||
CSTRACE_MSG("foo");
|
||||
traceTest2(0);
|
||||
{
|
||||
int i=0;
|
||||
CSTRACE_VAR(int,i);
|
||||
CSTRACE_VAL(int,i);
|
||||
i=1;
|
||||
SHOW_CALLSTACK;
|
||||
}
|
||||
WARN_CALLSTACK;
|
||||
}
|
||||
|
||||
class CUtilsTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
void init()
|
||||
{
|
||||
// nel info, warning and debug redirectrion tests
|
||||
nldebug("debug"); nlinfo("info"); nlwarning("warning");
|
||||
{
|
||||
CNLLogOverride hold(NLMISC::DebugLog);
|
||||
nldebug("debug"); nlinfo("info"); nlwarning("warning");
|
||||
}
|
||||
{
|
||||
CNLLogOverride hold(NLMISC::InfoLog);
|
||||
nldebug("debug"); nlinfo("info"); nlwarning("warning");
|
||||
}
|
||||
{
|
||||
CNLLogOverride hold(NLMISC::WarningLog);
|
||||
nldebug("debug"); nlinfo("info"); nlwarning("warning");
|
||||
}
|
||||
nldebug("debug"); nlinfo("info"); nlwarning("warning");
|
||||
|
||||
|
||||
// handy vector method tests
|
||||
std::vector<sint64> vect;
|
||||
|
||||
vectAppend(vect)= 0; nlassert(vect.size()==1); nlassert(vect[0]==0);
|
||||
vectAppend(vect)= 1; nlassert(vect.size()==2); nlassert(vect[1]==1);
|
||||
vectAppend(vect)= 2; nlassert(vect.size()==3); nlassert(vect[2]==2);
|
||||
|
||||
vectInsert(vect,2); nlassert(vect.size()==3); nlassert(vect[0]+vect[1]+vect[2]==3);
|
||||
vectInsert(vect,4); nlassert(vect.size()==4); nlassert(vect[3]==4);
|
||||
|
||||
// handy ptr class tests
|
||||
CTestClass tc;
|
||||
|
||||
CTestClass* tcptr= &tc;
|
||||
CTestClass& tcref= tc;
|
||||
IPtr<CTestClass> ptr;
|
||||
ptr= tcptr;
|
||||
ptr= &tc;
|
||||
ptr= &tcref;
|
||||
++ptr;
|
||||
--ptr;
|
||||
tcptr= ptr.operator->();
|
||||
tcref= *ptr;
|
||||
nlassert(ptr==ptr);
|
||||
nlassert(!(ptr!=ptr));
|
||||
nlassert(ptr==tcptr);
|
||||
nlassert(!(ptr!=tcptr));
|
||||
|
||||
CTestClass const* ctcptr= &tc;
|
||||
CTestClass const& ctcref= tc;
|
||||
IConstPtr<CTestClass> cptr;
|
||||
cptr= ctcptr;
|
||||
cptr= &tc;
|
||||
cptr= &ctcref;
|
||||
++cptr;
|
||||
--cptr;
|
||||
ctcptr= cptr.operator->();
|
||||
// ctcref= *cptr;
|
||||
nlassert(cptr==cptr);
|
||||
nlassert(!(cptr!=cptr));
|
||||
nlassert(cptr==ctcptr);
|
||||
nlassert(!(cptr!=ctcptr));
|
||||
|
||||
// trace system test
|
||||
traceTest();
|
||||
}
|
||||
|
||||
class CTestClass
|
||||
{
|
||||
public:
|
||||
int a,b;
|
||||
};
|
||||
};
|
||||
|
||||
static CUtilsTest UtilsTest;
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Utils tests - macros that assert or break execution
|
||||
|
||||
project: RYZOM / TEST
|
||||
|
||||
*/
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
#include "game_share/singleton_registry.h"
|
||||
#include "game_share/utils.h"
|
||||
|
||||
static class CUtilsAssertTest: public IServiceSingleton
|
||||
{
|
||||
public:
|
||||
void init()
|
||||
{
|
||||
// warning system tests
|
||||
WARN("WARN");
|
||||
STOP("STOP");
|
||||
BOMB("BOMB",nldebug("BOMB action"));
|
||||
WARN_IF(true,"WARN_IF");
|
||||
STOP_IF(true,"STOP_IF");
|
||||
BOMB_IF(true,"BOMB_IF",nldebug("BOMB_IF action"));
|
||||
|
||||
// this should fail in debug but not in release
|
||||
nlassertd(false);
|
||||
|
||||
// testing the onChange macros
|
||||
int i=0;
|
||||
{
|
||||
ON_CHANGE_ASSERT(int,i);
|
||||
{
|
||||
++i;
|
||||
ON_CHANGE_ASSERT(int,i);
|
||||
// this should drop through fine
|
||||
}
|
||||
// there should be an assert here
|
||||
nldebug("There should be an assert after this message");
|
||||
}
|
||||
nldebug("There should be an assert before this message");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Test;
|
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
// $ASHost = "192.168.2.2";
|
||||
$ASPort = 46700;
|
||||
// $ASHost = "borisb";
|
||||
$ASHost = "workserver";
|
||||
require_once("../../../../code_private/nel/tools/net/admin/public_html/admin_modules_itf.php");
|
||||
|
||||
class MyAdminService extends CAdminServiceWeb
|
||||
{
|
||||
function commandResult($serviceModuleName, $result)
|
||||
{
|
||||
echo "Service $serviceModuleName returned '$result'<br>";
|
||||
}
|
||||
}
|
||||
|
||||
// connect to the AS
|
||||
$adminService = new MyAdminService;
|
||||
if ($adminService->connect($ASHost, $ASPort, $res) === false)
|
||||
{
|
||||
echo "Failed to connect to AS : '".$res."'<br>";
|
||||
die;
|
||||
}
|
||||
|
||||
if (!isset($_GET['action']))
|
||||
{
|
||||
// no request, display the form with status
|
||||
echo "sending status request...<br>";
|
||||
$status = $adminService->getStates();
|
||||
echo "Result : <br>";
|
||||
|
||||
echo "<form action='test_admin_service_2.php' method='get'>";
|
||||
echo "<input type='text' name='cmd' value=''> <input type='submit' name='action' value='GLOBAL_CMD'><br>";
|
||||
echo "<br>";
|
||||
echo "</form>";
|
||||
|
||||
|
||||
foreach($status as $value)
|
||||
{
|
||||
$varsStr = explode ( "\t", $value );
|
||||
$vars = array();
|
||||
foreach($varsStr as $var)
|
||||
{
|
||||
$parts = explode("=", $var);
|
||||
$vars[$parts[0]] = $parts[1];
|
||||
}
|
||||
|
||||
echo "<form action='test_admin_service_2.php' method='get'>";
|
||||
echo "Service '".$vars['AliasName']."' :<br>";
|
||||
echo "<li>RunningState = '".$vars['RunningState']."'<br>";
|
||||
echo "<li>RunningTags = '".$vars['RunningTags']."'<br>";
|
||||
echo "<li>Longname = '".$vars['LongName']."'<br>";
|
||||
echo "<li>Shortname = '".$vars['ShortName']."'<br>";
|
||||
echo "<li>Host = '".$vars['Hostname']."'<br>";
|
||||
echo "<li>State = '".$vars['State']."'<br>";
|
||||
echo "<li>NoReportSince = '".$vars['NoReportSince']."' (seconds)<br>";
|
||||
echo "<li>RawState = '".$value."'<br>";
|
||||
echo "<input type='hidden' name='serviceAlias' value='".$vars['AliasName']."'> ";
|
||||
echo "<input type='submit' name='action' value='START'> ";
|
||||
echo "<input type='submit' name='action' value='STOP' > ";
|
||||
echo "<input type='submit' name='action' value='RESTART'> ";
|
||||
echo "<input type='submit' name='action' value='KILL'> ";
|
||||
echo "<input type='submit' name='action' value='ABORT'> ";
|
||||
echo "<br>";
|
||||
echo "<input type='text' name='serviceCmd' value=''> <input type='submit' name='action' value='SERVICE_CMD'><br>";
|
||||
echo "<input type='text' name='controlCmd' value=''> <input type='submit' name='action' value='CONTROL_CMD'><br>";
|
||||
// echo "<input type='text' name='cmd' value=''> <input type='submit' name='action' value='GLOBAL_CMD'><br>";
|
||||
echo "<br>";
|
||||
echo "</form>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Connection result : '$res'<br>";
|
||||
// execute the request
|
||||
switch ($_GET['action'])
|
||||
{
|
||||
case "SERVICE_CMD":
|
||||
$adminService->serviceCmd($_GET['serviceAlias'], $_GET['serviceCmd']);
|
||||
echo "Waiting result...<br>";
|
||||
if (!$adminService->waitCallback())
|
||||
echo "Error will waiting for callback<br>";
|
||||
break;
|
||||
case "CONTROL_CMD":
|
||||
$adminService->controlCmd($_GET['serviceAlias'], $_GET['controlCmd']);
|
||||
echo "Waiting result...<br>";
|
||||
if (!$adminService->waitCallback())
|
||||
echo "Error will waiting for callback<br>";
|
||||
break;
|
||||
case "GLOBAL_CMD":
|
||||
$adminService->globalCmd($_GET['cmd']);
|
||||
echo "Waiting result...<br>";
|
||||
if (!$adminService->waitCallback())
|
||||
echo "Error will waiting for callback<br>";
|
||||
break;
|
||||
}
|
||||
|
||||
// back link
|
||||
echo '<a href="test_admin_service_2.php">Back to status page</a>';
|
||||
}
|
||||
|
||||
die;
|
||||
|
||||
if (!isset($_GET['req']))
|
||||
{
|
||||
echo "you must supply a 'req' argument as :<br>";
|
||||
echo " <li>req=cmd&service=<a service module name>&cmd=<your command><br>";
|
||||
echo " <li>req=ctrl&service=<a service module name>&cmd=<your command><br>";
|
||||
echo " <li>req=glob&cmd=<your command><br>";
|
||||
echo " <li>req=status<br>";
|
||||
echo " <li>req=hrg&varAddr=<varAddr>start=<unix start date>end=<unix end date>step=<millisecond step><br>";
|
||||
die();
|
||||
}
|
||||
else if ($_GET['req'] === "status")
|
||||
{
|
||||
$adminService = new MyAdminService;
|
||||
$adminService->connect($ASHost, $ASPort, $res);
|
||||
echo "Connection result : '$res'<br>";
|
||||
|
||||
echo "sending status request...<br>";
|
||||
$status = $adminService->getStates();
|
||||
echo "Status : <br>";
|
||||
foreach($status as $value)
|
||||
echo "$value<br>";
|
||||
echo "<br>";
|
||||
}
|
||||
else if ($_GET['req'] === "cmd")
|
||||
{
|
||||
$adminService = new MyAdminService;
|
||||
$adminService->connect($ASHost, $ASPort, $res);
|
||||
echo "Connection result : '$res'<br>";
|
||||
|
||||
echo "sending command...<br>";
|
||||
$adminService->serviceCmd($_GET['service'], $_GET['cmd']);
|
||||
echo "Waiting result...<br>";
|
||||
if (!$adminService->waitCallback())
|
||||
echo "Error will waiting for callback<br>";
|
||||
}
|
||||
else if ($_GET['req'] === "ctrl")
|
||||
{
|
||||
$adminService = new MyAdminService;
|
||||
$adminService->connect($ASHost, $ASPort, $res);
|
||||
echo "Connection result : '$res'<br>";
|
||||
|
||||
echo "sending command...<br>";
|
||||
$adminService->controlCmd($_GET['service'], $_GET['cmd']);
|
||||
echo "Waiting result...<br>";
|
||||
if (!$adminService->waitCallback())
|
||||
echo "Error will waiting for callback<br>";
|
||||
}
|
||||
else if ($_GET['req'] === "glob")
|
||||
{
|
||||
$adminService = new MyAdminService;
|
||||
$adminService->connect($ASHost, $ASPort, $res);
|
||||
echo "Connection result : '$res'<br>";
|
||||
|
||||
echo "sending command...<br>";
|
||||
$adminService->globalCmd($_GET['cmd']);
|
||||
echo "Waiting result...<br>";
|
||||
if (!$adminService->waitCallback())
|
||||
echo "Error will waiting for callback<br>";
|
||||
}
|
||||
else if ($_GET['req'] === "hrgraph")
|
||||
{
|
||||
$adminService = new MyAdminService;
|
||||
$adminService->connect($ASHost, $ASPort, $res);
|
||||
echo "Connection result : '$res'<br>";
|
||||
|
||||
echo "sending HR graph req...<br>";
|
||||
$ret = $adminService->getHighRezGraph($_GET['varAddr'], $_GET['start'],$_GET['end'],$_GET['step']);
|
||||
echo "Result :<br>";
|
||||
foreach($ret as $value)
|
||||
echo "$value<br>";
|
||||
echo "<br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "invalid request '".$_GET['req']."<br>";
|
||||
}
|
||||
echo "End of page<br>";
|
||||
?>
|
@ -0,0 +1,125 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Ryzom Ring</title>
|
||||
</head>
|
||||
<body>
|
||||
<p><H1>Welcome in Ryzom Ring</H1>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
// some colors....
|
||||
|
||||
for ($i=0; $i<256; ++$i)
|
||||
{
|
||||
// printf('code = #%02x%02x%02x', $i*16, 255-$i*16, 128);
|
||||
printf('<font color="#%02x%02x%02x>-=X=-</font>', $i, 255-$i, 128);
|
||||
}
|
||||
echo "<br>";
|
||||
?>
|
||||
|
||||
<form action="plan_edit_session.php" method="post">
|
||||
<input type="submit" name="button" value="Schedule editing session">
|
||||
|
||||
<select name="toto">
|
||||
<option value ="volvo">Volvo</option>
|
||||
<option value ="saab">Saab</option>
|
||||
<option value ="opel" selected="selected">Opel (preselected)</option>
|
||||
<option value ="audi">Audi</option>
|
||||
</select>
|
||||
|
||||
</form>
|
||||
<form action="plan_anim_session.php" method="post">
|
||||
<input type="submit" name="button" value="Schedule animation session">
|
||||
</form>
|
||||
<br>
|
||||
|
||||
<!--<form action="http://borisb2/ring/edit_session.php" method="post">-->
|
||||
<form action="edit_session.php" method="post">
|
||||
<table width="100%" cellpadding="5" border = "5" bgcolor="#003366">
|
||||
<tr>
|
||||
<td width="20%" align="center">
|
||||
<input name="GestSub" value="Gestion abonnement" type="submit" z_btn_tmpl="html_text_button_look2">
|
||||
</td>
|
||||
<td width="40%" align="right">
|
||||
<input name="EnterAtys" value="Rejoindre Atys" type="submit">
|
||||
</td>
|
||||
<td width="40%">
|
||||
<input name="ResumeSession" value="Resume" type="submit">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<input name="EnterOutland" value="Outlands" type="submit">
|
||||
</td>
|
||||
<td align="right">
|
||||
<input name="StartAnimSession" value="Start Anim session" type="submit">
|
||||
</td>
|
||||
<td>
|
||||
<input name="StartEditSession" value="Start Edit sessions" type="submit">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#662222" align="center">
|
||||
<input name="Quit" value="Quit" type="submit" z_btn_tmpl="html_text_button_look2">
|
||||
</td>
|
||||
<td align="right">
|
||||
<input name="Scheduling" value="Schedule edit or anim session" type="submit">
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Calendrier [filter combo box]
|
||||
|
||||
<table width="100%" cellspacing="0" border = "2">
|
||||
<tr>
|
||||
<td width="20%">
|
||||
</td>
|
||||
<td width="15%">
|
||||
<h4>En cours</h4>
|
||||
</td>
|
||||
<td width="50%">
|
||||
</td>
|
||||
<td width="15%">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
Animateur
|
||||
</td>
|
||||
<td>
|
||||
Description<br>
|
||||
blablablable
|
||||
</td>
|
||||
<td>
|
||||
Gerer
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
Joueur
|
||||
</td>
|
||||
<td>
|
||||
Description<br>
|
||||
blablablable
|
||||
</td>
|
||||
<td>
|
||||
Rejoindre
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<hr/>
|
||||
<br/>
|
||||
<p> <a href="edit_session.php"><h2>Start an editing session</h2></a> </p>
|
||||
<p> <a href="anim_session.php"><h2>Start an Animation session</h2></a> </p>
|
||||
<p> <a href="play_ryzom.php"><h2>Enter Ryzom as usual</h2></a> </p>
|
||||
<p/>
|
||||
<p> pipo et molo<a href="web_start.php">Reload this page</a> </p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
echo "<H1>Language Header displayer</H1>";
|
||||
|
||||
$language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
|
||||
echo "Language = ".$language."<br>";
|
||||
|
||||
?>
|
@ -0,0 +1,347 @@
|
||||
<?php
|
||||
|
||||
include('test_web_interface_itf.php');
|
||||
|
||||
ob_implicit_flush();
|
||||
|
||||
$host = "192.168.0.1";
|
||||
$port = 8061;
|
||||
$state = 0;
|
||||
|
||||
function returnUInt32($i32)
|
||||
{
|
||||
global $state;
|
||||
|
||||
printf("returnUInt32(%x)<br>", $i32);
|
||||
var_dump($i32);
|
||||
|
||||
if ($state == 0)
|
||||
{
|
||||
assert($i32 == 0x12345678);
|
||||
}
|
||||
else if ($state == 3)
|
||||
{
|
||||
assert($i32 == 0x12345678);
|
||||
}
|
||||
else if ($state == 9)
|
||||
{
|
||||
assert($i32 == 0x12345678);
|
||||
}
|
||||
else if ($state == 10)
|
||||
{
|
||||
assert($i32 == 0x87654321);
|
||||
}
|
||||
else if ($state == 12)
|
||||
{
|
||||
assert($i32 == 0x87654321);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
$state++;
|
||||
}
|
||||
|
||||
function returnUInt8($i8)
|
||||
{
|
||||
global $state;
|
||||
|
||||
printf("returnUInt8(%x)<br>", $i8);
|
||||
var_dump($i8);
|
||||
|
||||
|
||||
if ($state == 1)
|
||||
{
|
||||
assert($i8 == 0xf1);
|
||||
}
|
||||
else if ($state == 4)
|
||||
{
|
||||
assert($i8 == 0x01);
|
||||
}
|
||||
else if ($state == 11)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
$state++;
|
||||
}
|
||||
|
||||
function returnString($str)
|
||||
{
|
||||
global $state;
|
||||
|
||||
printf("returnString(\"%s\")<br>", $str);
|
||||
|
||||
if ($state == 2)
|
||||
{
|
||||
assert($str == "hello world");
|
||||
}
|
||||
else if ($state == 5)
|
||||
{
|
||||
assert($str == "ok");
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
$state++;
|
||||
}
|
||||
|
||||
function returnComposite1($i32, $i8, $str)
|
||||
{
|
||||
global $state;
|
||||
if ($state == 6)
|
||||
{
|
||||
assert($i32 == 0x12345678);
|
||||
assert($i8 == 0x9a);
|
||||
assert($str == 'hal');
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
$state++;
|
||||
}
|
||||
|
||||
function returnComposite2($str1, $str2, $str3, $str4)
|
||||
{
|
||||
global $state;
|
||||
if ($state == 7)
|
||||
{
|
||||
assert($str1 == "ABCD");
|
||||
assert($str2 == "EFGH IJKL");
|
||||
assert($str3 == "MNO");
|
||||
assert($str4 == "PQ");
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
$state++;
|
||||
}
|
||||
function returnComposite3($i81, $i321, $str1, $i82, $i322, $str2, $i83, $i323, $str3, $i84, $i324, $str4, $i325, $i85)
|
||||
{
|
||||
global $state;
|
||||
if ($state == 8)
|
||||
{
|
||||
assert($i81 == 0x9a);
|
||||
assert($i321 == 0x12345678);
|
||||
assert($str1 == "ABC");
|
||||
assert($i82 == 0x34);
|
||||
assert($i322 == 0xbcdef012);
|
||||
assert($str2 == "DEFGH");
|
||||
assert($i83 == 0xcd);
|
||||
assert($i323 == 0x567890ab);
|
||||
assert($str3 == "I");
|
||||
assert($i84 == 0x67);
|
||||
assert($i324 == 0xef012345);
|
||||
assert($str4 == "");
|
||||
assert($i325 == 0x01234567);
|
||||
assert($i85 == 0x89);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
$state++;
|
||||
}
|
||||
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
|
||||
// init the test session
|
||||
$ret = $tstProxy->beginTest();
|
||||
assert($ret);
|
||||
$tstProxy->close();
|
||||
usleep(1000*500); // wait 10ms
|
||||
|
||||
///////////////////////////
|
||||
// step 1
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
echo "A<br>";
|
||||
$ret = $tstProxy->sendUInt32(0x12345678);
|
||||
assert($ret);
|
||||
echo "B<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "C<br>";
|
||||
// diconnect
|
||||
$tstProxy->close();
|
||||
// usleep(1000*200); // wait 10ms
|
||||
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
echo "D<br>";
|
||||
$ret = $tstProxy->sendUInt8(0xf1);
|
||||
assert($ret);
|
||||
echo "E<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "F<br>";
|
||||
// diconnect
|
||||
$tstProxy->close();
|
||||
// usleep(1000*200); // wait 10ms
|
||||
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
echo "G<br>";
|
||||
$ret = $tstProxy->sendString("hello world");
|
||||
assert($ret);
|
||||
echo "H<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "I<br>";
|
||||
// diconnect
|
||||
$tstProxy->close();
|
||||
// usleep(1000*200); // wait 10ms
|
||||
|
||||
////////////////////////
|
||||
// step 2
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
echo "J<br>";
|
||||
$ret = $tstProxy->sendUInt32(0xFEDCBA98);
|
||||
assert($ret);
|
||||
echo "K<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "L<br>";
|
||||
|
||||
$ret = $tstProxy->sendUInt8(0xCC);
|
||||
assert($ret);
|
||||
echo "M<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "N<br>";
|
||||
|
||||
$ret = $tstProxy->sendString("hello world");
|
||||
assert($ret);
|
||||
echo "O<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "P<br>";
|
||||
// diconnect
|
||||
$tstProxy->close();
|
||||
// usleep(1000*200); // wait 10ms
|
||||
|
||||
////////////////////////
|
||||
// step 3
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
echo "Q<br>";
|
||||
$ret = $tstProxy->composite1(0x12345678, 0x9A, "Ibm");
|
||||
assert($ret);
|
||||
echo "R<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "S<br>";
|
||||
|
||||
$ret = $tstProxy->composite2("ABCD", "EFGH IJKL", "MNO", "PQ");
|
||||
assert($ret);
|
||||
echo "T<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "U<br>";
|
||||
|
||||
$ret = $tstProxy->composite3(0x9a, 0x12345678, "ABC",
|
||||
0x34, 0xbcdef012, "DEFGH",
|
||||
0xcd, 0x567890ab, "I",
|
||||
0x67, 0xef012345, "",
|
||||
0x01234567, 0x89);
|
||||
assert($ret);
|
||||
echo "V<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "W<br>";
|
||||
// diconnect
|
||||
$tstProxy->close();
|
||||
// usleep(1000*200); // wait 10ms
|
||||
|
||||
///////////////////////////////
|
||||
// step 4
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
echo "X<br>";
|
||||
$ret = $tstProxy->sendUInt32(0x12345678);
|
||||
assert($ret);
|
||||
echo "Y<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "Z<br>";
|
||||
// wait another return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "AA<br>";
|
||||
// diconnect
|
||||
$tstProxy->close();
|
||||
// usleep(1000*200); // wait 10ms
|
||||
|
||||
/////////////////////////////////
|
||||
// step 5
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
echo "AB<br>";
|
||||
$ret = $tstProxy->sendUInt32(0x12345678);
|
||||
assert($ret);
|
||||
echo "AC<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "AD<br>";
|
||||
// wait another return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret);
|
||||
echo "AE<br>";
|
||||
|
||||
// diconnect
|
||||
$tstProxy->close();
|
||||
// usleep(1000*200); // wait 10ms
|
||||
|
||||
/////////////////////////////////
|
||||
// step 6
|
||||
$tstProxy = new CTestInterfaceWeb;
|
||||
$ret = $tstProxy->connect($host, $port, $res);
|
||||
assert($ret);
|
||||
echo "AF<br>";
|
||||
$ret = $tstProxy->sendUInt32(0x12345678);
|
||||
assert($ret);
|
||||
echo "AG<br>";
|
||||
// wait the return message
|
||||
$ret = $tstProxy->waitCallback();
|
||||
assert($ret == false);
|
||||
echo "AH<br>";
|
||||
|
||||
// diconnect
|
||||
$tstProxy->close();
|
||||
|
||||
echo "All test done<br>";
|
||||
// usleep(1000*200); // wait 10ms
|
||||
?>
|
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
include('test_web_interface_itf.php');
|
||||
|
||||
// force output immediatly
|
||||
ob_implicit_flush();
|
||||
echo "Starting web interface test..<br>";
|
||||
|
||||
// declare a class that overide the callbacks
|
||||
|
||||
class CMyInterface extends CTestInterfaceWeb2
|
||||
{
|
||||
function returnVectorUInt32($i32)
|
||||
{
|
||||
echo "CMyInterface::returnVectorUint32 called<br>";
|
||||
|
||||
print_r($i32);echo"<br>";
|
||||
}
|
||||
|
||||
function returnVectorString($vstr)
|
||||
{
|
||||
echo "CMyInterface::returnVectorString called<br>";
|
||||
|
||||
print_r($vstr);echo"<br>";
|
||||
}
|
||||
|
||||
function returnMixedVector($param1, $vstr, $vi32)
|
||||
{
|
||||
echo "CMyInterface::returnMixedVevtor called<br>";
|
||||
|
||||
echo "$param1<br>";
|
||||
print_r($vstr);echo"<br>";
|
||||
print_r($vi32);echo"<br>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$interf = new CMyInterface;
|
||||
|
||||
// connect to the server
|
||||
echo "Connecting...<br>";
|
||||
$res = "";
|
||||
$interf->connect("192.168.0.1", 8062, $res);
|
||||
echo "Conn result : '$res'<br>";
|
||||
|
||||
$arr = array(1,2,3,4,5,6,7,8,9);
|
||||
echo "Calling sendVectorUInt32...<br>";
|
||||
$interf->sendVectorUInt32($arr);
|
||||
|
||||
echo "Waiting callback...<br>";
|
||||
$interf->waitCallback();
|
||||
|
||||
$arr = array("a ldkjfmdslk", "b slekjf lef", "c smdlkjfs", "d slkdjfdsmfkj", "e mdlfkdsm");
|
||||
echo "Calling sendVectorUInt32...<br>";
|
||||
$interf->sendVectorString($arr);
|
||||
|
||||
echo "Waiting callback...<br>";
|
||||
$interf->waitCallback();
|
||||
|
||||
echo "Calling simple twoway...<br>";
|
||||
$ret = $interf->twoWayCall("toto");
|
||||
$ret = $interf->twoWayCall("toto");
|
||||
assert($ret === "toto");
|
||||
$ret = $interf->twoWayCall("titi");
|
||||
assert($ret === "titi");
|
||||
$ret = $interf->twoWayCall("qsmflkjsdgoishdfgoiuh ihf isqouhf skqrgbiq qo'zhto'èt_yzaèhtàaéç't_hpg");
|
||||
assert($ret === "qsmflkjsdgoishdfgoiuh ihf isqouhf skqrgbiq qo'zhto'èt_yzaèhtàaéç't_hpg");
|
||||
echo "Twoway call returned $ret<br>";
|
||||
|
||||
echo "Calling int twoway<br>";
|
||||
$ret = $interf->twoWayCallInt(1234);
|
||||
assert($ret == 1234);
|
||||
|
||||
echo "Calling enum twoway<br>";
|
||||
$ret = $interf->twoWayCallInt("enum_b");
|
||||
assert($ret == "enum_b");
|
||||
|
||||
echo "Calling int vector twoway<br>";
|
||||
$arr = array(1,2,3,4,5,6);
|
||||
$ret = $interf->twoWayCallVector($arr);
|
||||
print_r($ret);echo "<br>";
|
||||
print_r($arr);echo "<br>";
|
||||
assert($ret == $arr);
|
||||
|
||||
echo "Calling mixed vector<br>";
|
||||
$interf->mixedVector(1234, array("a", "b", "c", "d"), array(1,2,3,4,5,6));
|
||||
$interf->waitCallback();
|
||||
|
||||
echo "Calling mixed vector twoway<br>";
|
||||
$ret = $interf->mixedTwoWayVector(1234, array("a", "b", "c", "d"), array(1,2,3,4,5,6));
|
||||
assert($ret == 1234);
|
||||
|
||||
echo "Test ended<br>";
|
||||
?>
|
Loading…
Reference in New Issue