* Added simple test application to be able to see node monitoring messages

in order to reproduce bug #5405.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35526 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-02-19 21:35:46 +00:00
parent b9fa1de995
commit 75e7a5adae
2 changed files with 99 additions and 0 deletions
+5
View File
@@ -21,6 +21,11 @@ SimpleTest lock_node_test :
: be
;
SimpleTest node_monitor_test :
node_monitor_test.cpp
: be
;
SimpleTest page_fault_cache_merge_test : page_fault_cache_merge_test.cpp ;
SimpleTest path_resolution_test : path_resolution_test.cpp ;
@@ -0,0 +1,94 @@
/*
* Copyright 2010, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include <Application.h>
#include <Entry.h>
#include <NodeMonitor.h>
class Application : public BApplication {
public:
Application();
virtual ~Application();
protected:
virtual void ArgvReceived(int32 argCount, char** args);
virtual void ReadyToRun();
virtual void MessageReceived(BMessage* message);
private:
bool fWatchingNode;
};
Application::Application()
:
BApplication("application/x-vnd.test-node-monitor-test"),
fWatchingNode(false)
{
}
Application::~Application()
{
}
void
Application::ArgvReceived(int32 argCount, char** args)
{
uint32 flags = B_WATCH_STAT;
for (int32 i = 0; i < argCount; i++) {
BEntry entry(args[i]);
if (!entry.Exists()) {
fprintf(stderr, "Entry does not exist: %s\n", args[i]);
continue;
}
node_ref nodeRef;
entry.GetNodeRef(&nodeRef);
if (watch_node(&nodeRef, flags, this) == B_OK)
fWatchingNode = true;
}
}
void
Application::ReadyToRun()
{
if (!fWatchingNode)
Quit();
}
void
Application::MessageReceived(BMessage* message)
{
switch (message->what) {
case B_NODE_MONITOR:
message->PrintToStream();
break;
default:
BApplication::MessageReceived(message);
}
}
// #pragma mark -
int
main(int argc, char** argv)
{
Application app;
app.Run();
return 0;
}