build: ensure sys/select.h is included
[coreutils.git] / tests / id / uid.sh
blob793a1761470404a67534a9fa67d54a12924a24f9
1 #!/bin/sh
2 # Ensure that "id" works with numeric user ids
3 # Copyright (C) 2013-2019 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
18 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
19 print_ver_ id
21 uid=$(id -u) || fail=1
22 user=$(id -nu) || fail=1
24 # Ensure the empty user spec is discarded
25 returns_ 1 id '' || fail=1
27 # Ensure we don't exit early, and process all users
28 id $user > user_out || fail=1
29 returns_ 1 id '' $user >multi_user_out || fail=1
30 compare user_out multi_user_out || fail=1
32 for mode in '' '-G' '-g'; do
33 id $mode $user > user_out || fail=1 # lookup name for comparison
35 id $mode $uid > uid_out || fail=1 # lookup name "$uid" before id "$uid"
36 compare user_out uid_out || fail=1
38 id $mode +$uid > uid_out || fail=1 # lookup only id "$uid"
39 compare user_out uid_out || fail=1
40 done
42 Exit $fail