From 75e7a5adaef4b6619083ec554e1fab8d0d7aeb54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 19 Feb 2010 21:35:46 +0000 Subject: [PATCH] * 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 --- src/tests/system/kernel/Jamfile | 5 + src/tests/system/kernel/node_monitor_test.cpp | 94 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/tests/system/kernel/node_monitor_test.cpp diff --git a/src/tests/system/kernel/Jamfile b/src/tests/system/kernel/Jamfile index 5535410030..3e50fc40aa 100644 --- a/src/tests/system/kernel/Jamfile +++ b/src/tests/system/kernel/Jamfile @@ -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 ; diff --git a/src/tests/system/kernel/node_monitor_test.cpp b/src/tests/system/kernel/node_monitor_test.cpp new file mode 100644 index 0000000000..81d3738800 --- /dev/null +++ b/src/tests/system/kernel/node_monitor_test.cpp @@ -0,0 +1,94 @@ +/* + * Copyright 2010, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include +#include + + +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; +}