Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAutomation : Failed to authorize rights with status: -60007

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 ?

like image 796
Legolas Avatar asked Jan 17 '23 04:01

Legolas


1 Answers

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
like image 145
Alexander Avatar answered Jan 30 '23 09:01

Alexander