From c2e8b5572c9d71db91d3e9cac2f61637e9bf4f08 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 8 Aug 2002 22:03:06 +0000 Subject: [PATCH] Added find_test_app() functions that return the path/an entry_ref for a given test app. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@658 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/kits/app/common/AppRunner.cpp | 40 ++++++++++++++++++++----- src/tests/kits/app/common/AppRunner.h | 3 ++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/tests/kits/app/common/AppRunner.cpp b/src/tests/kits/app/common/AppRunner.cpp index 6fdacc56f4..bb28f49bab 100644 --- a/src/tests/kits/app/common/AppRunner.cpp +++ b/src/tests/kits/app/common/AppRunner.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -46,13 +47,7 @@ AppRunner::Run(const char *command, const char *args, bool findCommand) // get the app path BString appPath; if (findCommand) { - appPath = BTestShell::GlobalTestDir(); - appPath.CharacterEscape(" \t\n!\"'`$&()?*+{}[]<>|", '\\'); - appPath += "/kits/app/"; - appPath += command; - #ifdef TEST_R5 - appPath += "_r5"; - #endif + find_test_app(command, &appPath); command = appPath.String(); } // add args, i.e. compose the command line @@ -253,3 +248,34 @@ port_id AppRunner::fTeamPort = -1; // fTeamPortLock BLocker AppRunner::fTeamPortLock; + +// find_test_app +status_t +find_test_app(const char *testApp, BString *path) +{ + status_t error = (testApp && path ? B_OK : B_BAD_VALUE); + if (error == B_OK) { + *path = BTestShell::GlobalTestDir(); + path->CharacterEscape(" \t\n!\"'`$&()?*+{}[]<>|", '\\'); + *path += "/kits/app/"; + *path += testApp; + #ifdef TEST_R5 + *path += "_r5"; + #endif + } + return error; +} + +// find_test_app +status_t +find_test_app(const char *testApp, entry_ref *ref) +{ + status_t error = (testApp && ref ? B_OK : B_BAD_VALUE); + BString path; + if (error == B_OK) + error = find_test_app(testApp, &path); + if (error == B_OK) + error = get_ref_for_path(path.String(), ref); + return error; +} + diff --git a/src/tests/kits/app/common/AppRunner.h b/src/tests/kits/app/common/AppRunner.h index 382e56db5b..fafc5a0982 100644 --- a/src/tests/kits/app/common/AppRunner.h +++ b/src/tests/kits/app/common/AppRunner.h @@ -45,4 +45,7 @@ private: static BLocker fTeamPortLock; }; +status_t find_test_app(const char *testApp, BString *path); +status_t find_test_app(const char *testApp, entry_ref *ref); + #endif // APP_RUNNER_H