summaryrefslogtreecommitdiff
path: root/test/simulation
diff options
context:
space:
mode:
authorVincent Blut <vincent.debian@free.fr>2015-09-26 17:05:50 +0200
committerVincent Blut <vincent.debian@free.fr>2015-09-26 17:05:50 +0200
commit55697823c8a320c595ad93947965f29f94c5a1da (patch)
tree55efda509aef466d40b907913c7a435feb90ace9 /test/simulation
parent9576b683a04f8a0e691933f580aa431f460c56e3 (diff)
Imported Upstream version 2.1.1
Diffstat (limited to 'test/simulation')
-rwxr-xr-xtest/simulation/009-sourceselection41
-rwxr-xr-xtest/simulation/111-knownclient2
-rwxr-xr-xtest/simulation/113-leapsecond39
-rwxr-xr-xtest/simulation/114-presend4
-rwxr-xr-xtest/simulation/116-minsources24
-rwxr-xr-xtest/simulation/117-fallbackdrift23
-rwxr-xr-xtest/simulation/118-maxdelay28
-rwxr-xr-xtest/simulation/119-smoothtime68
-rwxr-xr-xtest/simulation/202-prefer21
-rw-r--r--test/simulation/test.common21
10 files changed, 255 insertions, 16 deletions
diff --git a/test/simulation/009-sourceselection b/test/simulation/009-sourceselection
new file mode 100755
index 0000000..a6c9759
--- /dev/null
+++ b/test/simulation/009-sourceselection
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+. test.common
+
+test_start "source selection"
+
+# Falsetickers should be detected if their number is less than half of all
+
+base_delay=1e-3
+servers=5
+
+for falsetickers in 1 2; do
+ run_test || test_fail
+ check_chronyd_exit || test_fail
+ check_source_selection || test_fail
+ check_packet_interval || test_fail
+ check_sync || test_fail
+done
+
+for falsetickers in 3 4; do
+ run_test || test_fail
+ check_chronyd_exit || test_fail
+ check_packet_interval || test_fail
+ # These check are expected to fail
+ check_source_selection && test_fail
+ check_sync && test_fail
+done
+
+# Sources with large asymmetric delay should be excluded
+
+servers=3
+falsetickers=0
+base_delay="(+ 1e-3 (equal 0.1 to 2) (equal 0.1 to 3))"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_packet_interval || test_fail
+check_sync || test_fail
+
+test_pass
diff --git a/test/simulation/111-knownclient b/test/simulation/111-knownclient
index 13374ac..70ba2b1 100755
--- a/test/simulation/111-knownclient
+++ b/test/simulation/111-knownclient
@@ -4,7 +4,7 @@
test_start "reply to client configured as server"
-server_conf="server 192.168.123.2
+server_conf="server 192.168.123.2 noselect
acquisitionport 123"
client_conf="acquisitionport 123"
diff --git a/test/simulation/113-leapsecond b/test/simulation/113-leapsecond
index 3889d2e..7d67007 100755
--- a/test/simulation/113-leapsecond
+++ b/test/simulation/113-leapsecond
@@ -5,17 +5,42 @@ test_start "leap second"
export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Dec 30 2008 0:00:00' +'%s')
+leap=$[2 * 24 * 3600]
limit=$[4 * 24 * 3600]
server_conf="refclock SHM 0 dpoll 10 poll 10
leapsectz right/UTC"
-server_step="(* 1.0 (equal 0.1 (sum 1.0) $[2 * 24 * 3600 + 1]))"
-client_step="(* 1.0 (equal 0.1 (sum 1.0) $[2 * 24 * 3600 + 1]))"
refclock_jitter=1e-9
+refclock_offset="(* -1.0 (equal 0.1 (max (sum 1.0) $leap) $leap))"
-run_test || test_fail
-check_chronyd_exit || test_fail
-check_source_selection || test_fail
-check_packet_interval || test_fail
-check_sync || test_fail
+for leapmode in system step slew; do
+ client_conf="leapsecmode $leapmode"
+ if [ $leapmode = slew ]; then
+ max_sync_time=$[$leap + 12]
+ else
+ max_sync_time=$[$leap]
+ fi
+
+ run_test || test_fail
+ check_chronyd_exit || test_fail
+ check_source_selection || test_fail
+ check_packet_interval || test_fail
+ check_sync || test_fail
+done
+
+for smoothmode in "" "leaponly"; do
+ server_conf="refclock SHM 0 dpoll 10 poll 10
+ leapsectz right/UTC
+ leapsecmode slew
+ smoothtime 400 0.001 $smoothmode"
+ client_conf="leapsecmode system"
+ min_sync_time=230000
+ max_sync_time=240000
+
+ run_test || test_fail
+ check_chronyd_exit || test_fail
+ check_source_selection || test_fail
+ check_packet_interval || test_fail
+ check_sync || test_fail
+done
test_pass
diff --git a/test/simulation/114-presend b/test/simulation/114-presend
index ddbac93..e9fe66e 100755
--- a/test/simulation/114-presend
+++ b/test/simulation/114-presend
@@ -3,7 +3,9 @@
. test.common
test_start "presend option"
-client_server_options="presend 6"
+min_sync_time=140
+max_sync_time=260
+client_server_options="presend 6 maxdelay 16"
run_test || test_fail
check_chronyd_exit || test_fail
diff --git a/test/simulation/116-minsources b/test/simulation/116-minsources
new file mode 100755
index 0000000..f32596a
--- /dev/null
+++ b/test/simulation/116-minsources
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+. test.common
+
+test_start "minsources directive"
+
+client_conf="minsources 3"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_packet_interval || test_fail
+# These check are expected to fail
+check_source_selection && test_fail
+check_sync && test_fail
+
+servers=3
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_packet_interval || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+test_pass
diff --git a/test/simulation/117-fallbackdrift b/test/simulation/117-fallbackdrift
new file mode 100755
index 0000000..a4f3d0f
--- /dev/null
+++ b/test/simulation/117-fallbackdrift
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+. test.common
+test_start "fallback drift"
+
+limit=100000
+wander=0.0
+jitter=1e-6
+time_offset=10
+freq_offset="(* 1e-4 (sine 1000))"
+base_delay="(* -1.0 (equal 0.1 (min time 4250) 4250))"
+client_server_options="minpoll 4 maxpoll 4"
+client_conf="fallbackdrift 6 10"
+time_max_limit=1e0
+time_rms_limit=1e0
+freq_max_limit=5e-4
+freq_rms_limit=5e-4
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_sync || test_fail
+
+test_pass
diff --git a/test/simulation/118-maxdelay b/test/simulation/118-maxdelay
new file mode 100755
index 0000000..0e27847
--- /dev/null
+++ b/test/simulation/118-maxdelay
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+. test.common
+test_start "maxdelay options"
+
+max_sync_time=2000
+base_delay=1e-5
+jitter=1e-5
+wander=0.0
+freq_offset="(sum 1e-10)"
+time_rms_limit=2e-4
+
+client_server_options="maxdelay 3e-5 maxdelayratio 2.0 maxdelaydevratio 2.0"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_packet_interval || test_fail
+check_sync || test_fail
+
+for client_server_options in "maxdelay 2e-5" \ "maxdelayratio 1.001"; do
+ run_test || test_fail
+ check_chronyd_exit || test_fail
+ check_packet_interval || test_fail
+ check_sync && test_fail
+done
+
+test_pass
diff --git a/test/simulation/119-smoothtime b/test/simulation/119-smoothtime
new file mode 100755
index 0000000..5b043e2
--- /dev/null
+++ b/test/simulation/119-smoothtime
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+. test.common
+test_start "smoothtime option"
+
+server_strata=2
+server_conf="smoothtime 400 0.001"
+min_sync_time=250
+max_sync_time=1000
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+limit=10000
+refclock_jitter=1e-4
+refclock_offset="(* 10.0 (equal 0.1 (max (sum 1.0) 1000) 1000))"
+server_step="(* -10.0 (equal 0.1 (sum 1.0) 1))"
+server_strata=1
+server_conf="refclock SHM 0 dpoll 4 poll 6
+smoothtime 2000 1"
+time_offset=-10
+client_server_options="minpoll 6 maxpoll 6"
+client_conf="corrtimeratio 100"
+min_sync_time=8000
+max_sync_time=8500
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+min_sync_time=$default_min_sync_time
+max_sync_time=$default_max_sync_time
+time_max_limit=11
+time_rms_limit=11
+freq_max_limit=1e-2
+freq_rms_limit=2e-3
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+refclock_jitter=1e-9
+refclock_offset="(* 1e-1 (triangle 1000) (+ -1.0 (pulse 1000 10000)))"
+server_step=""
+server_conf="refclock SHM 0 dpoll 4 poll 6 minsamples 4 maxsamples 4
+smoothtime 1e4 1e-6"
+client_server_options="minpoll 4 maxpoll 4"
+time_offset=0.1
+jitter=1e-6
+wander=0.0
+min_sync_time=30
+max_sync_time=40
+time_max_limit=1e-5
+time_rms_limit=5e-6
+freq_max_limit=1e-6
+freq_rms_limit=1e-7
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_packet_interval || test_fail
+check_sync || test_fail
+
+test_pass
diff --git a/test/simulation/202-prefer b/test/simulation/202-prefer
new file mode 100755
index 0000000..57a7fc9
--- /dev/null
+++ b/test/simulation/202-prefer
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+. test.common
+
+# Test fix in commit 4253075a97141edfa62043ab71bd0673587e6629
+
+test_start "prefer option"
+
+servers=3
+client_server_conf="
+server 192.168.123.1
+server 192.168.123.2
+server 192.168.123.3 prefer"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_packet_interval || test_fail
+check_sync || test_fail
+
+test_pass
diff --git a/test/simulation/test.common b/test/simulation/test.common
index 8aee454..03476fd 100644
--- a/test/simulation/test.common
+++ b/test/simulation/test.common
@@ -18,7 +18,7 @@ export PATH=../../:$PATH
export CLKNETSIM_PATH=clknetsim
# Known working clknetsim revision
-clknetsim_revision=7ea71b32e0caec4d8da4cecc3499b5c87098e137
+clknetsim_revision=1e56224dee1db69c0027e9bd63c2a202d4765959
clknetsim_url=https://github.com/mlichvar/clknetsim/archive/$clknetsim_revision.tar.gz
# Only Linux is supported
@@ -49,6 +49,7 @@ default_base_delay=1e-4
default_jitter=1e-4
default_wander=1e-9
default_refclock_jitter=""
+default_refclock_offset=0.0
default_update_interval=0
default_shift_pll=2
@@ -57,12 +58,14 @@ default_server_strata=1
default_servers=1
default_clients=1
default_peers=0
+default_falsetickers=0
default_server_start=0.0
default_client_start=0.0
default_chronyc_start=1000.0
default_server_step=""
default_client_step=""
+default_client_server_conf=""
default_server_server_options=""
default_client_server_options=""
default_server_peer_options=""
@@ -167,7 +170,7 @@ get_delay_expr() {
}
get_refclock_expr() {
- echo "(* $refclock_jitter (normal))"
+ echo "(+ $refclock_offset (* $refclock_jitter (normal)))"
}
get_chronyd_nodes() {
@@ -190,9 +193,13 @@ get_chronyd_conf() {
done
echo "$server_conf"
else
- for i in $(seq 1 $servers); do
- echo "server 192.168.123.$[$servers * ($stratum - 2) + $i] $client_server_options"
- done
+ if [ -n "$client_server_conf" ]; then
+ echo "$client_server_conf"
+ else
+ for i in $(seq 1 $servers); do
+ echo "server 192.168.123.$[$servers * ($stratum - 2) + $i] $client_server_options"
+ done
+ fi
for i in $(seq 1 $peers); do
[ $i -eq $peer -o $i -gt $clients ] && continue
echo "peer 192.168.123.$[$servers * ($stratum - 1) + $i] $client_peer_options"
@@ -260,7 +267,7 @@ check_source_selection() {
for i in $(seq $[$servers * $server_strata + 1] $(get_chronyd_nodes)); do
test_message 3 0 "node $i:"
- ! grep -q 'no majority\|no reachable sources' tmp/log.$i && \
+ ! grep -q 'no majority\|no selectable sources' tmp/log.$i && \
grep -q 'Selected source' tmp/log.$i && \
test_ok || test_bad
[ $? -eq 0 ] || ret=1
@@ -397,7 +404,7 @@ run_test() {
step=$server_step
start=$server_start
freq=""
- offset=0.0
+ [ $i -le $falsetickers ] && offset=$i.0 || offset=0.0
elif [ $stratum -le $server_strata ]; then
step=$server_step
start=$server_start