drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / tools / testing / selftests / ftrace / test.d / 00basic / test_ownership.tc
blobe71cc3ad0bdf9a98e08d41d6692f4a2cc2d56aaf
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # description: Test file and directory ownership changes for eventfs
4 # requires: "[gid=<gid>]":README
6 original_group=`stat -c "%g" .`
7 original_owner=`stat -c "%u" .`
9 local mount_point=$(get_mount_point)
11 mount_options=$(get_mnt_options "$mount_point")
13 # find another owner and group that is not the original
14 other_group=`tac /etc/group | grep -v ":$original_group:" | head -1 | cut -d: -f3`
15 other_owner=`tac /etc/passwd | grep -v ":$original_owner:" | head -1 | cut -d: -f3`
17 # Remove any group ownership already
18 new_options=`echo "$mount_options" | sed -e "s/gid=[0-9]*/gid=$other_group/"`
20 if [ "$new_options" = "$mount_options" ]; then
21 new_options="$mount_options,gid=$other_group"
22 mount_options="$mount_options,gid=$original_group"
25 canary="events/timer events/timer/timer_cancel events/timer/timer_cancel/format"
27 test() {
28 file=$1
29 test_group=$2
31 owner=`stat -c "%u" $file`
32 group=`stat -c "%g" $file`
34 echo "testing $file $owner=$original_owner and $group=$test_group"
35 if [ $owner -ne $original_owner ]; then
36 exit_fail
38 if [ $group -ne $test_group ]; then
39 exit_fail
42 # Note, the remount does not update ownership so test going to and from owner
43 echo "test owner $file to $other_owner"
44 chown $other_owner $file
45 owner=`stat -c "%u" $file`
46 if [ $owner -ne $other_owner ]; then
47 exit_fail
50 chown $original_owner $file
51 owner=`stat -c "%u" $file`
52 if [ $owner -ne $original_owner ]; then
53 exit_fail
58 run_tests() {
59 for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
60 test "$d" $other_group
61 done
63 chgrp $original_group events
64 test "events" $original_group
65 for d in "." "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
66 test "$d" $other_group
67 done
69 chgrp $original_group events/sched
70 test "events/sched" $original_group
71 for d in "." "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
72 test "$d" $other_group
73 done
75 chgrp $original_group events/sched/sched_switch
76 test "events/sched/sched_switch" $original_group
77 for d in "." "events/sched/sched_switch/enable" $canary; do
78 test "$d" $other_group
79 done
81 chgrp $original_group events/sched/sched_switch/enable
82 test "events/sched/sched_switch/enable" $original_group
83 for d in "." $canary; do
84 test "$d" $other_group
85 done
88 # Run the tests twice as leftovers can cause issues
89 for loop in 1 2 ; do
91 echo "Running iteration $loop"
93 mount -o remount,"$new_options" .
95 run_tests
97 mount -o remount,"$mount_options" .
99 for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
100 test "$d" $original_group
101 done
103 # check instances as well
105 chgrp $other_group instances
107 instance="$(mktemp -u test-XXXXXX)"
109 mkdir instances/$instance
111 cd instances/$instance
113 run_tests
115 cd ../..
117 rmdir instances/$instance
119 chgrp $original_group instances
120 done
122 exit 0