I see two problems in your code:
1) The "hdiutil" documentation states:
-stdinpass
read a null-terminated passphrase from standard input. ... Beware that the password will contain any newlines before the NULL.
But "/bin/echo" always appends a newline to the output. So your password is set to "test\n".
2) If you read the password from the pipe for logging, the data is "gone" and isn't read by the backup task anymore. (EDIT: This has also been posted by Ramy Al Zuhoury while I was writing this answer!)
I would not use a "/bin/echo" task to pipe the password into the backup task. You can better write the necessary data directly to the pipe:
NSString *passwd = @"test\0\n"; // password + NULL character + newline
NSData *passwdData = [passwd dataUsingEncoding:NSUTF8StringEncoding];
[[pipe fileHandleForWriting] writeData:passwdData];
[[pipe fileHandleForWriting] closeFile];
(I am not sure if "hdiutil" really expects a newline after the NULL character. You can also try it without the newline.)