~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/cgroup/test_cpuset_v1_base.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 #
  4 # Basc test for cpuset v1 interfaces write/read
  5 #
  6 
  7 skip_test() {
  8         echo "$1"
  9         echo "Test SKIPPED"
 10         exit 4 # ksft_skip
 11 }
 12 
 13 write_test() {
 14         dir=$1
 15         interface=$2
 16         value=$3
 17         original=$(cat $dir/$interface)
 18         echo "testing $interface $value"
 19         echo $value > $dir/$interface
 20         new=$(cat $dir/$interface)
 21         [[ $value -ne $(cat $dir/$interface) ]] && {
 22                 echo "$interface write $value failed: new:$new"
 23                 exit 1
 24         }
 25 }
 26 
 27 [[ $(id -u) -eq 0 ]] || skip_test "Test must be run as root!"
 28 
 29 # Find cpuset v1 mount point
 30 CPUSET=$(mount -t cgroup | grep cpuset | head -1 | awk '{print $3}')
 31 [[ -n "$CPUSET" ]] || skip_test "cpuset v1 mount point not found!"
 32 
 33 #
 34 # Create a test cpuset, read write test
 35 #
 36 TDIR=test$$
 37 [[ -d $CPUSET/$TDIR ]] || mkdir $CPUSET/$TDIR
 38 
 39 ITF_MATRIX=(
 40         #interface                      value           expect  root_only
 41         'cpuset.cpus                    0-1             0-1     0'
 42         'cpuset.mem_exclusive           1               1       0'
 43         'cpuset.mem_exclusive           0               0       0'
 44         'cpuset.mem_hardwall            1               1       0'
 45         'cpuset.mem_hardwall            0               0       0'
 46         'cpuset.memory_migrate          1               1       0'
 47         'cpuset.memory_migrate          0               0       0'
 48         'cpuset.memory_spread_page      1               1       0'
 49         'cpuset.memory_spread_page      0               0       0'
 50         'cpuset.memory_spread_slab      1               1       0'
 51         'cpuset.memory_spread_slab      0               0       0'
 52         'cpuset.mems                    0               0       0'
 53         'cpuset.sched_load_balance      1               1       0'
 54         'cpuset.sched_load_balance      0               0       0'
 55         'cpuset.sched_relax_domain_level        2       2       0'
 56         'cpuset.memory_pressure_enabled 1               1       1'
 57         'cpuset.memory_pressure_enabled 0               0       1'
 58 )
 59 
 60 run_test()
 61 {
 62         cnt="${ITF_MATRIX[@]}"
 63         for i in "${ITF_MATRIX[@]}" ; do
 64                 args=($i)
 65                 root_only=${args[3]}
 66                 [[ $root_only -eq 1 ]] && {
 67                         write_test "$CPUSET" "${args[0]}" "${args[1]}" "${args[2]}"
 68                         continue
 69                 }
 70                 write_test "$CPUSET/$TDIR" "${args[0]}" "${args[1]}" "${args[2]}"
 71         done
 72 }
 73 
 74 run_test
 75 rmdir $CPUSET/$TDIR
 76 echo "Test PASSED"
 77 exit 0

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php