2 # SPDX-License-Identifier: GPL-2.0
11 ##############################################################################
14 if [[ "$(id -u)" -ne 0 ]]; then
15 echo "SKIP: need root privileges"
19 if [[ "$DEV" == "" ]]; then
20 echo "SKIP: PTP device not provided"
28 if [[ ! -x "$(command -v "$cmd")" ]]; then
29 echo "SKIP: $cmd not installed"
36 phc_ctl
$DEV get
&> /dev
/null
39 echo "SKIP: unknown clock $DEV: No such device"
44 require_command phc_ctl
47 ##############################################################################
50 # Exit status to return at the end. Set in case one of the tests fails.
52 # Per-test return value. Clear at the beginning of each test.
59 if [[ $RET -eq 0 && $err -ne 0 ]]; then
68 if [[ $RET -ne 0 ]]; then
70 printf "TEST: %-60s [FAIL]\n" "$test_name"
74 printf "TEST: %-60s [ OK ]\n" "$test_name"
82 for current_test
in ${TESTS:-$ALL_TESTS}; do
87 ##############################################################################
94 res
=$
(phc_ctl
$DEV set 0 wait 120.5 get
2> /dev
/null \
95 |
awk '/clock time is/{print $5}' \
96 |
awk -F.
'{print $1}')
105 res
=$
(phc_ctl
$DEV set 0 adj
10 get
2> /dev
/null \
106 |
awk '/clock time is/{print $5}' \
107 |
awk -F.
'{print $1}')
116 # Set the clock to be 1% faster
117 res
=$
(phc_ctl
$DEV freq
10000000 set 0 wait 100.5 get
2> /dev
/null \
118 |
awk '/clock time is/{print $5}' \
119 |
awk -F.
'{print $1}')
124 ##############################################################################
128 phc_ctl
$DEV freq
0.0 &> /dev
/null
129 phc_ctl
$DEV set &> /dev
/null