4

So I am running UIAutomation on command line with

$ instruments -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate 
<path-to-your-app>/<appname>.app/ -e UIASCRIPT <path-to-your-js-test-file> -e 
UIARESULTSPATH <path-to-results-folder>

This works fine and the simulator opens up, and the app runs, but gets stuck with this error.

Failed to authorize rights (0x2) with status: -60007

I believe it has something to do with the permissions.

How do I go about this ?

Legolas
  • 12,145
  • 12
  • 79
  • 132
  • Does this help? http://stackoverflow.com/questions/9476131/is-there-a-way-to-remove-the-authorization-prompt-from-command-line-instances-of – S.P. Jul 06 '12 at 21:50
  • Have you ever solved this issue? Unfortunately I am currently running into the same one... – Alexander Jul 10 '12 at 11:43
  • @Alexander I think I fixed it. I will post an answer. – Legolas Jul 10 '12 at 16:36
  • ah okay, do you have another solution than the one I mentioned in this question: http://stackoverflow.com/a/11416025/925622 – Alexander Jul 10 '12 at 17:09
  • @Alexander I fixed it by making changes with `sudo visudo` and changing privilages for instruments. But I reverted and took your solution, its BETTER. Please add the answer to this question for other folks :) Thanks ! – Legolas Jul 10 '12 at 17:59
  • @S.P. No. Alexander's solution worked only. – Display Name Sep 10 '13 at 08:28

2 Answers2

7

That's the answer I posted at Instruments via command line - jenkins

And here is even a blog post about Xcode command line authorization prompt error

I will explain it again here:

What I did was the following:

  • Mark jenkins user as admin (unfortunately it seems that there is no other way atm)
  • Go to /etc/authorization
  • search for key system.privilige.taskport
  • change value of allow-root to true

    <key>system.privilege.taskport</key>
    <dict>
        <key>allow-root</key>
        <false/> // change to -> <true>
        <key>class</key>
        <string>user</string>
        <key>comment</key>
        <string>Used by task_for_pid(...).
        ...
    </dict>
    

Now I am being able to use jenkins to run my UIAutomation-Tests via Command Line Script

EDIT

To make jenkins recognize a successfull build, I have not a perfect solution but the following workaround:

...
echo "Run instruments simulator"

instruments -t "$ORDER_AUTOMATION_TEST_TEMPLATE_PATH" "$FILE_DEBUG_APP" -e UIASCRIPT "$ORDER_AUTOMATION_TESTSCRIPT_PATH" -e UIARESULTSPATH "$DIRECTORY_INSTRUMENTS_RESULT"

returnCode=0

if test -a "Run 1/Assertion failed.png"; then
echo "failed"
returnCode=1
else
echo "passed"
returnCode=0
fi

rm -fR "Run 1"

rm -fR "instrumentscli0.trace"

echo "Removing app dir"

echo "$FILE_APPLICATIONS"

rm -fR "$FILE_APPLICATIONS"

echo $returnCode

exit $returnCode

EDIT 2 Better way to check if automation test did run successfully:

# cleanup the tracefiles produced from instruments
rm -rf *.trace

##kill simulator afterwards
killall "iPhone Simulator"

##check if failures occured
# fail script if any failures have been generated
if [ `grep "<string>Error</string>" "$WORKSPACE/Automation Results/Run 1/Automation Results.plist" | wc -l` -gt 0 ]; then
    echo 'Build Failed'
    exit -1
else
    echo 'Build Passed'
    exit 0
fi
Community
  • 1
  • 1
Alexander
  • 7,178
  • 8
  • 45
  • 75
2

This can help on Mavericks and Yosemite: (based on Alexander's answer)

$ security authorizationdb write system.privilege.taskport allow

stefreak
  • 1,460
  • 12
  • 30