Mercurial > hg > toybox
annotate tests/chown.test @ 1656:88e6a100490e draft
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
new test:
and here's the patch to fix "owner:" ":group" and the ":" special case:
author | Elliott Hughes <enh@google.com> |
---|---|
date | Wed, 14 Jan 2015 03:43:49 -0600 |
parents | |
children |
rev | line source |
---|---|
1656
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
1 #!/bin/bash |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
2 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
3 [ -f testing.sh ] && . testing.sh |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
4 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
5 if [ "$(id -u)" -ne 0 ] |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
6 then |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
7 echo "SKIPPED: chown (not root)" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
8 continue 2>/dev/null |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
9 exit |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
10 fi |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
11 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
12 # We chown between user "root" and the last user in /etc/passwd, |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
13 # and group "root" and the last group in /etc/group. |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
14 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
15 USR="$(sed -n '$s/:.*//p' /etc/passwd)" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
16 GRP="$(sed -n '$s/:.*//p' /etc/group)" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
17 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
18 # Set up a little testing hierarchy |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
19 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
20 rm -rf testdir && |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
21 mkdir testdir && |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
22 touch testdir/file |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
23 F=testdir/file |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
24 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
25 # Wrapper to reset groups and return results |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
26 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
27 OUT="&& echo \$(ls -l testdir/file | awk '{print \$3,\$4}')" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
28 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
29 #testing "name" "command" "result" "infile" "stdin" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
30 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
31 # Basic smoketest |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
32 testing "chown initial" "chown root:root $F $OUT" "root root\n" "" "" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
33 testing "chown usr:grp" "chown $USR:$GRP $F $OUT" "$USR $GRP\n" "" "" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
34 testing "chown root" "chown root $F $OUT" "root $GRP\n" "" "" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
35 # TODO: can we test "owner:"? |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
36 testing "chown :grp" "chown root:root $F && chown :$GRP $F $OUT" \ |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
37 "root $GRP\n" "" "" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
38 testing "chown :" "chown $USR:$GRP $F && chown : $F $OUT" \ |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
39 "$USR $GRP\n" "" "" |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
40 |
88e6a100490e
i found a few problems while manually smoke testing toybox chown versus toolbox (NetBSD) chown...
Elliott Hughes <enh@google.com>
parents:
diff
changeset
|
41 rm -rf testdir |