Added some interesting new tests for BRoster::FindApp()/Launch(): App hint points to a link, document is cyclic or bad link, found application has no signature set in resources/attributes.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1439 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2002-10-07 22:06:11 +00:00
parent af8eec4080
commit 6a6ef24013
5 changed files with 527 additions and 59 deletions

View File

@ -147,6 +147,17 @@ case 13:mimeType is installed, but has no preferred application,
case 14:installed type mimeType, preferred app, app type not installed,
app has signature, app is trash =>
Should return B_LAUNCH_FAILED_APP_IN_TRASH.
case 15:installed type mimeType, preferred app, app type installed,
preferred app type has an app hint pointing to void,
no app with this signature exists =>
Should return B_LAUNCH_FAILED_APP_NOT_FOUND and unset the app type's
app hint.
case 16:installed type mimeType, preferred app, app type installed,
preferred app type has an app hint pointing to a cyclic link,
no app with this signature exists =>
R5: Should return B_OK and set the ref to refer to the link.
OBOS: Should return B_LAUNCH_FAILED_APP_NOT_FOUND and unset the app
type's app hint.
status_t FindApp(const char *mimeType, entry_ref *app) const
case 1: mimeType or app are NULL =>
@ -193,6 +204,10 @@ case 9: ref is valid, file has type,
case 10:ref is valid, file has no type, sniffing results in a type,
type is set on file,
common cases 2-14
case 11:ref is valid and refers to a cyclic link =>
Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
case 12:ref is valid and refers to a link to void =>
Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
status_t Launch() const: common cases
case 1: uninstalled type mimeType =>
@ -315,7 +330,25 @@ case 27:launch two apps with the same signature:
first app: ArgvReceived(), ReadyToRun(), QuitRequested()
(No second ArgvReceived()!)
second app: Launch() fails with B_ALREADY_RUNNING
case 28:installed type mimeType, preferred app, app type installed,
preferred app type has an app hint pointing to void,
no app with this signature exists =>
Should return B_LAUNCH_FAILED_APP_NOT_FOUND and unset the app type's
app hint.
case 29:installed type mimeType, preferred app, app type installed,
preferred app type has an app hint pointing to a cyclic link,
no app with this signature exists =>
Should return
OBOS: B_LAUNCH_FAILED_APP_NOT_FOUND and unset the app type's app hint.
R5: B_ENTRY_NOT_FOUND or B_LAUNCH_FAILED_NO_RESOLVE_LINK.
case 30:installed type mimeType, preferred app, app type installed,
preferred app type has an app hint that points to an app without a
signature, app will pass a different signature to the
BApplication constructor =>
Should return B_OK and set team to the ID of the team running the
application's executable. Should remove the incorrect app hint on
the app type. BRoster::GetRunningAppInfo() should return an app_info
with the signature passed to the BApplication constructor.
status_t Launch(const char *mimeType, BMessage *initialMsg,
team_id *appTeam) const
@ -404,6 +437,14 @@ case 10:ref is valid, file has no type, but preferred app, app type is not
Should return B_OK and set team to the ID of the team running the
application's executable. Should install the app type and set the app
hint on it.
case 11:ref is valid and refers to a cyclic link =>
Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
case 12:ref is valid and refers to a link to void =>
Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
case 13:ref is valid and refers to an executable without signature =>
Should return B_OK and set team to the ID of the team running the
application's executable.
status_t Launch(const entry_ref *ref, const BList *messageList,
team_id *appTeam) const
@ -452,6 +493,13 @@ case 11:ref is valid, file has no type, but preferred app, app type is not
Should return B_OK and set team to the ID of the team running the
application's executable. Should install the app type and set the app
hint on it.
case 12:ref is valid and refers to a cyclic link =>
Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
case 13:ref is valid and refers to a link to void =>
Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
case 14:ref is valid and refers to an executable without signature =>
Should return B_OK and set team to the ID of the team running the
application's executable.
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
team_id *appTeam) const
@ -506,4 +554,11 @@ case 11:ref is valid, file has no type, but preferred app, app type is not
Should return B_OK and set team to the ID of the team running the
application's executable. Should install the app type and set the app
hint on it. argv are ignored.
case 12:ref is valid and refers to a cyclic link =>
Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
case 13:ref is valid and refers to a link to void =>
Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
case 14:ref is valid and refers to an executable without signature =>
Should return B_OK and set team to the ID of the team running the
application's executable.

View File

