Added a simple test for the Dano message format reader (it accepts flattened message files as parameter).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13654 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-07-13 06:32:33 +00:00
parent b0ba19ba3a
commit 698b96ef9b
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,56 @@
#include <File.h>
#include <Message.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
namespace BPrivate {
status_t unflatten_dano_message(uint32 magic, BDataIO& stream, BMessage& message);
size_t dano_message_size(const char* buffer);
}
extern const char* __progname;
static const uint32 kMessageFormat = 'FOB2';
static const uint32 kMessageFormatSwapped = '2BOF';
int
main(int argc, char** argv)
{
if (argc < 2) {
fprintf(stderr, "usage: %s <flattened dano message>\n", __progname);
return -1;
}
for (int32 i = 1; i < argc; i++) {
BFile file(argv[i], B_READ_ONLY);
if (file.InitCheck() != B_OK) {
fprintf(stderr, "Could not open message \"%s\": %s\n", argv[i], strerror(file.InitCheck()));
continue;
}
off_t size;
if (file.GetSize(&size) != B_OK)
continue;
uint32 magic;
if (file.Read(&magic, sizeof(uint32)) != sizeof(uint32))
continue;
if (magic != kMessageFormat && magic != kMessageFormatSwapped) {
fprintf(stderr, "Not a dano message \"%s\"\n", argv[i]);
continue;
}
BMessage message;
if (BPrivate::unflatten_dano_message(magic, file, message) == B_OK)
message.PrintToStream();
}
return 0;
}

View File

@ -151,6 +151,15 @@ CommonTestLib libappteststub.so
:
;
SimpleTest DanoMessageTest :
DanoMessageTest.cpp
dano_message.cpp
: be ;
SEARCH on [ FGristFiles
dano_message.cpp
] = [ FDirName $(OBOS_TOP) src kits app ] ;
SubInclude OBOS_TOP src tests kits app bapplication ;
SubInclude OBOS_TOP src tests kits app bclipboard ;
SubInclude OBOS_TOP src tests kits app bcursor ;