diff options
Diffstat (limited to 'test/simulation/test.common')
-rw-r--r-- | test/simulation/test.common | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/test/simulation/test.common b/test/simulation/test.common index c5758c6..951a794 100644 --- a/test/simulation/test.common +++ b/test/simulation/test.common @@ -84,6 +84,8 @@ done test_start() { rm -f tmp/* echo "Testing $@:" + + check_config_h 'FEAT_NTP 1' || test_skip } test_pass() { @@ -211,6 +213,12 @@ get_chronyd_conf() { fi } +# Check if chrony was built with specified option in config.h +check_config_h() { + local pattern=$1 + grep -q "^#define $pattern" ../../config.h +} + # Check if the clock was well synchronized check_sync() { local i sync_time max_time_error max_freq_error ret=0 @@ -337,7 +345,7 @@ check_chronyc_output() { return $ret } -# Check the number of messages matching a matter in the client logs +# Check the number of messages matching a pattern in the client logs check_log_messages() { local i count ret=0 pattern=$1 min=$2 max=$3 @@ -355,6 +363,25 @@ check_log_messages() { return $ret } +# Check the number of messages matching a pattern in a specified file +check_file_messages() { + local i count ret=0 pattern=$1 min=$2 max=$3 + shift 3 + + test_message 2 1 "checking number of messages \"$pattern\":" + + for i; do + count=$(grep "$pattern" tmp/$i | wc -l) + test_message 3 0 "$i: $count" + + [ "$min" -le "$count" ] && [ "$count" -le "$max" ] && \ + test_ok || test_bad + [ $? -eq 0 ] || ret=1 + done + + return $ret +} + # Check if only NTP port (123) was used check_packet_port() { local i ret=0 port=123 |