1#!/usr/bin/env bash 2# SPDX-License-Identifier: LGPL-2.1-or-later 3set -eux 4set -o pipefail 5 6: >/failed 7 8# Reset host date to current time, 3 days in the past. 9date -s "-3 days" 10 11# Run a timer for every 15 minutes. 12systemd-run --unit test-timer --on-calendar "*:0/15:0" true 13 14next_elapsed=$(systemctl show test-timer.timer -p NextElapseUSecRealtime --value) 15next_elapsed=$(date -d "${next_elapsed}" +%s) 16now=$(date +%s) 17time_delta=$((next_elapsed - now)) 18 19# Check that the timer will elapse in less than 20 minutes. 20((0 < time_delta && time_delta < 1200)) || { 21 echo 'Timer elapse outside of the expected 20 minute window.' 22 echo " next_elapsed=${next_elapsed}" 23 echo " now=${now}" 24 echo " time_delta=${time_delta}" 25 echo '' 26} >>/failed 27 28if test ! -s /failed ; then 29 rm -f /failed 30 touch /testok 31fi 32