From c61e14d3a8412cd50d98aab604e607692c844c8a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 21:33:30 +0200 Subject: Adding upstream version 2.40. Signed-off-by: Daniel Baumann --- tests/ts/misc/lsclocks | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 tests/ts/misc/lsclocks (limited to 'tests/ts/misc/lsclocks') diff --git a/tests/ts/misc/lsclocks b/tests/ts/misc/lsclocks new file mode 100755 index 0000000..71fefaa --- /dev/null +++ b/tests/ts/misc/lsclocks @@ -0,0 +1,70 @@ +#!/bin/bash + +# Copyright (C) 2023 Thomas Weißschuh +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="lsclocks" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_LSCLOCKS" +ts_check_prog sed + +mask_timestamps() { + sed 's/[0-9]\+\.[0-9]\+/X.X/g' +} + +NO_DISCOVER="--no-discover-dynamic --no-discover-rtc" + +ts_init_subtest basic + +"$TS_CMD_LSCLOCKS" $NO_DISCOVER -o TYPE,ID,CLOCK,NAME > "$TS_OUTPUT" 2>> "$TS_ERRLOG" + +ts_finalize_subtest + +ts_init_subtest time + +"$TS_CMD_LSCLOCKS" --time monotonic | mask_timestamps > "$TS_OUTPUT" 2>> "$TS_ERRLOG" + +ts_finalize_subtest + +ts_init_subtest dynamic + +if [ -c /dev/ptp0 ] && [ -r /dev/ptp0 ]; then + "$TS_CMD_LSCLOCKS" $NO_DISCOVER --dynamic-clock /dev/ptp0 --output TYPE,ID,CLOCK,NAME \ + | tail -1 > "$TS_OUTPUT" 2>> "$TS_ERRLOG" + ts_finalize_subtest +else + ts_skip_subtest "/dev/ptp0 not usable" +fi + +ts_init_subtest rtc + +if [ -c /dev/rtc0 ] && [ -r /dev/rtc0 ]; then + "$TS_CMD_LSCLOCKS" $NO_DISCOVER --rtc /dev/rtc0 --output TYPE,ID,CLOCK,NAME \ + | tail -1 > "$TS_OUTPUT" 2>> "$TS_ERRLOG" + ts_finalize_subtest +else + ts_skip_subtest "/dev/rtc0 not usable" +fi + +ts_init_subtest cpu + +"$TS_CMD_LSCLOCKS" --cpu 1 --output TYPE,ID,NAME | tail -1 > "$TS_OUTPUT" 2>> "$TS_ERRLOG" + +ts_finalize_subtest + +ts_finalize -- cgit v1.2.3