From fcac2a821c9b382ee265b9f1ed8a251f47c6892f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 25 Jun 2019 14:01:07 -0700 Subject: Make chgrp and chown tests work on Android. There's no /etc/passwd and /etc/group, but there are enough users and groups that we can test with. ("bin" and "daemon" were added for LTP; "shell" is what you get with `adb shell`.) --- tests/chown.test | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'tests/chown.test') diff --git a/tests/chown.test b/tests/chown.test index 56eed81e..20be541a 100755 --- a/tests/chown.test +++ b/tests/chown.test @@ -9,11 +9,16 @@ then exit fi -# We chown between user "root" and the last user in /etc/passwd, -# and group "root" and the last group in /etc/group. - -USR="$(sed -n '$s/:.*//p' /etc/passwd)" -GRP="$(sed -n '$s/:.*//p' /etc/group)" +if [ -f /etc/group ]; then + # We chown between user "root" and the last user in /etc/passwd, + # and group "root" and the last group in /etc/group. + USR="$(sed -n '$s/:.*//p' /etc/passwd)" + GRP="$(sed -n '$s/:.*//p' /etc/group)" +else + # Or we assume we're on Android... + USR="shell" + GRP="daemon" +fi # Set up a little testing hierarchy @@ -24,7 +29,7 @@ F=testdir/file # Wrapper to reset groups and return results -OUT="&& echo \$(ls -l testdir/file | awk '{print \$3,\$4}')" +OUT="&& stat --format '%U %G' $F" #testing "name" "command" "result" "infile" "stdin" -- cgit v1.2.3