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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/ptp/phc.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 ] ~

Diff markup

Differences between /tools/testing/selftests/ptp/phc.sh (Architecture ppc) and /tools/testing/selftests/ptp/phc.sh (Architecture sparc)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3                                                     3 
  4 ALL_TESTS="                                         4 ALL_TESTS="
  5         settime                                     5         settime
  6         adjtime                                     6         adjtime
  7         adjfreq                                     7         adjfreq
  8 "                                                   8 "
  9 DEV=$1                                              9 DEV=$1
 10                                                    10 
 11 ##############################################     11 ##############################################################################
 12 # Sanity checks                                    12 # Sanity checks
 13                                                    13 
 14 if [[ "$(id -u)" -ne 0 ]]; then                    14 if [[ "$(id -u)" -ne 0 ]]; then
 15         echo "SKIP: need root privileges"          15         echo "SKIP: need root privileges"
 16         exit 0                                     16         exit 0
 17 fi                                                 17 fi
 18                                                    18 
 19 if [[ "$DEV" == "" ]]; then                        19 if [[ "$DEV" == "" ]]; then
 20         echo "SKIP: PTP device not provided"       20         echo "SKIP: PTP device not provided"
 21         exit 0                                     21         exit 0
 22 fi                                                 22 fi
 23                                                    23 
 24 require_command()                                  24 require_command()
 25 {                                                  25 {
 26         local cmd=$1; shift                        26         local cmd=$1; shift
 27                                                    27 
 28         if [[ ! -x "$(command -v "$cmd")" ]];      28         if [[ ! -x "$(command -v "$cmd")" ]]; then
 29                 echo "SKIP: $cmd not installed     29                 echo "SKIP: $cmd not installed"
 30                 exit 1                             30                 exit 1
 31         fi                                         31         fi
 32 }                                                  32 }
 33                                                    33 
 34 phc_sanity()                                       34 phc_sanity()
 35 {                                                  35 {
 36         phc_ctl $DEV get &> /dev/null              36         phc_ctl $DEV get &> /dev/null
 37                                                    37 
 38         if [ $? != 0 ]; then                       38         if [ $? != 0 ]; then
 39                 echo "SKIP: unknown clock $DEV     39                 echo "SKIP: unknown clock $DEV: No such device"
 40                 exit 1                             40                 exit 1
 41         fi                                         41         fi
 42 }                                                  42 }
 43                                                    43 
 44 require_command phc_ctl                            44 require_command phc_ctl
 45 phc_sanity                                         45 phc_sanity
 46                                                    46 
 47 ##############################################     47 ##############################################################################
 48 # Helpers                                          48 # Helpers
 49                                                    49 
 50 # Exit status to return at the end. Set in cas     50 # Exit status to return at the end. Set in case one of the tests fails.
 51 EXIT_STATUS=0                                      51 EXIT_STATUS=0
 52 # Per-test return value. Clear at the beginnin     52 # Per-test return value. Clear at the beginning of each test.
 53 RET=0                                              53 RET=0
 54                                                    54 
 55 check_err()                                        55 check_err()
 56 {                                                  56 {
 57         local err=$1                               57         local err=$1
 58                                                    58 
 59         if [[ $RET -eq 0 && $err -ne 0 ]]; the     59         if [[ $RET -eq 0 && $err -ne 0 ]]; then
 60                 RET=$err                           60                 RET=$err
 61         fi                                         61         fi
 62 }                                                  62 }
 63                                                    63 
 64 log_test()                                         64 log_test()
 65 {                                                  65 {
 66         local test_name=$1                         66         local test_name=$1
 67                                                    67 
 68         if [[ $RET -ne 0 ]]; then                  68         if [[ $RET -ne 0 ]]; then
 69                 EXIT_STATUS=1                      69                 EXIT_STATUS=1
 70                 printf "TEST: %-60s  [FAIL]\n"     70                 printf "TEST: %-60s  [FAIL]\n" "$test_name"
 71                 return 1                           71                 return 1
 72         fi                                         72         fi
 73                                                    73 
 74         printf "TEST: %-60s  [ OK ]\n" "$test_     74         printf "TEST: %-60s  [ OK ]\n" "$test_name"
 75         return 0                                   75         return 0
 76 }                                                  76 }
 77                                                    77 
 78 tests_run()                                        78 tests_run()
 79 {                                                  79 {
 80         local current_test                         80         local current_test
 81                                                    81 
 82         for current_test in ${TESTS:-$ALL_TEST     82         for current_test in ${TESTS:-$ALL_TESTS}; do
 83                 $current_test                      83                 $current_test
 84         done                                       84         done
 85 }                                                  85 }
 86                                                    86 
 87 ##############################################     87 ##############################################################################
 88 # Tests                                            88 # Tests
 89                                                    89 
 90 settime_do()                                       90 settime_do()
 91 {                                                  91 {
 92         local res                                  92         local res
 93                                                    93 
 94         res=$(phc_ctl $DEV set 0 wait 120.5 ge     94         res=$(phc_ctl $DEV set 0 wait 120.5 get 2> /dev/null \
 95                 | awk '/clock time is/{print $     95                 | awk '/clock time is/{print $5}' \
 96                 | awk -F. '{print $1}')            96                 | awk -F. '{print $1}')
 97                                                    97 
 98         (( res == 120 ))                           98         (( res == 120 ))
 99 }                                                  99 }
100                                                   100 
101 adjtime_do()                                      101 adjtime_do()
102 {                                                 102 {
103         local res                                 103         local res
104                                                   104 
105         res=$(phc_ctl $DEV set 0 adj 10 get 2>    105         res=$(phc_ctl $DEV set 0 adj 10 get 2> /dev/null \
106                 | awk '/clock time is/{print $    106                 | awk '/clock time is/{print $5}' \
107                 | awk -F. '{print $1}')           107                 | awk -F. '{print $1}')
108                                                   108 
109         (( res == 10 ))                           109         (( res == 10 ))
110 }                                                 110 }
111                                                   111 
112 adjfreq_do()                                      112 adjfreq_do()
113 {                                                 113 {
114         local res                                 114         local res
115                                                   115 
116         # Set the clock to be 1% faster           116         # Set the clock to be 1% faster
117         res=$(phc_ctl $DEV freq 10000000 set 0    117         res=$(phc_ctl $DEV freq 10000000 set 0 wait 100.5 get 2> /dev/null \
118                 | awk '/clock time is/{print $    118                 | awk '/clock time is/{print $5}' \
119                 | awk -F. '{print $1}')           119                 | awk -F. '{print $1}')
120                                                   120 
121         (( res == 101 ))                          121         (( res == 101 ))
122 }                                                 122 }
123                                                   123 
124 ##############################################    124 ##############################################################################
125                                                   125 
126 cleanup()                                         126 cleanup()
127 {                                                 127 {
128         phc_ctl $DEV freq 0.0 &> /dev/null        128         phc_ctl $DEV freq 0.0 &> /dev/null
129         phc_ctl $DEV set &> /dev/null             129         phc_ctl $DEV set &> /dev/null
130 }                                                 130 }
131                                                   131 
132 settime()                                         132 settime()
133 {                                                 133 {
134         RET=0                                     134         RET=0
135                                                   135 
136         settime_do                                136         settime_do
137         check_err $?                              137         check_err $?
138         log_test "settime"                        138         log_test "settime"
139         cleanup                                   139         cleanup
140 }                                                 140 }
141                                                   141 
142 adjtime()                                         142 adjtime()
143 {                                                 143 {
144         RET=0                                     144         RET=0
145                                                   145 
146         adjtime_do                                146         adjtime_do
147         check_err $?                              147         check_err $?
148         log_test "adjtime"                        148         log_test "adjtime"
149         cleanup                                   149         cleanup
150 }                                                 150 }
151                                                   151 
152 adjfreq()                                         152 adjfreq()
153 {                                                 153 {
154         RET=0                                     154         RET=0
155                                                   155 
156         adjfreq_do                                156         adjfreq_do
157         check_err $?                              157         check_err $?
158         log_test "adjfreq"                        158         log_test "adjfreq"
159         cleanup                                   159         cleanup
160 }                                                 160 }
161                                                   161 
162 trap cleanup EXIT                                 162 trap cleanup EXIT
163                                                   163 
164 tests_run                                         164 tests_run
165                                                   165 
166 exit $EXIT_STATUS                                 166 exit $EXIT_STATUS
                                                      

~ [ 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