@ -86,11 +86,11 @@ install_type(const char *type, const char *preferredApp = NULL,
// ref_for_path
static
entry_ref
ref_for_path(const char *filename)
ref_for_path(const char *filename, bool traverse = true)
{
entry_ref ref;
BEntry entry;
CHK(entry.SetTo(filename, true) == B_OK);
CHK(entry.SetTo(filename, traverse) == B_OK);
CHK(entry.GetRef(&ref) == B_OK);
return ref;
}
@ -522,13 +522,64 @@ CommonFindAppTest14(FindAppCaller &caller)
CHK(caller(fileType1, &ref) == B_LAUNCH_FAILED_APP_IN_TRASH);
}
/*
@case 15 installed type mimeType, preferred app, app type installed,
preferred app type has an app hint pointing to void,
no app with this signature exists
@results Should return B_LAUNCH_FAILED_APP_NOT_FOUND and unset the
app type's app hint.
*/
static
void
CommonFindAppTest15(FindAppCaller &caller)
{
BRoster roster;
set_type_app_hint(appType1, appFile1);
install_type(fileType1, appType1);
entry_ref ref;
CHK(caller(fileType1, &ref) == B_LAUNCH_FAILED_APP_NOT_FOUND);
entry_ref appHint;
CHK(BMimeType(appType1).GetAppHint(&appHint) == B_ENTRY_NOT_FOUND);
}
/*
@case 16 installed type mimeType, preferred app, app type installed,
preferred app type has an app hint pointing to a cyclic
link, no app with this signature exists
@results R5: Should return B_OK and set the ref to refer to the
link.
OBOS: Should return B_LAUNCH_FAILED_APP_NOT_FOUND and
unset the app type's app hint.
*/
static
void
CommonFindAppTest16(FindAppCaller &caller)
{
BRoster roster;
set_type_app_hint(appType1, appFile1);
install_type(fileType1, appType1);
system((string("ln -s ") + appFile1 + " " + appFile1).c_str());
entry_ref ref;
entry_ref appHint;
#ifdef TEST_R5
CHK(caller(fileType1, &ref) == B_OK);
CHK(ref_for_path(appFile1, false) == ref);
CHK(BMimeType(appType1).GetAppHint(&appHint) == B_OK);
CHK(appHint == ref);
#else
CHK(caller(fileType1, &ref) == B_LAUNCH_FAILED_APP_NOT_FOUND);
CHK(BMimeType(appType1).GetAppHint(&appHint) == B_ENTRY_NOT_FOUND);
#endif
}
typedef void commonTestFunction(FindAppCaller &caller);
static commonTestFunction *commonTestFunctions[] = {
CommonFindAppTest1, CommonFindAppTest2, CommonFindAppTest3,
CommonFindAppTest4, CommonFindAppTest5, CommonFindAppTest6,
CommonFindAppTest7, CommonFindAppTest8, CommonFindAppTest9,
CommonFindAppTest10, CommonFindAppTest11, CommonFindAppTest12,
CommonFindAppTest13, CommonFindAppTest14
CommonFindAppTest13, CommonFindAppTest14, CommonFindAppTest15,
CommonFindAppTest16
};
static int32 commonTestFunctionCount
= sizeof(commonTestFunctions) / sizeof(commonTestFunction*);
@ -735,7 +786,7 @@ void FindAppTester::FindAppTestB8()
install_type(fileType1, appType1);
create_file(testFile1, fileType1);
system((string("ln -s ") + testFile1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1));
entry_ref linkRef(ref_for_path(testLink1, false));
entry_ref ref;
CHK(roster.FindApp(&linkRef, &ref) == B_OK);
CHK(ref_for_path(appFile1) == ref);
@ -802,6 +853,33 @@ void FindAppTester::FindAppTestB10()
}
}
/*
status_t FindApp(entry_ref *ref, entry_ref *app) const
@case 11 ref is valid and refers to a cyclic link
@results Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
void FindAppTester::FindAppTestB11()
{
BRoster roster;
system((string("ln -s ") + testLink1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1, false));
entry_ref ref;
CHK(roster.FindApp(&linkRef, &ref) == B_LAUNCH_FAILED_NO_RESOLVE_LINK);
}
/*
status_t FindApp(entry_ref *ref, entry_ref *app) const
@case 12 ref is valid and refers to a link to void
@results Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
void FindAppTester::FindAppTestB12()
{
BRoster roster;
system((string("ln -s ") + testFile1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1, false));
entry_ref ref;
CHK(roster.FindApp(&linkRef, &ref) == B_LAUNCH_FAILED_NO_RESOLVE_LINK);
}
Test* FindAppTester::Suite()
@ -822,6 +900,8 @@ Test* FindAppTester::Suite()
ADD_TEST4(BRoster, SuiteOfTests, FindAppTester, FindAppTestB8);
ADD_TEST4(BRoster, SuiteOfTests, FindAppTester, FindAppTestB9);
ADD_TEST4(BRoster, SuiteOfTests, FindAppTester, FindAppTestB10);
ADD_TEST4(BRoster, SuiteOfTests, FindAppTester, FindAppTestB11);
ADD_TEST4(BRoster, SuiteOfTests, FindAppTester, FindAppTestB12);
return SuiteOfTests;
}

View File

@ -43,6 +43,8 @@ class FindAppTester : public BTestCase
void FindAppTestB8();
void FindAppTestB9();
void FindAppTestB10();
void FindAppTestB11();
void FindAppTestB12();
static Test* Suite();

View File

@ -116,11 +116,11 @@ install_type(const char *type, const char *preferredApp = NULL,
// ref_for_path
static
entry_ref
ref_for_path(const char *filename)
ref_for_path(const char *filename, bool traverse = true)
{
entry_ref ref;
BEntry entry;
CHK(entry.SetTo(filename, true) == B_OK);
CHK(entry.SetTo(filename, traverse) == B_OK);
CHK(entry.GetRef(&ref) == B_OK);
return ref;
}
@ -152,9 +152,10 @@ create_app(const char *filename, const char *signature,
CHK(file.SetTo(filename, B_READ_WRITE) == B_OK);
BAppFileInfo appFileInfo;
CHK(appFileInfo.SetTo(&file) == B_OK);
CHK(appFileInfo.SetSignature(signature) == B_OK);
if (signature)
CHK(appFileInfo.SetSignature(signature) == B_OK);
CHK(appFileInfo.SetAppFlags(appFlags) == B_OK);
if (install)
if (install && signature)
CHK(BMimeType(signature).Install() == B_OK);
// We write the signature into a separate attribute, just in case we
// decide to also test files without BEOS:APP_SIG attribute.
@ -1314,6 +1315,115 @@ CommonLaunchTest27(LaunchCaller &caller)
CHK(context.CheckNextMessage(caller, team1, cookie, MSG_TERMINATED));
}
/*
@case 28 installed type mimeType, preferred app, app type installed,
preferred app type has an app hint pointing to void,
no app with this signature exists
@results Should return B_LAUNCH_FAILED_APP_NOT_FOUND and unset the
app type's app hint.
*/
static
void
CommonLaunchTest28(LaunchCaller &caller)
{
LaunchContext context;
BRoster roster;
set_type_app_hint(appType1, appFile1);
install_type(fileType1, appType1);
team_id team;
CHK(context(caller, fileType1, &team) == B_LAUNCH_FAILED_APP_NOT_FOUND);
entry_ref appHint;
CHK(BMimeType(appType1).GetAppHint(&appHint) == B_ENTRY_NOT_FOUND);
}
/*
@case 29 installed type mimeType, preferred app, app type installed,
preferred app type has an app hint pointing to a cyclic
link, no app with this signature exists
@results Should return
OBOS: B_LAUNCH_FAILED_APP_NOT_FOUND and unset the app
type's app hint.
R5: B_ENTRY_NOT_FOUND or B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
static
void
CommonLaunchTest29(LaunchCaller &caller)
{
LaunchContext context;
BRoster roster;
set_type_app_hint(appType1, appFile1);
install_type(fileType1, appType1);
system((string("ln -s ") + appFile1 + " " + appFile1).c_str());
team_id team;
entry_ref appHint;
#if TEST_R5
if (caller.SupportsRefs()) {
CHK(context(caller, fileType1, &team)
== B_LAUNCH_FAILED_NO_RESOLVE_LINK);
} else
CHK(context(caller, fileType1, &team) == B_ENTRY_NOT_FOUND);
CHK(BMimeType(appType1).GetAppHint(&appHint) == B_OK);
CHK(appHint == ref_for_path(appFile1, false));
#else
CHK(context(caller, fileType1, &team) == B_LAUNCH_FAILED_APP_NOT_FOUND);
CHK(BMimeType(appType1).GetAppHint(&appHint) == B_ENTRY_NOT_FOUND);
#endif
}
/*
@case 30 installed type mimeType, preferred app, app type installed,
preferred app type has an app hint that points to an app
without a signature, app will pass a different signature
to the BApplication constructor
@results Should return B_OK and set team to the ID of the team
running the application's executable. Should remove the
incorrect app hint on the app type.
BRoster::GetRunningAppInfo() should return an app_info
with the signature passed to the BApplication constructor.
*/
static
void
CommonLaunchTest30(LaunchCaller &caller)
{
LaunchContext context;
BRoster roster;
create_app(appFile1, NULL);
set_type_app_hint(appType1, appFile1);
entry_ref appHint;
CHK(BMimeType(appType1).GetAppHint(&appHint) == B_OK);
install_type(fileType1, appType1);
team_id team;
CHK(context(caller, fileType1, &team) == B_OK);
entry_ref ref = ref_for_team(team);
CHK(ref_for_path(appFile1) == ref);
// OBOS: We unset the app hint for the app type. R5 leaves it untouched.
#ifdef TEST_R5
check_app_type(appType1, appFile1);
#else
CHK(BMimeType(appType1).GetAppHint(&appHint) == B_ENTRY_NOT_FOUND);
#endif
context.WaitForMessage(team, MSG_STARTED, true);
app_info appInfo;
CHK(roster.GetRunningAppInfo(team, &appInfo) == B_OK);
// R5 keeps appType1, OBOS updates the signature
#ifdef TEST_R5
CHK(!strcmp(appInfo.signature, appType1));
#else
CHK(!strcmp(appInfo.signature, kDefaultTestAppSignature));
#endif
context.Terminate();
int32 cookie = 0;
CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED));
CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref));
CHK(context.CheckMessageMessages(caller, team, cookie));
CHK(context.CheckArgvMessage(caller, team, cookie, &ref));
if (caller.SupportsRefs() && !caller.SupportsArgv())
CHK(context.CheckRefsMessage(caller, team, cookie));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_READY_TO_RUN));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_QUIT_REQUESTED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
}
typedef void commonTestFunction(LaunchCaller &caller);
static commonTestFunction *commonTestFunctions[] = {
CommonLaunchTest1, CommonLaunchTest2, CommonLaunchTest3,
@ -1324,7 +1434,8 @@ static commonTestFunction *commonTestFunctions[] = {
CommonLaunchTest16, CommonLaunchTest17, CommonLaunchTest18,
CommonLaunchTest19, CommonLaunchTest20, CommonLaunchTest21,
CommonLaunchTest22, CommonLaunchTest23, CommonLaunchTest24,
CommonLaunchTest25, CommonLaunchTest26, CommonLaunchTest27
CommonLaunchTest25, CommonLaunchTest26, CommonLaunchTest27,
CommonLaunchTest28, CommonLaunchTest29, CommonLaunchTest30
};
static int32 commonTestFunctionCount
= sizeof(commonTestFunctions) / sizeof(commonTestFunction*);
@ -1794,9 +1905,6 @@ void LaunchTester::LaunchTestD4()
SimpleFileCaller1 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -1836,9 +1944,6 @@ void LaunchTester::LaunchTestD5()
SimpleFileCaller1 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -1899,13 +2004,11 @@ void LaunchTester::LaunchTestD7()
install_type(fileType1, appType1);
create_file(testFile1, fileType1);
system((string("ln -s ") + testFile1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1));
entry_ref fileRef(ref_for_path(testFile1, false));
entry_ref linkRef(ref_for_path(testLink1, false));
SimpleFileCaller1 caller(linkRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -1919,7 +2022,7 @@ void LaunchTester::LaunchTestD7()
CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref));
CHK(context.CheckMessageMessages(caller, team, cookie));
// CHK(context.CheckArgvMessage(caller, team, cookie, &ref));
CHK(context.CheckRefsMessage(caller, team, cookie));
CHK(context.CheckRefsMessage(caller, team, cookie, &fileRef));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_READY_TO_RUN));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_QUIT_REQUESTED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
@ -1981,9 +2084,6 @@ void LaunchTester::LaunchTestD10()
SimpleFileCaller1 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, NULL, LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv, &team) == B_OK);
entry_ref ref = ref_for_team(team);
@ -2002,6 +2102,82 @@ void LaunchTester::LaunchTestD10()
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
}
/*
status_t Launch(const entry_ref *ref, const BMessage *initialMessage,
team_id *app_team) const
@case 11 ref is valid and refers to a cyclic link
@results Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
void LaunchTester::LaunchTestD11()
{
BRoster roster;
system((string("ln -s ") + testLink1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1, false));
BMessage message;
team_id team;
CHK(roster.Launch(&linkRef, &message, &team)
== B_LAUNCH_FAILED_NO_RESOLVE_LINK);
}
/*
status_t Launch(const entry_ref *ref, const BMessage *initialMessage,
team_id *app_team) const
@case 12 ref is valid and refers to a link to void
@results Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
void LaunchTester::LaunchTestD12()
{
BRoster roster;
system((string("ln -s ") + testFile1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1, false));
BMessage message;
team_id team;
CHK(roster.Launch(&linkRef, &message, &team)
== B_LAUNCH_FAILED_NO_RESOLVE_LINK);
}
/*
status_t Launch(const entry_ref *ref, const BMessage *initialMessage,
team_id *app_team) const
@case 13 ref is valid and refers to an executable without signature
@results Should return B_OK and set team to the ID of the team
running the application's executable.
*/
void LaunchTester::LaunchTestD13()
{
BRoster roster;
create_app(appFile1, NULL);
entry_ref fileRef(ref_for_path(appFile1));
SimpleFileCaller1 caller(fileRef);
LaunchContext context;
team_id team;
CHK(context(caller, appType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
entry_ref ref = ref_for_team(team);
CHK(ref_for_path(appFile1) == ref);
context.WaitForMessage(team, MSG_STARTED, true);
app_info appInfo;
CHK(roster.GetRunningAppInfo(team, &appInfo) == B_OK);
CHK(!strcmp(appInfo.signature, kDefaultTestAppSignature));
context.Terminate();
int32 cookie = 0;
CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED));
// CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref));
CHK(context.CheckArgsMessage(caller, team, cookie, &ref, NULL,
0, NULL, MSG_MAIN_ARGS));
CHK(context.CheckMessageMessages(caller, team, cookie));
// CHK(context.CheckArgvMessage(caller, team, cookie, &ref));
// CHK(context.CheckArgsMessage(caller, team, cookie, &ref, NULL,
// LaunchContext::kStandardArgc,
// LaunchContext::kStandardArgv,
// MSG_ARGV_RECEIVED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_READY_TO_RUN));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_QUIT_REQUESTED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
}
// SimpleFileCaller2
class SimpleFileCaller2 : public LaunchCaller {
public:
@ -2146,9 +2322,6 @@ void LaunchTester::LaunchTestE4()
SimpleFileCaller2 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -2188,9 +2361,6 @@ void LaunchTester::LaunchTestE5()
SimpleFileCaller2 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -2250,13 +2420,11 @@ void LaunchTester::LaunchTestE7()
install_type(fileType1, appType1);
create_file(testFile1, fileType1);
system((string("ln -s ") + testFile1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1));
entry_ref fileRef(ref_for_path(testFile1, false));
entry_ref linkRef(ref_for_path(testLink1, false));
SimpleFileCaller2 caller(linkRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -2270,7 +2438,7 @@ void LaunchTester::LaunchTestE7()
CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref));
CHK(context.CheckMessageMessages(caller, team, cookie));
// CHK(context.CheckArgvMessage(caller, team, cookie, &ref));
CHK(context.CheckRefsMessage(caller, team, cookie));
CHK(context.CheckRefsMessage(caller, team, cookie, &fileRef));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_READY_TO_RUN));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_QUIT_REQUESTED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
@ -2332,9 +2500,6 @@ void LaunchTester::LaunchTestE10()
SimpleFileCaller2 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, NULL, LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv, &team) == B_OK);
entry_ref ref = ref_for_team(team);
@ -2371,9 +2536,6 @@ void LaunchTester::LaunchTestE11()
SimpleFileCaller2 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
BList list;
CHK(context(caller, fileType1, &list, LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv, &team) == B_OK);
@ -2393,6 +2555,84 @@ void LaunchTester::LaunchTestE11()
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
}
/*
status_t Launch(const entry_ref *ref, const BList *messageList,
team_id *appTeam) const
@case 12 ref is valid and refers to a cyclic link
@results Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
void LaunchTester::LaunchTestE12()
{
BRoster roster;
system((string("ln -s ") + testLink1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1, false));
BMessage message;
team_id team;
BList list;
CHK(roster.Launch(&linkRef, &list, &team)
== B_LAUNCH_FAILED_NO_RESOLVE_LINK);
}
/*
status_t Launch(const entry_ref *ref, const BList *messageList,
team_id *appTeam) const
@case 13 ref is valid and refers to a link to void
@results Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
void LaunchTester::LaunchTestE13()
{
BRoster roster;
system((string("ln -s ") + testFile1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1, false));
BMessage message;
team_id team;
BList list;
CHK(roster.Launch(&linkRef, &list, &team)
== B_LAUNCH_FAILED_NO_RESOLVE_LINK);
}
/*
status_t Launch(const entry_ref *ref, const BList *messageList,
team_id *appTeam) const
@case 14 ref is valid and refers to an executable without signature
@results Should return B_OK and set team to the ID of the team
running the application's executable.
*/
void LaunchTester::LaunchTestE14()
{
BRoster roster;
create_app(appFile1, NULL);
entry_ref fileRef(ref_for_path(appFile1));
SimpleFileCaller2 caller(fileRef);
LaunchContext context;
team_id team;
CHK(context(caller, appType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
entry_ref ref = ref_for_team(team);
CHK(ref_for_path(appFile1) == ref);
context.WaitForMessage(team, MSG_STARTED, true);
app_info appInfo;
CHK(roster.GetRunningAppInfo(team, &appInfo) == B_OK);
CHK(!strcmp(appInfo.signature, kDefaultTestAppSignature));
context.Terminate();
int32 cookie = 0;
CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED));
// CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref));
CHK(context.CheckArgsMessage(caller, team, cookie, &ref, NULL,
0, NULL, MSG_MAIN_ARGS));
CHK(context.CheckMessageMessages(caller, team, cookie));
// CHK(context.CheckArgvMessage(caller, team, cookie, &ref));
// CHK(context.CheckArgsMessage(caller, team, cookie, &ref, NULL,
// LaunchContext::kStandardArgc,
// LaunchContext::kStandardArgv,
// MSG_ARGV_RECEIVED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_READY_TO_RUN));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_QUIT_REQUESTED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
}
// SimpleFileCaller3
class SimpleFileCaller3 : public LaunchCaller {
public:
@ -2537,9 +2777,6 @@ void LaunchTester::LaunchTestF4()
SimpleFileCaller3 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -2579,9 +2816,6 @@ void LaunchTester::LaunchTestF5()
SimpleFileCaller3 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -2641,13 +2875,11 @@ void LaunchTester::LaunchTestF7()
install_type(fileType1, appType1);
create_file(testFile1, fileType1);
system((string("ln -s ") + testFile1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1));
entry_ref fileRef(ref_for_path(testFile1, false));
entry_ref linkRef(ref_for_path(testLink1, false));
SimpleFileCaller3 caller(linkRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
@ -2658,9 +2890,16 @@ void LaunchTester::LaunchTestF7()
context.Terminate();
int32 cookie = 0;
CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED));
CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref));
// CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref));
CHK(context.CheckArgsMessage(caller, team, cookie, &ref, &fileRef,
LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv, MSG_MAIN_ARGS));
// CHK(context.CheckMessageMessages(caller, team, cookie));
CHK(context.CheckArgvMessage(caller, team, cookie, &ref));
// CHK(context.CheckArgvMessage(caller, team, cookie, &ref));
CHK(context.CheckArgsMessage(caller, team, cookie, &ref, &fileRef,
LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv,
MSG_ARGV_RECEIVED));
// CHK(context.CheckRefsMessage(caller, team, cookie));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_READY_TO_RUN));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_QUIT_REQUESTED));
@ -2723,9 +2962,6 @@ void LaunchTester::LaunchTestF10()
SimpleFileCaller3 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, NULL, 0, NULL, &team) == B_OK);
entry_ref ref = ref_for_team(team);
CHK(ref_for_path(appFile1) == ref);
@ -2761,9 +2997,6 @@ void LaunchTester::LaunchTestF11()
SimpleFileCaller3 caller(fileRef);
LaunchContext context;
team_id team;
BMessage message(MSG_1);
BList messages;
messages.AddItem(&message);
CHK(context(caller, fileType1, NULL, 1, NULL, &team) == B_OK);
entry_ref ref = ref_for_team(team);
CHK(ref_for_path(appFile1) == ref);
@ -2781,6 +3014,86 @@ void LaunchTester::LaunchTestF11()
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
}
/*
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
team_id *appTeam) const
@case 12 ref is valid and refers to a cyclic link
@results Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
void LaunchTester::LaunchTestF12()
{
BRoster roster;
system((string("ln -s ") + testLink1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1, false));
BMessage message;
team_id team;
CHK(roster.Launch(&linkRef, LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv, &team)
== B_LAUNCH_FAILED_NO_RESOLVE_LINK);
}
/*
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
team_id *appTeam) const
@case 13 ref is valid and refers to a link to void
@results Should return B_LAUNCH_FAILED_NO_RESOLVE_LINK.
*/
void LaunchTester::LaunchTestF13()
{
BRoster roster;
system((string("ln -s ") + testFile1 + " " + testLink1).c_str());
entry_ref linkRef(ref_for_path(testLink1, false));
BMessage message;
team_id team;
CHK(roster.Launch(&linkRef, LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv, &team)
== B_LAUNCH_FAILED_NO_RESOLVE_LINK);
}
/*
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
team_id *appTeam) const
@case 14 ref is valid and refers to an executable without signature
@results Should return B_OK and set team to the ID of the team
running the application's executable.
*/
void LaunchTester::LaunchTestF14()
{
BRoster roster;
create_app(appFile1, NULL);
entry_ref fileRef(ref_for_path(appFile1));
SimpleFileCaller3 caller(fileRef);
LaunchContext context;
team_id team;
CHK(context(caller, appType1, context.StandardMessages(),
LaunchContext::kStandardArgc, LaunchContext::kStandardArgv,
&team) == B_OK);
entry_ref ref = ref_for_team(team);
CHK(ref_for_path(appFile1) == ref);
context.WaitForMessage(team, MSG_STARTED, true);
app_info appInfo;
CHK(roster.GetRunningAppInfo(team, &appInfo) == B_OK);
CHK(!strcmp(appInfo.signature, kDefaultTestAppSignature));
context.Terminate();
int32 cookie = 0;
CHK(context.CheckNextMessage(caller, team, cookie, MSG_STARTED));
// CHK(context.CheckMainArgsMessage(caller, team, cookie, &ref));
CHK(context.CheckArgsMessage(caller, team, cookie, &ref, NULL,
LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv,
MSG_MAIN_ARGS));
// CHK(context.CheckMessageMessages(caller, team, cookie));
// CHK(context.CheckArgvMessage(caller, team, cookie, &ref));
CHK(context.CheckArgsMessage(caller, team, cookie, &ref, NULL,
LaunchContext::kStandardArgc,
LaunchContext::kStandardArgv,
MSG_ARGV_RECEIVED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_READY_TO_RUN));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_QUIT_REQUESTED));
CHK(context.CheckNextMessage(caller, team, cookie, MSG_TERMINATED));
}
Test* LaunchTester::Suite()
{
@ -2812,6 +3125,9 @@ Test* LaunchTester::Suite()
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestD8);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestD9);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestD10);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestD11);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestD12);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestD13);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestE1);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestE2);
@ -2824,6 +3140,9 @@ Test* LaunchTester::Suite()
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestE9);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestE10);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestE11);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestE12);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestE13);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestE14);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestF1);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestF2);
@ -2836,6 +3155,9 @@ Test* LaunchTester::Suite()
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestF9);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestF10);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestF11);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestF12);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestF13);
ADD_TEST4(BRoster, SuiteOfTests, LaunchTester, LaunchTestF14);
return SuiteOfTests;
}

View File

@ -55,6 +55,9 @@ class LaunchTester : public BTestCase
void LaunchTestD8();
void LaunchTestD9();
void LaunchTestD10();
void LaunchTestD11();
void LaunchTestD12();
void LaunchTestD13();
void LaunchTestE1();
void LaunchTestE2();
@ -67,6 +70,9 @@ class LaunchTester : public BTestCase
void LaunchTestE9();
void LaunchTestE10();
void LaunchTestE11();
void LaunchTestE12();
void LaunchTestE13();
void LaunchTestE14();
void LaunchTestF1();
void LaunchTestF2();
@ -79,6 +85,9 @@ class LaunchTester : public BTestCase
void LaunchTestF9();
void LaunchTestF10();
void LaunchTestF11();
void LaunchTestF12();
void LaunchTestF13();
void LaunchTestF14();
static Test* Suite();