summaryrefslogtreecommitdiff
path: root/tests/id
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
commit71cd8e3a743046573744123777061b64881bf372 (patch)
tree82522befe647f4fff186a5630cad0cad33f8ef53 /tests/id
parentc18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff)
downloadcoreutils-upstream.tar.gz
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'tests/id')
-rwxr-xr-xtests/id/context.sh9
-rwxr-xr-xtests/id/gnu-zero-uids.sh4
-rwxr-xr-xtests/id/no-context.sh2
-rwxr-xr-xtests/id/setgid.sh10
-rwxr-xr-xtests/id/smack.sh2
-rwxr-xr-xtests/id/uid.sh4
-rwxr-xr-xtests/id/zero.sh8
7 files changed, 22 insertions, 17 deletions
diff --git a/tests/id/context.sh b/tests/id/context.sh
index 4629c1a0..b1aefe73 100755
--- a/tests/id/context.sh
+++ b/tests/id/context.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Ensure that "id" outputs SELinux context only without specified user
-# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+# Copyright (C) 2008-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,7 +26,10 @@ id | grep context= >/dev/null || fail=1
# Check with specified user, no context string should be present.
# But if the current user is nameless, skip this part.
-id -nu > /dev/null \
- && id $(id -nu) | grep context= >/dev/null && fail=1
+name=$(id -nu) || { test $? -ne 1 && fail=1; }
+if test "$name"; then
+ id "$name" > id_name || fail=1
+ grep context= id_name >/dev/null && fail=1
+fi
Exit $fail
diff --git a/tests/id/gnu-zero-uids.sh b/tests/id/gnu-zero-uids.sh
index 89ca3097..c2ee6cfb 100755
--- a/tests/id/gnu-zero-uids.sh
+++ b/tests/id/gnu-zero-uids.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# On GNU, 'id' must fail for processes with zero UIDs.
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,6 +24,6 @@ require_gnu_
sush - true || skip_ "the 'sush' command does not work"
# Run 'id' with zero UIDs. It should exit with a non-zero status.
-sush - id > out && fail=1
+returns_ 1 sush - id > out || fail=1
Exit $fail
diff --git a/tests/id/no-context.sh b/tests/id/no-context.sh
index 7b699278..ff4f44d1 100755
--- a/tests/id/no-context.sh
+++ b/tests/id/no-context.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# With POSIXLY_CORRECT, id must not print context=...
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh
index 6d9d74f4..2ea249a0 100755
--- a/tests/id/setgid.sh
+++ b/tests/id/setgid.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Verify that id [-G] prints the right group when run set-GID.
-# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,14 +27,14 @@ echo $gp1 > exp || framework_failure_
# With coreutils-8.16 and earlier, id -G would print both:
# $gp1 $NON_ROOT_GID
-chroot --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / env PATH="$PATH" \
- id -G > out || fail=1
+chroot --skip-chdir --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / \
+ env PATH="$PATH" id -G > out || fail=1
compare exp out || fail=1
# With coreutils-8.22 and earlier, id would erroneously print
# groups=$NON_ROOT_GID
-chroot --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / env PATH="$PATH" \
- id > out || fail=1
+chroot --skip-chdir --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / \
+ env PATH="$PATH" id > out || fail=1
grep -F "groups=$gp1" out || { cat out; fail=1; }
Exit $fail
diff --git a/tests/id/smack.sh b/tests/id/smack.sh
index 227db3e8..10350cc2 100755
--- a/tests/id/smack.sh
+++ b/tests/id/smack.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# SMACK test for the id-command.
# Derived from tests/id/context.sh and tests/id/no-context.sh.
-# Copyright (C) 2014 Free Software Foundation, Inc.
+# Copyright (C) 2014-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/id/uid.sh b/tests/id/uid.sh
index 919ffbe2..e7a83858 100755
--- a/tests/id/uid.sh
+++ b/tests/id/uid.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Ensure that "id" works with numeric user ids
-# Copyright (C) 2013-2014 Free Software Foundation, Inc.
+# Copyright (C) 2013-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ uid=$(id -u) || fail=1
user=$(id -nu) || fail=1
# Ensure the empty user spec is discarded
-id '' && fail=1
+returns_ 1 id '' || fail=1
for mode in '' '-G' '-g'; do
id $mode $user > user_out || fail=1 # lookup name for comparison
diff --git a/tests/id/zero.sh b/tests/id/zero.sh
index c826ff43..7bee3a64 100755
--- a/tests/id/zero.sh
+++ b/tests/id/zero.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise "id --zero".
-# Copyright (C) 2013-2014 Free Software Foundation, Inc.
+# Copyright (C) 2013-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -51,8 +51,10 @@ while read u ; do
printf '\n%s: ' "id -${o}${n}[z] $u" >> out || framework_failure_
# There may be no name corresponding to an id, so don't check
# exit status when in name lookup mode
- id -${o}${n} $u >> exp || { test -z "$n" && fail=1; }
- id -${o}${n}z $u > tmp || { test -z "$n" && fail=1; }
+ id -${o}${n} $u >> exp ||
+ { test $? -ne 1 || test -z "$n" && fail=1; }
+ id -${o}${n}z $u > tmp ||
+ { test $? -ne 1 || test -z "$n" && fail=1; }
head -c-1 < tmp >> out || framework_failure_
done
done