Mercurial > hg > toybox
annotate tests/groupadd.test @ 1499:319e79bab052 draft
Separate more commands so single.sh can build them standalone.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 26 Sep 2014 18:42:23 -0500 |
parents | 8700cbe1cb29 |
children |
rev | line source |
---|---|
1377
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
1 #!/bin/bash |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
2 # Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com> |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2013 Robin Mittal <robinmittal.it@gmail.com> |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
4 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
5 [ -f testing.sh ] && . testing.sh |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
6 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
7 # 70 characters long string; hereafter, we will use it as per our need. |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
8 _s70="abcdefghijklmnopqrstuvwxyz123456789abcdefghijklmnopqrstuvwxyz123456789" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
9 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
10 echo "# usage: addgroup [-g GID] [USER] GROUP |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
11 # Add a group or add a user to a group." |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
12 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
13 # Redirecting all output to /dev/null for grep and delgroup |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
14 arg="&>/dev/null" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
15 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
16 #testing "name" "command" "result" "infile" "stdin" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
17 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
18 testing "groupadd group_name (text)" "groupadd toyTestGroup && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
19 grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
20 echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
21 testing "groupadd group_name (alphanumeric)" "groupadd toy1Test2Group3 && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
22 grep '^toy1Test2Group3:' /etc/group $arg && groupdel toy1Test2Group3 $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
23 echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
24 testing "groupadd group_name (numeric)" "groupadd 987654321 && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
25 grep '^987654321:' /etc/group $arg && groupdel 987654321 $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
26 echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
27 testing "groupadd group_name (with ./-)" "groupadd toy.1Test-2Group.3 && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
28 grep '^toy.1Test-2Group.3:' /etc/group $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
29 groupdel toy.1Test-2Group.3 $arg && echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
30 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
31 _s210=`echo $_s70$_s70$_s70` |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
32 testing "groupadd group_name (long string)" "groupadd $_s210 && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
33 grep '^$_s210:' /etc/group $arg && groupdel $_s210 $arg && echo 'yes'" \ |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
34 "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
35 testing "groupadd group_name with group_id" "groupadd -g 49999 toyTestGroup && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
36 grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
37 echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
38 testing "groupadd group_name with group_id (system_group)" \ |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
39 "groupadd -g 49999 -S toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
40 groupdel toyTestGroup $arg && echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
41 testing "groupadd group_name (system_group)" "groupadd -S toyTestGroup && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
42 grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
43 echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
44 testing "groupadd group_name (add/del user)" "groupadd toyTestGroup && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
45 grep '^toyTestGroup:' /etc/group $arg && groupadd $USER toyTestGroup && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
46 grep '^toyTestGroup:.*:.*:.*$USER.*' /etc/group $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
47 groupdel $USER toyTestGroup $arg || groupdel toyTestGroup && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
48 grep '^toyTestGroup:' /etc/group $arg || echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
49 |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
50 echo "Testing to add single group multiple times after removing it..." |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
51 for each in {01..20} |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
52 do |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
53 testing "groupadd group_name ($each)" "groupadd toyTestGroup && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
54 grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
55 echo 'yes'" "yes\n" "" "" |
7a2aec0876fe
I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff
changeset
|
56 done |