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; +}