For Programmers: Free Programming Magazines  


Home > Archive > Extreme Programming > August 2006 > OCUnit (OS X): Injecting a bundle into an app with spawned processes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author OCUnit (OS X): Injecting a bundle into an app with spawned processes
imjwilkinson@gmail.com

2006-07-28, 6:58 pm

If this question is better directed to another group, please let me
know. I'm new here :-)

I'm using the SenTest unit test tools on Mac OSX 10.4.7 with XCode 2.3.

I'm implementing unit tests to test the UI on a large project. I'm
using the method of injecting the test bundle into the application.

Unfortunately, the test script craps out with the following errors:

/bin/sh -c
/build/intermediate/MyProg.build/Debug/TestUI.build/Script-3C3B68DE0A755C2200BC53C4.sh
2006-07-25 12:15:04.095 WorkServer[25120] CFLog (21): Error loading
/build/Debug/TestUI.octest/Contents/MacOS/TestUI: error code 4, error
number 0 (Library not loaded:
@executable_path/../Frameworks/LicenseRegistration.framework/Versions/A/LicenseRegistration
Referenced from: /build/Debug/TestUI.octest/Contents/MacOS/TestUI
Reason: image not found)
DevToolsBundleInjection: Error loading bundle
'/build/Debug/TestUI.octest'
2006-07-25 12:15:04.096 WorkServer[25121] CFLog (21): Error loading
/build/Debug/TestUI.octest/Contents/MacOS/TestUI: error code 4, error
number 0 (Library not loaded:
@executable_path/../Frameworks/LicenseRegistration.framework/Versions/A/LicenseRegistration
Referenced from: /build/Debug/TestUI.octest/Contents/MacOS/TestUI
Reason: image not found)
DevToolsBundleInjection: Error loading bundle
'/build/Debug/TestUI.octest'
2006-07-25 12:15:06.405 FooBarProgram[25119] +[NSATSGlyphGenerator
initialize] invocation. The class is deprecated.
2006-07-25 12:15:06.477 FooBarProgram[25119] *** NSRunLoop ignoring
exception '*** unknown return type encoding '('' that raised during
posting of delayed perform with target acc09794 and selector
'runTests:'
2006-07-25 12:15:30.094 FooBarProgram[25119] Exception raised during
posting of notification. Ignored. exception: The NSManagedObject with
ID:0xb3d2870 <x-coredata:///Disc/tBBF9DF98-5506-49BE-AE4C-B41C8BDDB3D7>
has been invalidated.

My understanding is because the main app launches another process
'WorkServer', the test script not only tries to inject the test bundle
into the main process, but into it's child processes too. Does anyone
know how to get around this?

Any help is appreciated.

Regards,
Ian Wilkinson

Chris Hanson

2006-08-04, 6:58 pm

On 2006-07-28 10:36:23 -0700, imjwilkinson@gmail.com said:

> If this question is better directed to another group, please let me
> know. I'm new here :-)


Your best bet for Mac OS X programming help is either
<news:comp.sys.mac.programmer.help> or the various mailing lists Apple
runs at <http://www.lists.apple.com/>.

> My understanding is because the main app launches another process
> 'WorkServer', the test script not only tries to inject the test bundle
> into the main process, but into it's child processes too. Does anyone
> know how to get around this?


How are the child processes launched? If they're launched via some
form of fork()/execve() combination that doesn't pass a specific set of
environment variables, the launched child processes will inherit the
environmet of the launcher. This includes the environment variables
that tell DYLD to inject the testing bundle into the process.

Also, if you use the NSTask class to represent and launch your child
processes, and don't adjust the task's environment variables prior to
launching them, they will inherit their environment from the parent
process. In other words, instead of:

NSTask *myTask;

myTask = [NSTask launchedTaskWithLaunchPath:pathToTool
arguments:[NSArray
arrayWithObject:pathToTool]];
[myTask retain];

You can use:

myTask = [[NSTask alloc] init];
[myTask setLaunchPath:pathToTool];
[myTask setArguments:[NSArray arrayWithObject:pathToTool]];
[myTask setEnvironment:[NSDictionary dictionary]];
[myTask launch];

Let me know if this helps.

-- Chris

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com