Merge ~slyon/ubuntu/+source/linuxptp:merge-lp2130003-resolute into ~slyon/ubuntu/+source/linuxptp:new-upstream-release

Proposed by Lukas Märdian
Status: Merged
Merge reported by: Lukas Märdian
Merged at revision: 4dfcf8faf3b88301a2e54612967ec49d38ebdcd3
Proposed branch: ~slyon/ubuntu/+source/linuxptp:merge-lp2130003-resolute
Merge into: ~slyon/ubuntu/+source/linuxptp:new-upstream-release
Diff against target: 3121 lines (+2788/-2)
49 files modified
debian/changelog (+104/-1)
debian/control (+3/-1)
debian/copyright (+25/-0)
debian/linuxptp.install (+3/-0)
debian/rules (+5/-0)
debian/tests/README (+51/-0)
debian/tests/control (+3/-0)
debian/tests/linuxptp-testsuite/01-defaults (+10/-0)
debian/tests/linuxptp-testsuite/02-swts (+22/-0)
debian/tests/linuxptp-testsuite/03-p2pdm (+20/-0)
debian/tests/linuxptp-testsuite/04-manynodes (+12/-0)
debian/tests/linuxptp-testsuite/05-clockclass (+29/-0)
debian/tests/linuxptp-testsuite/06-slaveonly (+14/-0)
debian/tests/linuxptp-testsuite/07-latereselect (+18/-0)
debian/tests/linuxptp-testsuite/08-largefreq (+22/-0)
debian/tests/linuxptp-testsuite/09-largeoffset (+15/-0)
debian/tests/linuxptp-testsuite/10-largeslew (+19/-0)
debian/tests/linuxptp-testsuite/11-syncinterval (+17/-0)
debian/tests/linuxptp-testsuite/12-phc2sys (+75/-0)
debian/tests/linuxptp-testsuite/13-delayedfup (+19/-0)
debian/tests/linuxptp-testsuite/14-boundary (+22/-0)
debian/tests/linuxptp-testsuite/15-largejitter (+17/-0)
debian/tests/linuxptp-testsuite/16-largewander (+16/-0)
debian/tests/linuxptp-testsuite/17-piservo (+41/-0)
debian/tests/linuxptp-testsuite/18-autodm (+29/-0)
debian/tests/linuxptp-testsuite/19-externalstep (+29/-0)
debian/tests/linuxptp-testsuite/20-pmc (+488/-0)
debian/tests/linuxptp-testsuite/21-linregservo (+38/-0)
debian/tests/linuxptp-testsuite/22-passiveport (+24/-0)
debian/tests/linuxptp-testsuite/23-basedelay (+18/-0)
debian/tests/linuxptp-testsuite/24-nsm (+85/-0)
debian/tests/linuxptp-testsuite/25-telecomdscmp (+42/-0)
debian/tests/linuxptp-testsuite/26-transparent (+43/-0)
debian/tests/linuxptp-testsuite/27-masteronly (+27/-0)
debian/tests/linuxptp-testsuite/28-hybriddm (+14/-0)
debian/tests/linuxptp-testsuite/29-unicast (+158/-0)
debian/tests/linuxptp-testsuite/30-telecombmca (+56/-0)
debian/tests/linuxptp-testsuite/31-leapsecond (+100/-0)
debian/tests/linuxptp-testsuite/32-classthreshold (+22/-0)
debian/tests/linuxptp-testsuite/33-power (+24/-0)
debian/tests/linuxptp-testsuite/36-automotive (+57/-0)
debian/tests/linuxptp-testsuite/COPYING (+339/-0)
debian/tests/linuxptp-testsuite/README (+18/-0)
debian/tests/linuxptp-testsuite/run (+18/-0)
debian/tests/linuxptp-testsuite/test.common (+367/-0)
debian/tests/simulation-test-suite (+55/-0)
debian/usr.sbin.phc2sys (+44/-0)
debian/usr.sbin.ptp4l (+64/-0)
debian/usr.sbin.timemaster (+47/-0)
Reviewer Review Type Date Requested Status
Athos Ribeiro (community) Approve
Canonical Server Reporter Pending
Lukas Märdian Pending
Review via email: mp+497354@code.launchpad.net

Description of the change

Note: This merge is a bit special, as we're moving ahead of Debian, but actually basing our work on top of a pending Salsa MR: https://salsa.debian.org/multimedia-team/linuxptp/-/merge_requests/4

I decided to call that not-yet-in-Debian version 4.4-0~salsa1/experimental.
The branch that I've rebased onto is here: https://salsa.debian.org/vblut/linuxptp/-/tree/new-upstream-release

PPA: https://launchpad.net/~slyon/+archive/ubuntu/merge-lp2130003-resolute/+packages

DEP-8:
- passes locally:
$ autopkgtest ../*_4.4-0ubuntu1*.deb . -- lxd autopkgtest/ubuntu/resolute/amd64
[...]
autopkgtest [16:29:16]: @@@@@@@@@@@@@@@@@@@@ summary
simulation-test-suite PASS

$ ppa tests ppa:slyon/merge-lp2130003-resolute -r resolute
[...]
* Results:
  - linuxptp: resolute/linuxptp/4.4-0ubuntu1~ppa1 [amd64]
    + ✅ linuxptp on resolute for amd64 @ 11.12.25 17:27:07 Log️ 🗒️
  - linuxptp: resolute/linuxptp/4.4-0ubuntu1~ppa1 [arm64]
    + ✅ linuxptp on resolute for arm64 @ 11.12.25 17:21:14 Log️ 🗒️
  - linuxptp: resolute/linuxptp/4.4-0ubuntu1~ppa1 [armhf]
    + ✅ linuxptp on resolute for armhf @ 11.12.25 17:25:25 Log️ 🗒️
  - linuxptp: resolute/linuxptp/4.4-0ubuntu1~ppa1 [ppc64el]
    + ✅ linuxptp on resolute for ppc64el @ 11.12.25 17:21:13 Log️ 🗒️
  - linuxptp: resolute/linuxptp/4.4-0ubuntu1~ppa1 [s390x]
    + ✅ linuxptp on resolute for s390x @ 11.12.25 17:36:27 Log️ 🗒️

Range diff:
$ git range-diff lp2130003/old/debian..lp2130003/old/ubuntu lp2130003/new/debian..merge-lp2130003-resolute

To post a comment you must log in.
Revision history for this message
Athos Ribeiro (athos) wrote :

Thanks, Lukas! I am reviewing this one

Revision history for this message
Lukas Märdian (slyon) wrote :

Important note from Salsa:

"""
Upstream supports 4 different cryptographic libraries to enable this features:

- GnuPG
- GnuTLS
- Nettle
- OpenSSL

I decided to go with Nettle because it was the least burdensome choice. OpenSSL enforces a license change to GPLv3 on LinuxPTP, GnuTLS depends on nettle-dev so we end up with both the Nettle and GnuTLS backends enabled if we don’t patch the upstream source and I did not considerate GnuPG.
"""

=> going with Nettle should be fine as long as the package stays in universe.

Revision history for this message
Athos Ribeiro (athos) wrote :

Thanks Lukas!
LGTM (thanks for taking the time to figure out all the tags for this non-conventional merge)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index ff4f062..5af053d 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,4 +1,37 @@
6-linuxptp (4.4-1) UNRELEASED; urgency=medium
7+linuxptp (4.4-0ubuntu1) resolute; urgency=medium
8+
9+ * Merge with Salsa MR#4 (LP: #2130003, LP: #2115203). Remaining changes:
10+ - Add autopkgtest to run linuxptp-testsuite.
11+ + d/t/linuxptp-testsuite: Include a copy of linuxptp-testsuite from
12+ https://github.com/mlichvar/linuxptp-testsuite.
13+ + d/t/README: Instructions to update the test suite for new upstream
14+ versions.
15+ + Note that the tests use needs-internet to download clknetsim, like
16+ in the chrony autopkgtests.
17+ - d/copyright: Add test suite copyright clauses.
18+ - Add AppArmor rules for ptp4l (LP #2083458)
19+ + d/control: Add dh-apparmor dependency
20+ + d/linuxptp.install: Add aa rules destdir
21+ + d/rules: Add section for aa profile adition
22+ + d/tests/simulation-test-suite: Add script function to inject additional
23+ local aa rules needed for autopkgtest
24+ + d/tests/control: Add needs-sudo capability
25+ + d/usr.sbin.ptp4l: aa profile for ptp4l application
26+ - Add AppArmor rules for timemaster (ref LP #2083458)
27+ + d/linuxptp.install: Add aa rules destdir for timemaster
28+ + d/rules: Add timemaster aa profile entry
29+ + d/usr.sbin.timemaster: aa profile for timemaster service
30+ - Add AppArmor rules for phc2sys (ref LP #2083458)
31+ + d/linuxptp.install: Add aa rules destdir for phc2sys
32+ + d/rules: Add phc2sys aa profile entry
33+ + d/tests/simulation-test-suite: Insert rule on aa profile for autopkgtest
34+ + d/usr.sbin.phc2sys: aa profile for phc2sys service
35+ * Drop Changes:
36+ - d/timemaster.conf: Fix path to chrony.conf. [applied in Debian]
37+
38+ -- Lukas Märdian <slyon@ubuntu.com> Thu, 11 Dec 2025 15:59:21 +0100
39+
40+linuxptp (4.4-0~salsa1) experimental; urgency=medium
41
42 * New upstream version 4.4 (Closes: #1108202)
43 * d/control: Update Homepage
44@@ -23,6 +56,48 @@ linuxptp (4.4-1) UNRELEASED; urgency=medium
45
46 -- Vincent Blut <vincent.debian@free.fr> Sun, 21 Sep 2025 20:42:49 +0200
47
48+linuxptp (4.2-1ubuntu2) questing; urgency=medium
49+
50+ * Add AppArmor rules for ptp4l (LP: #2083458)
51+ - d/control: Add dh-apparmor dependency
52+ - d/linuxptp.install: Add aa rules destdir
53+ - d/rules: Add section for aa profile adition
54+ - d/tests/simulation-test-suite: Add script function to inject additional local
55+ aa rules needed for autopkgtest
56+ - d/tests/control: Add needs-sudo capability
57+ - d/usr.sbin.ptp4l: aa profile for ptp4l application
58+
59+ * Add AppArmor rules for timemaster (ref LP #2083458)
60+ - d/linuxptp.install: Add aa rules destdir for timemaster
61+ - d/rules: Add timemaster aa profile entry
62+ - d/usr.sbin.timemaster: aa profile for timemaster service
63+
64+ * Add AppArmor rules for phc2sys (ref LP #2083458)
65+ - d/linuxptp.install: Add aa rules destdir for phc2sys
66+ - d/rules: Add phc2sys aa profile entry
67+ - d/tests/simulation-test-suite: Insert rule on aa profile for autopkgtest
68+ - d/usr.sbin.phc2sys: aa profile for phc2sys service
69+
70+ -- Lincoln Wallace <lincoln.wallace@canonical.com> Wed, 02 Oct 2024 15:50:17 -0300
71+
72+linuxptp (4.2-1ubuntu1) oracular; urgency=medium
73+
74+ * Merge with Debian unstable (LP: #2073737). Remaining changes:
75+ - d/timemaster.conf: Fix path to chrony.conf.
76+ (LP #2032805)
77+ - Add autopkgtest to run linuxptp-testsuite.
78+ + d/t/linuxptp-testsuite: Include a copy of linuxptp-testsuite from
79+ https://github.com/mlichvar/linuxptp-testsuite.
80+ + d/t/README: Instructions to update the test suite for new upstream
81+ versions.
82+ + Note that the tests use needs-internet to download clknetsim, like
83+ in the chrony autopkgtests.
84+ - d/copyright: Add test suite copyright clauses.
85+ * New Changes:
86+ - d/tests: Update test suite for linuxptp 4.2
87+
88+ -- JP Meijers <jp.meijers@canonical.com> Tue, 30 Jul 2024 10:15:18 +0200
89+
90 linuxptp (4.2-1) unstable; urgency=medium
91
92 [ IOhannes m zmölnig (Debian/GNU) ]
93@@ -36,6 +111,34 @@ linuxptp (4.2-1) unstable; urgency=medium
94
95 -- Punit Agrawal <punit@debian.org> Sat, 30 Mar 2024 07:11:06 +0000
96
97+linuxptp (4.0-1ubuntu3) oracular; urgency=medium
98+
99+ * Fix simulation-test-suite autopkgtest to properly pickup clknetsim
100+ from wget-ed download instead of trying to git clone it.
101+
102+ -- JP Meijers <jp.meijers@canonical.com> Thu, 13 Jun 2024 15:57:28 +0000
103+
104+linuxptp (4.0-1ubuntu2) oracular; urgency=medium
105+
106+ * Add autopkgtest to run linuxptp-testsuite.
107+ - See https://code.launchpad.net/~jpm/ubuntu/+source/linuxptp/+git/linuxptp/+merge/466495
108+ - Include a copy of linuxptp-testsuite from
109+ https://github.com/mlichvar/linuxptp-testsuite under debian/tests;
110+ instructions to update the snapshot for new upstream versions are in
111+ debian/tests/README.
112+ - Update debian/copyright.
113+ - Note that the tests use needs-internet to download clknetsim, like
114+ in the chrony autopkgtests.
115+
116+ -- JP Meijers <jp.meijers@canonical.com> Wed, 12 Jun 2024 16:02:49 +0000
117+
118+linuxptp (4.0-1ubuntu1) noble; urgency=medium
119+
120+ * d/timemaster.conf: Fix path to chrony.conf.
121+ (LP: #2032805)
122+
123+ -- Bryce Harrington <bryce@canonical.com> Mon, 01 Apr 2024 18:42:08 -0700
124+
125 linuxptp (4.0-1) unstable; urgency=medium
126
127 * New upstream version 4.0
128diff --git a/debian/control b/debian/control
129index e793e8b..04464e9 100644
130--- a/debian/control
131+++ b/debian/control
132@@ -1,11 +1,13 @@
133 Source: linuxptp
134 Section: utils
135-Maintainer: Debian Multimedia Maintainers <debian-multimedia@lists.debian.org>
136+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
137+XSBC-Original-Maintainer: Debian Multimedia Maintainers <debian-multimedia@lists.debian.org>
138 Uploaders:
139 Tino Mettler <tino+debian@tikei.de>,
140 Punit Agrawal <punit@debian.org>,
141 Build-Depends:
142 debhelper-compat (= 13),
143+ dh-apparmor,
144 dh-exec,
145 nettle-dev
146 Standards-Version: 4.7.2
147diff --git a/debian/copyright b/debian/copyright
148index 70a7d26..5f14ca9 100644
149--- a/debian/copyright
150+++ b/debian/copyright
151@@ -21,6 +21,31 @@ Copyright: 2014-2015 Miroslav Lichvar <mlichvar@redhat.com>
152 2015 Tino Mettler <tino+debian@tikei.de>
153 License: GPL-2.0+
154
155+Files: debian/tests/linuxptp-testsuite/*
156+Copyright: 2013-2024 Miroslav Lichvar <mlichvar@redhat.com>
157+License: GPL-2.0+
158+
159+Files: debian/tests/simulation-test-suite
160+Copyright: 2015-2023 Vincent Blut <vincent.debian@free.fr>
161+ 2024 Canonical Ltd
162+License: GPL-2
163+
164+License: GPL-2
165+ This program is free software: you can redistribute it and/or modify
166+ it under the terms of the GNU General Public License version 2 as
167+ published by the Free Software Foundation.
168+ .
169+ This package is distributed in the hope that it will be useful,
170+ but WITHOUT ANY WARRANTY; without even the implied warranty of
171+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
172+ GNU General Public License for more details.
173+ .
174+ You should have received a copy of the GNU General Public License
175+ along with this program. If not, see <https://www.gnu.org/licenses/>.
176+ .
177+ On Debian systems, the complete text of the GNU General Public License
178+ version 2 can be found in the file `/usr/share/common-licenses/GPL-2'.
179+
180 License: GPL-2.0+
181 This program is free software; you can redistribute it and/or modify
182 it under the terms of the GNU General Public License as published by
183diff --git a/debian/linuxptp.install b/debian/linuxptp.install
184index ad008d9..f0706a0 100755
185--- a/debian/linuxptp.install
186+++ b/debian/linuxptp.install
187@@ -1,3 +1,6 @@
188 #!/usr/bin/dh-exec
189 configs/default.cfg => /etc/linuxptp/ptp4l.conf
190 debian/timemaster.conf /etc/linuxptp/
191+debian/usr.sbin.ptp4l etc/apparmor.d
192+debian/usr.sbin.timemaster etc/apparmor.d
193+debian/usr.sbin.phc2sys etc/apparmor.d
194diff --git a/debian/rules b/debian/rules
195index 38cfc04..01e297f 100755
196--- a/debian/rules
197+++ b/debian/rules
198@@ -12,6 +12,11 @@ export DH_VERBOSE = 1
199 override_dh_auto_install:
200 dh_auto_install -- prefix=/usr mandir=/usr/share/man
201
202+execute_after_dh_install:
203+ dh_apparmor --profile-name=usr.sbin.ptp4l -plinuxptp
204+ dh_apparmor --profile-name=usr.sbin.timemaster -plinuxptp
205+ dh_apparmor --profile-name=usr.sbin.phc2sys -plinuxptp
206+
207 override_dh_installsystemd:
208 dh_installsystemd --no-enable --no-start --name=ptp4l@
209 dh_installsystemd --no-enable --no-start --name=phc2sys@
210diff --git a/debian/tests/README b/debian/tests/README
211new file mode 100644
212index 0000000..cb21cb2
213--- /dev/null
214+++ b/debian/tests/README
215@@ -0,0 +1,51 @@
216+# linuxptp-testsuite
217+
218+The directory linuxptp-testsuite contains a snapshot of the test suite source
219+code from https://github.com/mlichvar/linuxptp-testsuite.git at commit hash
220+bf8eadc.
221+
222+The version of linuxptp-testsuite needs to be compatible with the version of
223+linuxptp in this package. A summary of known compatible versions are listed
224+below in the compatibility matrix.
225+
226+When the version of linuxptp is updated, these tests need to be updated too.
227+
228+
229+## Copying test suite
230+
231+A tar archive of linuxptp-testsuite can be downloaded from Github and extracted
232+to the linuxptp-testsuite directory with these commands:
233+
234+$ COMMIT_ID=bf8eadc
235+$ wget https://github.com/mlichvar/linuxptp-testsuite/archive/$COMMIT_ID/linuxptp-testsuite-$COMMIT_ID.tar.gz
236+$ mkdir linuxptp-testsuite
237+$ tar -xvzf linuxptp-testsuite-$COMMIT_ID.tar.gz -C linuxptp-testsuite --strip-components=1
238+$ rm linuxptp-testsuite-$COMMIT_ID.tar.gz
239+
240+
241+git-ubuntu does not want .gitignore files in the archive package. Therefore remove it:
242+
243+$ rm linuxptp-testsuite/.gitignore
244+
245+
246+## Automotive test
247+
248+The test script 36-automotive is taken from commit d27dbdb of the test-suite and
249+added manually here. This is for extra coverage of the automotive related
250+configurations of linuxptp. These are not properly covered by commit b4763bb of
251+linuxptp-testsuite which is compatible with v4.0 of linuxptp. This will also be
252+required for linuxptp v4.0, v4.1 and v4.2. After that the upstream issue is
253+solved. See https://github.com/mlichvar/linuxptp-testsuite/issues/13
254+
255+$ wget https://raw.githubusercontent.com/mlichvar/linuxptp-testsuite/master/36-automotive -O linuxptp-testsuite/36-automotive
256+$ chmod 775 linuxptp-testsuite/36-automotive
257+
258+
259+## Version compatibility matrix
260+
261+linuxptp version | linuxptp-testsuite commit id
262+------------------|------------------------------
263+v4.0 | b4763bb
264+v4.1 | 248073c
265+v4.2 | bf8eadc
266+v4.3 | d27dbdb (includes 36-automotive)
267diff --git a/debian/tests/control b/debian/tests/control
268new file mode 100644
269index 0000000..147f518
270--- /dev/null
271+++ b/debian/tests/control
272@@ -0,0 +1,3 @@
273+Tests: simulation-test-suite
274+Depends: wget, g++, make, linuxptp
275+Restrictions: allow-stderr, isolation-container, build-needed, skippable, needs-internet, needs-sudo
276diff --git a/debian/tests/linuxptp-testsuite/01-defaults b/debian/tests/linuxptp-testsuite/01-defaults
277new file mode 100755
278index 0000000..b2017de
279--- /dev/null
280+++ b/debian/tests/linuxptp-testsuite/01-defaults
281@@ -0,0 +1,10 @@
282+#!/bin/bash
283+
284+. test.common
285+
286+test_start "ptp4l in default test settings"
287+
288+run_ptp4l || test_fail
289+check_sync || test_fail
290+
291+test_pass
292diff --git a/debian/tests/linuxptp-testsuite/02-swts b/debian/tests/linuxptp-testsuite/02-swts
293new file mode 100755
294index 0000000..076fcab
295--- /dev/null
296+++ b/debian/tests/linuxptp-testsuite/02-swts
297@@ -0,0 +1,22 @@
298+#!/bin/bash
299+
300+. test.common
301+
302+test_start "ptp4l with software time stamping"
303+
304+limit=2000
305+min_sync_time=50
306+max_sync_time=300
307+
308+master_conf="time_stamping software"
309+slave_conf="time_stamping software"
310+run_ptp4l || test_fail
311+check_sync || test_fail
312+
313+master_conf="time_stamping hardware"
314+slave_conf="time_stamping software"
315+run_ptp4l || test_fail
316+# this should fail (UTC-TAI offset)
317+check_sync && test_fail
318+
319+test_pass
320diff --git a/debian/tests/linuxptp-testsuite/03-p2pdm b/debian/tests/linuxptp-testsuite/03-p2pdm
321new file mode 100755
322index 0000000..6c24c14
323--- /dev/null
324+++ b/debian/tests/linuxptp-testsuite/03-p2pdm
325@@ -0,0 +1,20 @@
326+#!/bin/bash
327+
328+. test.common
329+
330+test_start "ptp4l with P2P delay mechanism"
331+
332+nodes=2
333+
334+master_conf="delay_mechanism P2P"
335+slave_conf="delay_mechanism P2P"
336+run_ptp4l || test_fail
337+check_sync || test_fail
338+
339+master_conf="delay_mechanism P2P"
340+slave_conf="delay_mechanism E2E"
341+run_ptp4l || test_fail
342+# this should fail
343+check_sync && test_fail
344+
345+test_pass
346diff --git a/debian/tests/linuxptp-testsuite/04-manynodes b/debian/tests/linuxptp-testsuite/04-manynodes
347new file mode 100755
348index 0000000..3807b86
349--- /dev/null
350+++ b/debian/tests/linuxptp-testsuite/04-manynodes
351@@ -0,0 +1,12 @@
352+#!/bin/bash
353+
354+. test.common
355+
356+test_start "ptp4l with many nodes"
357+
358+nodes=10
359+
360+run_ptp4l || test_fail
361+check_sync || test_fail
362+
363+test_pass
364diff --git a/debian/tests/linuxptp-testsuite/05-clockclass b/debian/tests/linuxptp-testsuite/05-clockclass
365new file mode 100755
366index 0000000..0919fa2
367--- /dev/null
368+++ b/debian/tests/linuxptp-testsuite/05-clockclass
369@@ -0,0 +1,29 @@
370+#!/bin/bash
371+
372+. test.common
373+
374+test_start "ptp4l master selection (clockClass, priority1, priority2)"
375+
376+master_nodes="2"
377+
378+master_conf="clockClass 6"
379+slave_conf=""
380+run_ptp4l || test_fail
381+check_sync || test_fail
382+
383+master_conf=""
384+slave_conf="clockClass 249"
385+run_ptp4l || test_fail
386+check_sync || test_fail
387+
388+master_conf="priority1 127"
389+slave_conf=""
390+run_ptp4l || test_fail
391+check_sync || test_fail
392+
393+master_conf=""
394+slave_conf="priority2 129"
395+run_ptp4l || test_fail
396+check_sync || test_fail
397+
398+test_pass
399diff --git a/debian/tests/linuxptp-testsuite/06-slaveonly b/debian/tests/linuxptp-testsuite/06-slaveonly
400new file mode 100755
401index 0000000..454fd48
402--- /dev/null
403+++ b/debian/tests/linuxptp-testsuite/06-slaveonly
404@@ -0,0 +1,14 @@
405+#!/bin/bash
406+
407+. test.common
408+
409+test_start "ptp4l with slaveOnly option"
410+
411+nodes=3
412+master_nodes="2"
413+slave_conf="slaveOnly 1"
414+
415+run_ptp4l || test_fail
416+check_sync || test_fail
417+
418+test_pass
419diff --git a/debian/tests/linuxptp-testsuite/07-latereselect b/debian/tests/linuxptp-testsuite/07-latereselect
420new file mode 100755
421index 0000000..b05218c
422--- /dev/null
423+++ b/debian/tests/linuxptp-testsuite/07-latereselect
424@@ -0,0 +1,18 @@
425+#!/bin/bash
426+
427+. test.common
428+
429+test_start "ptp4l with late master reselect"
430+
431+master_start=100.0
432+slave_start=0.0
433+slave_conf="logging_level 7
434+pi_offset_const 0.05"
435+min_sync_time=110
436+max_sync_time=140
437+
438+run_ptp4l || test_fail
439+check_sync || test_fail
440+check_ptp4l_delay || test_fail
441+
442+test_pass
443diff --git a/debian/tests/linuxptp-testsuite/08-largefreq b/debian/tests/linuxptp-testsuite/08-largefreq
444new file mode 100755
445index 0000000..88ecd9a
446--- /dev/null
447+++ b/debian/tests/linuxptp-testsuite/08-largefreq
448@@ -0,0 +1,22 @@
449+#!/bin/bash
450+
451+. test.common
452+
453+test_start "ptp4l with large frequency offsets"
454+
455+# System clock allows larger frequency adjustment
456+master_conf="time_stamping software"
457+slave_conf="time_stamping software
458+pi_proportional_scale 0.7
459+pi_integral_scale 0.3"
460+max_sync_time=80
461+
462+freq_offset=$(awk 'BEGIN { print 1 / 0.91 - 1 }')
463+run_ptp4l || test_fail
464+check_sync || test_fail
465+
466+freq_offset=$(awk 'BEGIN { print 1 / 1.09 - 1 }')
467+run_ptp4l || test_fail
468+check_sync || test_fail
469+
470+test_pass
471diff --git a/debian/tests/linuxptp-testsuite/09-largeoffset b/debian/tests/linuxptp-testsuite/09-largeoffset
472new file mode 100755
473index 0000000..d51644b
474--- /dev/null
475+++ b/debian/tests/linuxptp-testsuite/09-largeoffset
476@@ -0,0 +1,15 @@
477+#!/bin/bash
478+
479+. test.common
480+
481+test_start "ptp4l with large initial offsets"
482+
483+time_offset=1e9
484+run_ptp4l || test_fail
485+check_sync || test_fail
486+
487+time_offset=-1e9
488+run_ptp4l || test_fail
489+check_sync || test_fail
490+
491+test_pass
492diff --git a/debian/tests/linuxptp-testsuite/10-largeslew b/debian/tests/linuxptp-testsuite/10-largeslew
493new file mode 100755
494index 0000000..ae203c2
495--- /dev/null
496+++ b/debian/tests/linuxptp-testsuite/10-largeslew
497@@ -0,0 +1,19 @@
498+#!/bin/bash
499+
500+. test.common
501+
502+test_start "ptp4l with large initial slew"
503+
504+slave_conf="pi_f_offset_const 0.0"
505+min_sync_time=330
506+max_sync_time=360
507+
508+time_offset=10
509+run_ptp4l || test_fail
510+check_sync || test_fail
511+
512+time_offset=-10
513+run_ptp4l || test_fail
514+check_sync || test_fail
515+
516+test_pass
517diff --git a/debian/tests/linuxptp-testsuite/11-syncinterval b/debian/tests/linuxptp-testsuite/11-syncinterval
518new file mode 100755
519index 0000000..9a0a73b
520--- /dev/null
521+++ b/debian/tests/linuxptp-testsuite/11-syncinterval
522@@ -0,0 +1,17 @@
523+#!/bin/bash
524+
525+. test.common
526+
527+test_start "ptp4l with various sync intervals"
528+
529+max_sync_time=320
530+
531+for i in $(seq -4 2 4); do
532+ update_interval=$i
533+ master_conf="logSyncInterval $i"
534+ freq_max_limit=$(awk 'BEGIN {print 2e-6 / (2**'$i')**0.5}')
535+ run_ptp4l || test_fail
536+ check_sync || test_fail
537+done
538+
539+test_pass
540diff --git a/debian/tests/linuxptp-testsuite/12-phc2sys b/debian/tests/linuxptp-testsuite/12-phc2sys
541new file mode 100755
542index 0000000..05036d0
543--- /dev/null
544+++ b/debian/tests/linuxptp-testsuite/12-phc2sys
545@@ -0,0 +1,75 @@
546+#!/bin/bash
547+
548+. test.common
549+
550+test_start "phc2sys"
551+
552+nodes=1
553+master_nodes="0"
554+phc2sys_node=1
555+phc2sys_conf="-O 0 -s /dev/ptp0"
556+
557+run_test || test_fail
558+check_sync || test_fail
559+
560+time_max_limit=1e-8
561+phc2sys_conf="-O 0 -d /dev/pps0"
562+
563+run_test || test_fail
564+check_sync || test_fail
565+
566+phc2sys_conf="-O 0 -s /dev/ptp0 -d /dev/pps0"
567+
568+run_test || test_fail
569+check_sync || test_fail
570+
571+nodes=3
572+subnets="1 2 3 | 1 2 3"
573+master_nodes="1"
574+master_conf="utc_offset 30"
575+refclock_offset="-30"
576+phc2sys_node=3
577+phc2sys_uds="2:1"
578+phc2sys_phc_base=2
579+phc2sys_phc_swap=1
580+time_max_limit=$default_time_max_limit
581+
582+phc2sys_conf="-w -s eth0"
583+
584+run_test || test_fail
585+check_sync || test_fail
586+
587+phc2sys_conf="-a -r"
588+# network down at 150-250 in subnet 1 and 100-200 in subnet 2
589+base_delay=$(cat <<-EOF | tr -d '\n'
590+ (+ $default_base_delay
591+ (* -1
592+ (equal 0.6 subnet 1.5)
593+ (equal 0.1 (min (+ time (* subnet 50) -100) 100) 100)
594+ (equal 0.1 (max (+ time (* subnet 50) -100) 200) 200)))
595+EOF
596+)
597+# step at 170th second
598+slave_step="(* $time_offset (equal 0.1 (sum 1.0) 170))"
599+min_sync_time=215
600+max_sync_time=240
601+
602+run_test || test_fail
603+check_sync || test_fail
604+
605+nodes=4
606+subnets="1 2 4 | 1 3 4"
607+phc2sys_node=4
608+phc2sys_phc_base=3
609+phc2sys_uds="3:1 2:1"
610+max_sync_time=290
611+
612+run_test || test_fail
613+check_sync || test_fail
614+
615+check_any_log_message 4 "\[[12].\..*select.*out-of-domain" "eth1" || test_fail
616+check_any_log_message 4 "\[10.\..*select.*out-of-domain" "eth0" || test_fail
617+check_any_log_message 4 "\[20.\..*select.*out-of-domain" "eth1" || test_fail
618+check_any_log_message 4 "\[25.\..*select.*out-of-domain" "eth1" || test_fail
619+
620+test_pass
621diff --git a/debian/tests/linuxptp-testsuite/13-delayedfup b/debian/tests/linuxptp-testsuite/13-delayedfup
622new file mode 100755
623index 0000000..1624aee
624--- /dev/null
625+++ b/debian/tests/linuxptp-testsuite/13-delayedfup
626@@ -0,0 +1,19 @@
627+#!/bin/bash
628+
629+. test.common
630+
631+# In linuxptp-1.2 and earlier cached followup message was incorrectly
632+# paired with sync message when sequence id overflowed
633+
634+test_start "ptp4l with long delay between sync and followup"
635+
636+limit=67000
637+jitter=0.0
638+wander=0.0
639+nodes=2
640+base_delay="(+ 1e-6 (* 0.5 (+ port -319)))"
641+max_sync_time=45
642+run_ptp4l || test_fail
643+check_sync || test_fail
644+
645+test_pass
646diff --git a/debian/tests/linuxptp-testsuite/14-boundary b/debian/tests/linuxptp-testsuite/14-boundary
647new file mode 100755
648index 0000000..81709d1
649--- /dev/null
650+++ b/debian/tests/linuxptp-testsuite/14-boundary
651@@ -0,0 +1,22 @@
652+#!/bin/bash
653+
654+. test.common
655+
656+test_start "ptp4l with boundary clocks"
657+
658+# 1 --- 2 --- 3
659+# | |
660+# 4 --- 5 --- 6,7
661+subnets="1 2 | 2 3 | 2 4 | 3 5 | 4 5 | 5 6 7"
662+nodes=7
663+max_sync_time=100
664+time_max_limit=5e-6
665+freq_max_limit=5e-6
666+master_conf="clockClass 6"
667+
668+for master_nodes in "1" "4" "7"; do
669+ run_ptp4l || test_fail
670+ check_sync || test_fail
671+done
672+
673+test_pass
674diff --git a/debian/tests/linuxptp-testsuite/15-largejitter b/debian/tests/linuxptp-testsuite/15-largejitter
675new file mode 100755
676index 0000000..31fde99
677--- /dev/null
678+++ b/debian/tests/linuxptp-testsuite/15-largejitter
679@@ -0,0 +1,17 @@
680+#!/bin/bash
681+
682+. test.common
683+
684+test_start "ptp4l with large jitter"
685+
686+time_offset=1e0
687+jitter=1e-1
688+time_max_limit=5e-1
689+freq_max_limit=5e-1
690+time_rms_limit=1e-1
691+freq_rms_limit=1e-1
692+
693+run_ptp4l || test_fail
694+check_sync || test_fail
695+
696+test_pass
697diff --git a/debian/tests/linuxptp-testsuite/16-largewander b/debian/tests/linuxptp-testsuite/16-largewander
698new file mode 100755
699index 0000000..16f3af4
700--- /dev/null
701+++ b/debian/tests/linuxptp-testsuite/16-largewander
702@@ -0,0 +1,16 @@
703+#!/bin/bash
704+
705+. test.common
706+
707+test_start "ptp4l with large wander"
708+
709+wander=1e-4
710+time_max_limit=1e-3
711+freq_max_limit=1e-3
712+time_rms_limit=2e-4
713+freq_rms_limit=2e-4
714+
715+run_ptp4l || test_fail
716+check_sync || test_fail
717+
718+test_pass
719diff --git a/debian/tests/linuxptp-testsuite/17-piservo b/debian/tests/linuxptp-testsuite/17-piservo
720new file mode 100755
721index 0000000..266fb35
722--- /dev/null
723+++ b/debian/tests/linuxptp-testsuite/17-piservo
724@@ -0,0 +1,41 @@
725+#!/bin/bash
726+
727+. test.common
728+
729+test_start "ptp4l and phc2sys with various PI servo configurations"
730+
731+wander=1e-9
732+limit=4000
733+max_sync_time=2000
734+
735+for jitter in 1e-8 1e-7 1e-6 1e-5; do
736+ kp=$(awk 'BEGIN {x=1.5 / sqrt('$jitter'/'$wander'); print x < 0.7 ? x : 0.7}')
737+ ki=$(awk 'BEGIN {x=1.2 / ('$jitter'/'$wander'); print x < 0.3 ? x : 0.3}')
738+ time_rms_limit=$(awk 'BEGIN {print 1.5e-8 * ('$jitter'/1e-8)**0.75}')
739+ freq_rms_limit=$(awk 'BEGIN {print 1.5e-8 * ('$jitter'/1e-8)**0.5}')
740+ time_max_limit=$(awk 'BEGIN {print 8 * '$time_rms_limit'}')
741+ freq_max_limit=$(awk 'BEGIN {print 8 * '$freq_rms_limit'}')
742+
743+ refclock_jitter=$jitter
744+ master_conf=""
745+ slave_conf=""
746+ phc2sys_conf="-s /dev/ptp0 -O 0 -P $kp -I $ki"
747+ nodes=1
748+ master_nodes="0"
749+ phc2sys_node=1
750+ run_test || test_fail
751+ check_sync || test_fail
752+
753+ master_conf="delay_mechanism P2P"
754+ slave_conf="delay_mechanism P2P
755+ pi_proportional_const $kp
756+ pi_integral_const $ki"
757+ phc2sys_conf=""
758+ nodes=2
759+ master_nodes="1"
760+ phc2sys_node=0
761+ run_ptp4l || test_fail
762+ check_sync || test_fail
763+done
764+
765+test_pass
766diff --git a/debian/tests/linuxptp-testsuite/18-autodm b/debian/tests/linuxptp-testsuite/18-autodm
767new file mode 100755
768index 0000000..0743493
769--- /dev/null
770+++ b/debian/tests/linuxptp-testsuite/18-autodm
771@@ -0,0 +1,29 @@
772+#!/bin/bash
773+
774+. test.common
775+
776+test_start "ptp4l with Auto delay mechanism"
777+
778+nodes=2
779+
780+master_conf="delay_mechanism Auto"
781+slave_conf="delay_mechanism P2P"
782+run_ptp4l || test_fail
783+check_sync || test_fail
784+
785+master_conf="delay_mechanism P2P"
786+slave_conf="delay_mechanism Auto"
787+run_ptp4l || test_fail
788+check_sync || test_fail
789+
790+master_conf="delay_mechanism Auto"
791+slave_conf="delay_mechanism E2E"
792+run_ptp4l || test_fail
793+check_sync || test_fail
794+
795+master_conf="delay_mechanism E2E"
796+slave_conf="delay_mechanism Auto"
797+run_ptp4l || test_fail
798+check_sync || test_fail
799+
800+test_pass
801diff --git a/debian/tests/linuxptp-testsuite/19-externalstep b/debian/tests/linuxptp-testsuite/19-externalstep
802new file mode 100755
803index 0000000..bd51ac9
804--- /dev/null
805+++ b/debian/tests/linuxptp-testsuite/19-externalstep
806@@ -0,0 +1,29 @@
807+#!/bin/bash
808+
809+. test.common
810+
811+test_start "ptp4l with external clock step"
812+
813+# start the master so that the slaves are likely to have
814+# the step between the sync and delay request messages
815+freq_offset=0.0
816+master_start=0.9
817+# 100s step in 100th second
818+slave_step="(* 100 (equal 0.1 (sum 1.0) 100))"
819+min_sync_time=100
820+max_sync_time=110
821+nodes=6
822+
823+slave_conf="clock_servo pi
824+delay_filter_length 20
825+step_threshold 10.0"
826+run_ptp4l || test_fail
827+check_sync || test_fail
828+
829+slave_conf="clock_servo linreg
830+delay_filter_length 20
831+step_threshold 10.0"
832+run_ptp4l || test_fail
833+check_sync || test_fail
834+
835+test_pass
836diff --git a/debian/tests/linuxptp-testsuite/20-pmc b/debian/tests/linuxptp-testsuite/20-pmc
837new file mode 100755
838index 0000000..ee32afb
839--- /dev/null
840+++ b/debian/tests/linuxptp-testsuite/20-pmc
841@@ -0,0 +1,488 @@
842+#!/bin/bash
843+
844+. test.common
845+
846+test_start "pmc"
847+
848+limit=51
849+jitter=0.0
850+subnets="1 2 | 2 3"
851+pmc_node=3
852+
853+requests_replies=(
854+"GET USER_DESCRIPTION"
855+"sending: GET USER_DESCRIPTION
856+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT USER_DESCRIPTION
857+ userDescription "
858+
859+"GET DEFAULT_DATA_SET"
860+"sending: GET DEFAULT_DATA_SET
861+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT DEFAULT_DATA_SET
862+ twoStepFlag 1
863+ slaveOnly 0
864+ numberPorts 2
865+ priority1 128
866+ clockClass 248
867+ clockAccuracy 0xfe
868+ offsetScaledLogVariance 0xffff
869+ priority2 128
870+ clockIdentity 123456\.fffe\.780102
871+ domainNumber 0"
872+
873+"GET CURRENT_DATA_SET"
874+"sending: GET CURRENT_DATA_SET
875+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT CURRENT_DATA_SET
876+ stepsRemoved 1
877+ offsetFromMaster -?[0-9]+\.[0-9]+
878+ meanPathDelay [0-9]+\.[0-9]+"
879+
880+"GET PARENT_DATA_SET"
881+"sending: GET PARENT_DATA_SET
882+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT PARENT_DATA_SET
883+ parentPortIdentity 123456\.fffe\.780101-1
884+ parentStats 0
885+ observedParentOffsetScaledLogVariance 0xffff
886+ observedParentClockPhaseChangeRate 0x7fffffff
887+ grandmasterPriority1 128
888+ gm\.ClockClass 248
889+ gm\.ClockAccuracy 0xfe
890+ gm\.OffsetScaledLogVariance 0xffff
891+ grandmasterPriority2 128
892+ grandmasterIdentity 123456\.fffe\.780101"
893+
894+"GET TIME_PROPERTIES_DATA_SET"
895+"sending: GET TIME_PROPERTIES_DATA_SET
896+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT TIME_PROPERTIES_DATA_SET
897+ currentUtcOffset 3[567]
898+ leap61 0
899+ leap59 0
900+ currentUtcOffsetValid 0
901+ ptpTimescale 1
902+ timeTraceable 0
903+ frequencyTraceable 0
904+ timeSource 0xa0"
905+
906+"GET PRIORITY1"
907+"sending: GET PRIORITY1
908+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT PRIORITY1
909+ priority1 128"
910+
911+"GET PRIORITY2"
912+"sending: GET PRIORITY2
913+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT PRIORITY2
914+ priority2 128"
915+
916+"GET DOMAIN"
917+"sending: GET DOMAIN
918+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT DOMAIN
919+ domainNumber 0"
920+
921+"GET SLAVE_ONLY"
922+"sending: GET SLAVE_ONLY
923+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT SLAVE_ONLY
924+ slaveOnly 0"
925+
926+"GET CLOCK_ACCURACY"
927+"sending: GET CLOCK_ACCURACY
928+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT CLOCK_ACCURACY
929+ clockAccuracy 0xfe"
930+
931+"GET TRACEABILITY_PROPERTIES"
932+"sending: GET TRACEABILITY_PROPERTIES
933+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT TRACEABILITY_PROPERTIES
934+ timeTraceable 0
935+ frequencyTraceable 0"
936+
937+"GET TIMESCALE_PROPERTIES"
938+"sending: GET TIMESCALE_PROPERTIES
939+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT TIMESCALE_PROPERTIES
940+ ptpTimescale 1"
941+
942+"GET TIME_STATUS_NP"
943+"sending: GET TIME_STATUS_NP
944+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT TIME_STATUS_NP
945+ master_offset -?[0-9]+
946+ ingress_time 1262304[0-9]+
947+ cumulativeScaledRateOffset \+0\.000000000
948+ scaledLastGmPhaseChange 0
949+ gmTimeBaseIndicator 0
950+ lastGmPhaseChange 0x0000'0000000000000000\.0000
951+ gmPresent true
952+ gmIdentity 123456\.fffe\.780101"
953+
954+"GET GRANDMASTER_SETTINGS_NP"
955+"sending: GET GRANDMASTER_SETTINGS_NP
956+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT GRANDMASTER_SETTINGS_NP
957+ clockClass 248
958+ clockAccuracy 0xfe
959+ offsetScaledLogVariance 0xffff
960+ currentUtcOffset 3[567]
961+ leap61 0
962+ leap59 0
963+ currentUtcOffsetValid 0
964+ ptpTimescale 1
965+ timeTraceable 0
966+ frequencyTraceable 0
967+ timeSource 0xa0"
968+
969+"GET NULL_MANAGEMENT"
970+"sending: GET NULL_MANAGEMENT
971+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT
972+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT "
973+
974+"GET CLOCK_DESCRIPTION"
975+"sending: GET CLOCK_DESCRIPTION
976+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT CLOCK_DESCRIPTION
977+ clockType 0x4000
978+ physicalLayerProtocol IEEE 802\.3
979+ physicalAddress 12:34:56:78:01:02
980+ protocolAddress 1 192\.168\.123\.2
981+ manufacturerId 00:00:00
982+ productDescription ;;
983+ revisionData ;;
984+ userDescription
985+ profileId 00:1b:19:00:01:00
986+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT CLOCK_DESCRIPTION
987+ clockType 0x4000
988+ physicalLayerProtocol IEEE 802\.3
989+ physicalAddress 12:34:56:78:02:02
990+ protocolAddress 1 192\.168\.124\.2
991+ manufacturerId 00:00:00
992+ productDescription ;;
993+ revisionData ;;
994+ userDescription
995+ profileId 00:1b:19:00:01:00"
996+
997+"GET PORT_DATA_SET"
998+"sending: GET PORT_DATA_SET
999+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT PORT_DATA_SET
1000+ portIdentity 123456\.fffe\.780102-1
1001+ portState SLAVE
1002+ logMinDelayReqInterval 0
1003+ peerMeanPathDelay 0
1004+ logAnnounceInterval 1
1005+ announceReceiptTimeout 3
1006+ logSyncInterval 0
1007+ delayMechanism 1
1008+ logMinPdelayReqInterval 0
1009+ versionNumber 2
1010+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT PORT_DATA_SET
1011+ portIdentity 123456\.fffe\.780102-2
1012+ portState MASTER
1013+ logMinDelayReqInterval 0
1014+ peerMeanPathDelay 0
1015+ logAnnounceInterval 1
1016+ announceReceiptTimeout 3
1017+ logSyncInterval 0
1018+ delayMechanism 1
1019+ logMinPdelayReqInterval 0
1020+ versionNumber 2"
1021+
1022+"GET LOG_ANNOUNCE_INTERVAL"
1023+"sending: GET LOG_ANNOUNCE_INTERVAL
1024+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT LOG_ANNOUNCE_INTERVAL
1025+ logAnnounceInterval 1
1026+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT LOG_ANNOUNCE_INTERVAL
1027+ logAnnounceInterval 1"
1028+
1029+"GET ANNOUNCE_RECEIPT_TIMEOUT"
1030+"sending: GET ANNOUNCE_RECEIPT_TIMEOUT
1031+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT ANNOUNCE_RECEIPT_TIMEOUT
1032+ announceReceiptTimeout 3
1033+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT ANNOUNCE_RECEIPT_TIMEOUT
1034+ announceReceiptTimeout 3"
1035+
1036+"GET LOG_SYNC_INTERVAL"
1037+"sending: GET LOG_SYNC_INTERVAL
1038+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT LOG_SYNC_INTERVAL
1039+ logSyncInterval 0
1040+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT LOG_SYNC_INTERVAL
1041+ logSyncInterval 0"
1042+
1043+"GET VERSION_NUMBER"
1044+"sending: GET VERSION_NUMBER
1045+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT VERSION_NUMBER
1046+ versionNumber 2
1047+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT VERSION_NUMBER
1048+ versionNumber 2"
1049+
1050+"GET DELAY_MECHANISM"
1051+"sending: GET DELAY_MECHANISM
1052+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT DELAY_MECHANISM
1053+ delayMechanism 1
1054+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT DELAY_MECHANISM
1055+ delayMechanism 1"
1056+
1057+"GET LOG_MIN_PDELAY_REQ_INTERVAL"
1058+"sending: GET LOG_MIN_PDELAY_REQ_INTERVAL
1059+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGE?MENT LOG_MIN_PDELAY_REQ_INTERVAL
1060+ logMinPdelayReqInterval 0
1061+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGE?MENT LOG_MIN_PDELAY_REQ_INTERVAL
1062+ logMinPdelayReqInterval 0"
1063+
1064+"GET PORT_DATA_SET_NP"
1065+"sending: GET PORT_DATA_SET_NP
1066+ 123456.fffe.780102-1 seq 0 RESPONSE MANAGE?MENT PORT_DATA_SET_NP
1067+ neighborPropDelayThresh 20000000
1068+ asCapable 1
1069+ 123456.fffe.780102-2 seq 0 RESPONSE MANAGE?MENT PORT_DATA_SET_NP
1070+ neighborPropDelayThresh 20000000
1071+ asCapable 1"
1072+
1073+"GET PORT_STATS_NP"
1074+"sending: GET PORT_STATS_NP
1075+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGEMENT PORT_STATS_NP
1076+ portIdentity 123456\.fffe\.780102-1
1077+ rx_Sync [1234][0-9]
1078+ rx_Delay_Req 0
1079+ rx_Pdelay_Req 0
1080+ rx_Pdelay_Resp 0
1081+ rx_Follow_Up [1234][0-9]
1082+ rx_Delay_Resp [1234][0-9]
1083+ rx_Pdelay_Resp_Follow_Up 0
1084+ rx_Announce [1234][0-9]
1085+ rx_Signaling 0
1086+ rx_Management 0
1087+ tx_Sync 0
1088+ tx_Delay_Req [1234][0-9]
1089+ tx_Pdelay_Req 0
1090+ tx_Pdelay_Resp 0
1091+ tx_Follow_Up 0
1092+ tx_Delay_Resp 0
1093+ tx_Pdelay_Resp_Follow_Up 0
1094+ tx_Announce 0
1095+ tx_Signaling 0
1096+ tx_Management 0
1097+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT PORT_STATS_NP
1098+ portIdentity 123456\.fffe\.780102-2
1099+ rx_Sync 0
1100+ rx_Delay_Req 0
1101+ rx_Pdelay_Req 0
1102+ rx_Pdelay_Resp 0
1103+ rx_Follow_Up 0
1104+ rx_Delay_Resp 0
1105+ rx_Pdelay_Resp_Follow_Up 0
1106+ rx_Announce 0
1107+ rx_Signaling 0
1108+ rx_Management 1
1109+ tx_Sync [1234][0-9]
1110+ tx_Delay_Req 0
1111+ tx_Pdelay_Req 0
1112+ tx_Pdelay_Resp 0
1113+ tx_Follow_Up [1234][0-9]
1114+ tx_Delay_Resp 0
1115+ tx_Pdelay_Resp_Follow_Up 0
1116+ tx_Announce [1234][0-9]
1117+ tx_Signaling 0
1118+ tx_Management 1"
1119+
1120+"GET PORT_SERVICE_STATS_NP"
1121+"sending: GET PORT_SERVICE_STATS_NP
1122+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGEMENT PORT_SERVICE_STATS_NP
1123+ portIdentity 123456\.fffe\.780102-1
1124+ announce_timeout 0
1125+ sync_timeout 0
1126+ delay_timeout [1234][0-9]
1127+ unicast_service_timeout 0
1128+ unicast_request_timeout 0
1129+ master_announce_timeout 0
1130+ master_sync_timeout 0
1131+ qualification_timeout 0
1132+ sync_mismatch 0
1133+ followup_mismatch 0
1134+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT PORT_SERVICE_STATS_NP
1135+ portIdentity 123456\.fffe\.780102-2
1136+ announce_timeout 1
1137+ sync_timeout 0
1138+ delay_timeout 0
1139+ unicast_service_timeout 0
1140+ unicast_request_timeout 0
1141+ master_announce_timeout [1234][0-9]
1142+ master_sync_timeout [1234][0-9]
1143+ qualification_timeout 0
1144+ sync_mismatch 0
1145+ followup_mismatch 0"
1146+"GET UNICAST_MASTER_TABLE_NP"
1147+"sending: GET UNICAST_MASTER_TABLE_NP
1148+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGEMENT UNICAST_MASTER_TABLE_NP
1149+ actual_table_size 0
1150+ BM identity address state clockClass clockQuality offsetScaledLogVariance p1 p2
1151+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT UNICAST_MASTER_TABLE_NP
1152+ actual_table_size 0
1153+ BM identity address state clockClass clockQuality offsetScaledLogVariance p1 p2"
1154+
1155+"GET ALTERNATE_TIME_OFFSET_ENABLE"
1156+"sending: GET ALTERNATE_TIME_OFFSET_ENABLE
1157+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT ALTERNATE_TIME_OFFSET_ENABLE
1158+ keyField 0
1159+ enable 0"
1160+
1161+"GET ALTERNATE_TIME_OFFSET_NAME"
1162+"sending: GET ALTERNATE_TIME_OFFSET_NAME
1163+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT ALTERNATE_TIME_OFFSET_NAME
1164+ keyField 0
1165+ displayName "
1166+
1167+"GET ALTERNATE_TIME_OFFSET_PROPERTIES"
1168+"sending: GET ALTERNATE_TIME_OFFSET_PROPERTIES
1169+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT ALTERNATE_TIME_OFFSET_PROPERTIES
1170+ keyField 0
1171+ currentOffset 0
1172+ jumpSeconds 0
1173+ timeOfNextJump 0"
1174+
1175+"GET POWER_PROFILE_SETTINGS_NP"
1176+"sending: GET POWER_PROFILE_SETTINGS_NP
1177+ 123456.fffe.780102-1 seq 0 RESPONSE MANAGEMENT POWER_PROFILE_SETTINGS_NP
1178+ version 0
1179+ grandmasterID 0x0000
1180+ grandmasterTimeInaccuracy 4294967295
1181+ networkTimeInaccuracy 4294967295
1182+ totalTimeInaccuracy 4294967295
1183+ 123456.fffe.780102-2 seq 0 RESPONSE MANAGEMENT POWER_PROFILE_SETTINGS_NP
1184+ version 0
1185+ grandmasterID 0x0000
1186+ grandmasterTimeInaccuracy 4294967295
1187+ networkTimeInaccuracy 4294967295
1188+ totalTimeInaccuracy 4294967295"
1189+)
1190+
1191+for i in $(seq 0 $[${#requests_replies[*]} / 2 - 1]); do
1192+ pmc_conf=${requests_replies[$[i * 2]]}
1193+ run_ptp4l || test_fail
1194+ if ! check_pmc_output "^${requests_replies[$[i * 2 + 1]]}$"; then
1195+ cat tmp/log.$pmc_node
1196+ test_fail
1197+ fi
1198+done
1199+
1200+requests_replies=(
1201+"SET PRIORITY1 130"
1202+"sending: SET PRIORITY1
1203+ 123456\.fffe\.780102-0 seq 0 RESPONSE MANAGEMENT PRIORITY1
1204+ priority1 130"
1205+
1206+"SET PRIORITY2 130"
1207+"sending: SET PRIORITY2
1208+ 123456\.fffe\.780102-0 seq 0 RESPONSE MANAGEMENT PRIORITY2
1209+ priority2 130"
1210+
1211+"SET GRANDMASTER_SETTINGS_NP clockClass 6 clockAccuracy 0xfd offsetScaledLogVariance 0xfffe currentUtcOffset 50 leap61 1 leap59 0 currentUtcOffsetValid 1 ptpTimescale 0 timeTraceable 1 frequencyTraceable 1 timeSource 0xa1"
1212+"sending: SET GRANDMASTER_SETTINGS_NP
1213+ 123456\.fffe\.780102-0 seq 0 RESPONSE MANAGEMENT GRANDMASTER_SETTINGS_NP
1214+ clockClass 6
1215+ clockAccuracy 0xfd
1216+ offsetScaledLogVariance 0xfffe
1217+ currentUtcOffset 50
1218+ leap61 1
1219+ leap59 0
1220+ currentUtcOffsetValid 1
1221+ ptpTimescale 0
1222+ timeTraceable 1
1223+ frequencyTraceable 1
1224+ timeSource 0xa1"
1225+
1226+"SET SUBSCRIBE_EVENTS_NP duration 1 NOTIFY_PORT_STATE on NOTIFY_TIME_SYNC on NOTIFY_PARENT_DATA_SET on"
1227+"sending: SET SUBSCRIBE_EVENTS_NP
1228+ 123456\.fffe\.780102-0 seq 0 RESPONSE MANAGEMENT SUBSCRIBE_EVENTS_NP
1229+ duration 1
1230+ NOTIFY_PORT_STATE on
1231+ NOTIFY_TIME_SYNC on
1232+ NOTIFY_PARENT_DATA_SET on.*"
1233+
1234+"SET SYNCHRONIZATION_UNCERTAIN_NP 1"
1235+"sending: SET SYNCHRONIZATION_UNCERTAIN_NP
1236+ 123456\.fffe\.780102-0 seq 0 RESPONSE MANAGEMENT SYNCHRONIZATION_UNCERTAIN_NP
1237+ uncertain 1"
1238+
1239+# asCapable is ignored
1240+"SET PORT_DATA_SET_NP neighborPropDelayThresh 1000 asCapable 0"
1241+"sending: SET PORT_DATA_SET_NP
1242+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGEMENT PORT_DATA_SET_NP
1243+ neighborPropDelayThresh 1000
1244+ asCapable 1
1245+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT PORT_DATA_SET_NP
1246+ neighborPropDelayThresh 1000
1247+ asCapable 1"
1248+
1249+"SET ALTERNATE_TIME_OFFSET_ENABLE keyField 3 enable 1"
1250+"sending: SET ALTERNATE_TIME_OFFSET_ENABLE
1251+ 123456\.fffe\.780102-0 seq 0 RESPONSE MANAGEMENT ALTERNATE_TIME_OFFSET_ENABLE
1252+ keyField 3
1253+ enable 1"
1254+
1255+"SET ALTERNATE_TIME_OFFSET_NAME keyField 3 displayName CET"
1256+"sending: SET ALTERNATE_TIME_OFFSET_NAME
1257+ 123456\.fffe\.780102-0 seq 0 RESPONSE MANAGEMENT ALTERNATE_TIME_OFFSET_NAME
1258+ keyField 3
1259+ displayName CET"
1260+
1261+"SET ALTERNATE_TIME_OFFSET_PROPERTIES keyField 3 currentOffset 36000 jumpSeconds -3600 timeOfNextJump 6000000000"
1262+"sending: SET ALTERNATE_TIME_OFFSET_PROPERTIES
1263+ 123456\.fffe\.780102-0 seq 0 RESPONSE MANAGEMENT ALTERNATE_TIME_OFFSET_PROPERTIES
1264+ keyField 3
1265+ currentOffset 36000
1266+ jumpSeconds -3600
1267+ timeOfNextJump 6000000000"
1268+
1269+"SET POWER_PROFILE_SETTINGS_NP version 2 grandmasterID 1 grandmasterTimeInaccuracy 100 networkTimeInaccuracy 100 totalTimeInaccuracy 200"
1270+"sending: SET POWER_PROFILE_SETTINGS_NP
1271+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGEMENT POWER_PROFILE_SETTINGS_NP
1272+ version 2
1273+ grandmasterID 0x0001
1274+ grandmasterTimeInaccuracy 100
1275+ networkTimeInaccuracy 100
1276+ totalTimeInaccuracy 200
1277+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT POWER_PROFILE_SETTINGS_NP
1278+ version 2
1279+ grandmasterID 0x0001
1280+ grandmasterTimeInaccuracy 100
1281+ networkTimeInaccuracy 100
1282+ totalTimeInaccuracy 200"
1283+
1284+"GET PORT_PROPERTIES_NP"
1285+"sending: GET PORT_PROPERTIES_NP
1286+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGEMENT PORT_PROPERTIES_NP
1287+ portIdentity 123456\.fffe\.780102-1
1288+ portState SLAVE
1289+ timestamping HARDWARE
1290+ interface eth0
1291+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT PORT_PROPERTIES_NP
1292+ portIdentity 123456\.fffe\.780102-2
1293+ portState MASTER
1294+ timestamping HARDWARE
1295+ interface eth1"
1296+
1297+"GET PORT_HWCLOCK_NP"
1298+"sending: GET PORT_HWCLOCK_NP
1299+ 123456\.fffe\.780102-1 seq 0 RESPONSE MANAGEMENT PORT_HWCLOCK_NP
1300+ portIdentity 123456\.fffe\.780102-1
1301+ phcIndex 1
1302+ flags 0
1303+ 123456\.fffe\.780102-2 seq 0 RESPONSE MANAGEMENT PORT_HWCLOCK_NP
1304+ portIdentity 123456\.fffe\.780102-2
1305+ phcIndex 1
1306+ flags 0"
1307+)
1308+
1309+for i in $(seq 0 $[${#requests_replies[*]} / 2 - 1]); do
1310+ pmc_conf=${requests_replies[$[i * 2]]}
1311+
1312+ # UDS-RO
1313+ pmc_uds="2:2"
1314+ run_ptp4l || test_fail
1315+ if ! check_pmc_output "RESPONSE MANAGEMENT_ERROR_STATUS"; then
1316+ cat tmp/log.$pmc_node
1317+ test_fail
1318+ fi
1319+
1320+ # UDS-RW
1321+ pmc_uds="2:1"
1322+ run_ptp4l || test_fail
1323+ if ! check_pmc_output "^${requests_replies[$[i * 2 + 1]]}$"; then
1324+ cat tmp/log.$pmc_node
1325+ test_fail
1326+ fi
1327+done
1328+
1329+test_pass
1330diff --git a/debian/tests/linuxptp-testsuite/21-linregservo b/debian/tests/linuxptp-testsuite/21-linregservo
1331new file mode 100755
1332index 0000000..82447aa
1333--- /dev/null
1334+++ b/debian/tests/linuxptp-testsuite/21-linregservo
1335@@ -0,0 +1,38 @@
1336+#!/bin/bash
1337+
1338+. test.common
1339+
1340+test_start "ptp4l and phc2sys with linreg servo"
1341+
1342+wander=1e-9
1343+limit=4000
1344+max_sync_time=2000
1345+
1346+while read jitter time_max_limit freq_max_limit time_rms_limit freq_rms_limit; do
1347+ refclock_jitter=$jitter
1348+ master_conf=""
1349+ slave_conf=""
1350+ phc2sys_conf="-s /dev/ptp0 -O 0 -E linreg"
1351+ nodes=1
1352+ master_nodes="0"
1353+ phc2sys_node=1
1354+ run_test || test_fail
1355+ check_sync || test_fail
1356+
1357+ master_conf="delay_mechanism P2P"
1358+ slave_conf="delay_mechanism P2P
1359+ clock_servo linreg"
1360+ phc2sys_conf=""
1361+ nodes=2
1362+ master_nodes="1"
1363+ phc2sys_node=0
1364+ run_ptp4l || test_fail
1365+ check_sync || test_fail
1366+done <<-EOF
1367+ 1e-5 4.0e-05 4.8e-05 6.1e-06 1.5e-06
1368+ 1e-6 4.2e-06 4.4e-06 7.0e-07 1.8e-07
1369+ 1e-7 5.1e-07 7.5e-07 1.1e-07 3.3e-08
1370+ 1e-8 9.5e-08 9.3e-08 1.9e-08 1.3e-08
1371+EOF
1372+
1373+test_pass
1374diff --git a/debian/tests/linuxptp-testsuite/22-passiveport b/debian/tests/linuxptp-testsuite/22-passiveport
1375new file mode 100755
1376index 0000000..05b2ff1
1377--- /dev/null
1378+++ b/debian/tests/linuxptp-testsuite/22-passiveport
1379@@ -0,0 +1,24 @@
1380+#!/bin/bash
1381+
1382+. test.common
1383+
1384+test_start "ptp4l with passive ports"
1385+
1386+subnets="1 2 | 1 2 | 1 2"
1387+nodes=2
1388+limit=2000
1389+time_max_limit=5e-6
1390+freq_max_limit=5e-6
1391+base_delay=$(cat <<-EOF | tr -d '\n'
1392+ (+ $default_base_delay
1393+ (* subnet 1e-5)
1394+ (* -1 (equal 0.1 subnet 1) (equal 0.1 (min (% (+ time 0) 300) 150) 150))
1395+ (* -1 (equal 0.1 subnet 2) (equal 0.1 (min (% (+ time 100) 300) 150) 150))
1396+ (* -1 (equal 0.1 subnet 3) (equal 0.1 (min (% (+ time 200) 300) 150) 150)))
1397+EOF
1398+)
1399+
1400+run_ptp4l || test_fail
1401+check_sync || test_fail
1402+
1403+test_pass
1404diff --git a/debian/tests/linuxptp-testsuite/23-basedelay b/debian/tests/linuxptp-testsuite/23-basedelay
1405new file mode 100755
1406index 0000000..cb99812
1407--- /dev/null
1408+++ b/debian/tests/linuxptp-testsuite/23-basedelay
1409@@ -0,0 +1,18 @@
1410+#!/bin/bash
1411+
1412+. test.common
1413+
1414+test_start "ptp4l with various base delays"
1415+
1416+max_sync_time=320
1417+update_interval=-4
1418+master_conf="logSyncInterval -4
1419+ logMinDelayReqInterval -4"
1420+
1421+for i in $(seq -7 1 -1); do
1422+ base_delay=$(awk 'BEGIN {print 1e'$i'}')
1423+ run_ptp4l || test_fail
1424+ check_sync || test_fail
1425+done
1426+
1427+test_pass
1428diff --git a/debian/tests/linuxptp-testsuite/24-nsm b/debian/tests/linuxptp-testsuite/24-nsm
1429new file mode 100755
1430index 0000000..ff5343d
1431--- /dev/null
1432+++ b/debian/tests/linuxptp-testsuite/24-nsm
1433@@ -0,0 +1,85 @@
1434+#!/bin/bash
1435+
1436+. test.common
1437+
1438+test_start "nsm monitoring master node and slave node"
1439+nsm_node=3
1440+master_conf="hybrid_e2e 1
1441+net_sync_monitor 1"
1442+slave_conf="hybrid_e2e 1
1443+net_sync_monitor 1"
1444+
1445+requests_replies=(
1446+"NSM 192.168.123.1"
1447+"NSM MEASUREMENT COMPLETE
1448+ offset -?[0-9]+
1449+ portState MASTER
1450+ parentPortAddress 1 192.168.123.1
1451+ parentDataset
1452+ parentPortIdentity 123456.fffe.780101-0
1453+ parentStats 0
1454+ observedParentOffsetScaledLogVariance 0xffff
1455+ observedParentClockPhaseChangeRate 0x7fffffff
1456+ grandmasterPriority1 128
1457+ gm.ClockClass 248
1458+ gm.ClockAccuracy 0xfe
1459+ gm.OffsetScaledLogVariance 0xffff
1460+ grandmasterPriority2 128
1461+ grandmasterIdentity 123456.fffe.780101
1462+ currentDataset
1463+ stepsRemoved 0
1464+ offsetFromMaster 0.0
1465+ meanPathDelay 0.0
1466+ timePropertiesDataset
1467+ currentUtcOffset [0-9]+
1468+ leap61 0
1469+ leap59 0
1470+ currentUtcOffsetValid 0
1471+ ptpTimescale 1
1472+ timeTraceable 0
1473+ frequencyTraceable 0
1474+ timeSource 0xa0
1475+ lastSyncTimestamp 0.000000000"
1476+
1477+"NSM 192.168.123.2"
1478+"NSM MEASUREMENT COMPLETE
1479+ offset -?[0-9]+
1480+ portState SLAVE
1481+ parentPortAddress 1 192.168.123.1
1482+ parentDataset
1483+ parentPortIdentity 123456.fffe.780101-1
1484+ parentStats 0
1485+ observedParentOffsetScaledLogVariance 0xffff
1486+ observedParentClockPhaseChangeRate 0x7fffffff
1487+ grandmasterPriority1 128
1488+ gm.ClockClass 248
1489+ gm.ClockAccuracy 0xfe
1490+ gm.OffsetScaledLogVariance 0xffff
1491+ grandmasterPriority2 128
1492+ grandmasterIdentity 123456.fffe.780101
1493+ currentDataset
1494+ stepsRemoved 1
1495+ offsetFromMaster -?[0-9]+\.[0-9]+
1496+ meanPathDelay [0-9]+\.[0-9]+
1497+ timePropertiesDataset
1498+ currentUtcOffset [0-9]+
1499+ leap61 0
1500+ leap59 0
1501+ currentUtcOffsetValid 0
1502+ ptpTimescale 1
1503+ timeTraceable 0
1504+ frequencyTraceable 0
1505+ timeSource 0xa0
1506+ lastSyncTimestamp [0-9]+\.[0-9]+"
1507+)
1508+
1509+for i in $(seq 0 $[${#requests_replies[*]} / 2 - 1]); do
1510+ nsm_conf=${requests_replies[$[i * 2]]}
1511+ run_ptp4l || test_fail
1512+ if ! check_nsm_output "${requests_replies[$[i * 2 + 1]]}$"; then
1513+ cat tmp/log.$nsm_node
1514+ test_fail
1515+ fi
1516+done
1517+
1518+test_pass
1519diff --git a/debian/tests/linuxptp-testsuite/25-telecomdscmp b/debian/tests/linuxptp-testsuite/25-telecomdscmp
1520new file mode 100755
1521index 0000000..51c9098
1522--- /dev/null
1523+++ b/debian/tests/linuxptp-testsuite/25-telecomdscmp
1524@@ -0,0 +1,42 @@
1525+#!/bin/bash
1526+
1527+. test.common
1528+
1529+test_start "ptp4l with telecom_dscmp and various local priority"
1530+nodes=2
1531+
1532+# Using telecom_dscmp with default local priorities.
1533+# The first node will become master due to portIdentity.
1534+master_conf="dataset_comparison G.8275.x"
1535+slave_conf="dataset_comparison G.8275.x"
1536+
1537+run_ptp4l || test_fail
1538+check_sync || test_fail
1539+
1540+# Using telecom_dscmp with clock localPriority set.
1541+# The first node will now become slave and the second
1542+# master due to the local priority for the clock.
1543+master_nodes="2"
1544+master_conf="dataset_comparison G.8275.x
1545+G.8275.defaultDS.localPriority 127"
1546+slave_conf="dataset_comparison G.8275.x
1547+G.8275.defaultDS.localPriority 129"
1548+slave_start=0.0
1549+
1550+run_ptp4l || test_fail
1551+check_sync || test_fail
1552+
1553+# Using telecom_dscmp with port localPriority set.
1554+# The first node will become slave and the second
1555+# master due to the local priority for the port.
1556+master_nodes="2"
1557+master_conf="dataset_comparison G.8275.x
1558+G.8275.portDS.localPriority 129"
1559+slave_conf="dataset_comparison G.8275.x
1560+G.8275.portDS.localPriority 127"
1561+slave_start=0.0
1562+
1563+run_ptp4l || test_fail
1564+check_sync || test_fail
1565+
1566+test_pass
1567diff --git a/debian/tests/linuxptp-testsuite/26-transparent b/debian/tests/linuxptp-testsuite/26-transparent
1568new file mode 100755
1569index 0000000..fce2c7b
1570--- /dev/null
1571+++ b/debian/tests/linuxptp-testsuite/26-transparent
1572@@ -0,0 +1,43 @@
1573+#!/bin/bash
1574+
1575+. test.common
1576+
1577+test_start "ptp4l with transparent clocks"
1578+
1579+# 1 --- 2 --- 3
1580+# | |
1581+# 4 --- 5 --- 6
1582+subnets="1 2 | 2 3 | 2 4 | 3 5 | 4 5 | 5 6"
1583+nodes=6
1584+max_sync_time=100
1585+
1586+for tc_type in E2E P2P; do
1587+ if [ "$tc_type" == "E2E" ]; then
1588+ time_max_limit=3e-8
1589+ freq_max_limit=2e-8
1590+ delay_correction="(+ delay (* 8e-11 (+ length 42)))"
1591+ else
1592+ time_max_limit=5e-6
1593+ freq_max_limit=5e-6
1594+ delay_correction=""
1595+ fi
1596+ for free_running in 0 1; do
1597+ master_conf="delay_mechanism $tc_type"
1598+ slave_conf="delay_mechanism $tc_type"
1599+ for transparent_nodes in "2" "3 4" "2 3 4 5"; do
1600+ transparent_conf="clock_type ${tc_type}_TC
1601+ free_running $free_running
1602+ delay_mechanism $tc_type"
1603+ [[ $transparent_nodes =~ "2 3 4 5" ]] &&
1604+ transparent_conf+="
1605+ tc_spanning_tree 1"
1606+ [ $free_running -eq 0 ] &&
1607+ free_running_nodes="" ||
1608+ free_running_nodes=$transparent_nodes
1609+ run_ptp4l || test_fail
1610+ check_sync || test_fail
1611+ done
1612+ done
1613+done
1614+
1615+test_pass
1616diff --git a/debian/tests/linuxptp-testsuite/27-masteronly b/debian/tests/linuxptp-testsuite/27-masteronly
1617new file mode 100755
1618index 0000000..3d475b9
1619--- /dev/null
1620+++ b/debian/tests/linuxptp-testsuite/27-masteronly
1621@@ -0,0 +1,27 @@
1622+#!/bin/bash
1623+
1624+. test.common
1625+
1626+test_start "ptp4l with masterOnly option"
1627+
1628+nodes=3
1629+pmc_node=3
1630+
1631+# The masterOnly option is set to prevent the port of the second node
1632+# from entering the SLAVE state. The portState will then become MASTER
1633+# for both first and second node.
1634+slave_conf="masterOnly 1"
1635+pmc_conf="GET PORT_DATA_SET"
1636+
1637+run_ptp4l || test_fail
1638+
1639+expected1="123456\.fffe\.780101-1 seq 0 RESPONSE MANAGEMENT PORT_DATA_SET
1640+ portIdentity 123456\.fffe\.780101-1
1641+ portState MASTER"
1642+expected2="123456\.fffe\.780102-1 seq 0 RESPONSE MANAGEMENT PORT_DATA_SET
1643+ portIdentity 123456\.fffe\.780102-1
1644+ portState MASTER"
1645+check_pmc_output "$expected1" || test_fail
1646+check_pmc_output "$expected2" || test_fail
1647+
1648+test_pass
1649diff --git a/debian/tests/linuxptp-testsuite/28-hybriddm b/debian/tests/linuxptp-testsuite/28-hybriddm
1650new file mode 100755
1651index 0000000..6ae35b7
1652--- /dev/null
1653+++ b/debian/tests/linuxptp-testsuite/28-hybriddm
1654@@ -0,0 +1,14 @@
1655+#!/bin/bash
1656+
1657+. test.common
1658+
1659+test_start "ptp4l with hybrid delay mechanism"
1660+
1661+nodes=3
1662+master_conf="hybrid_e2e 1"
1663+slave_conf="hybrid_e2e 1"
1664+
1665+run_ptp4l || test_fail
1666+check_sync || test_fail
1667+
1668+test_pass
1669diff --git a/debian/tests/linuxptp-testsuite/29-unicast b/debian/tests/linuxptp-testsuite/29-unicast
1670new file mode 100755
1671index 0000000..020addb
1672--- /dev/null
1673+++ b/debian/tests/linuxptp-testsuite/29-unicast
1674@@ -0,0 +1,158 @@
1675+#!/bin/bash
1676+
1677+. test.common
1678+
1679+test_start "ptp4l with unicast-only messaging"
1680+
1681+# 1 GM, 2 unicast clients
1682+nodes=3
1683+master_conf="hybrid_e2e 1
1684+inhibit_multicast_service 1
1685+unicast_listen 1"
1686+slave_conf="
1687+inhibit_multicast_service 1
1688+unicast_req_duration 60
1689+unicast_master_table 1
1690+
1691+[unicast_master_table]
1692+table_id 1
1693+logQueryInterval 2
1694+UDPv4 192.168.123.1"
1695+
1696+run_ptp4l || test_fail
1697+check_sync || test_fail
1698+
1699+# 2 GMs, 1 unicast client, first one becomes best master because of portIdentity
1700+nodes=4
1701+master_nodes="1 2"
1702+
1703+max_sync_time=100
1704+
1705+master_conf="hybrid_e2e 1
1706+inhibit_multicast_service 1
1707+unicast_listen 1"
1708+slave_conf="
1709+inhibit_multicast_service 1
1710+unicast_req_duration 60
1711+unicast_master_table 1
1712+slaveOnly 1
1713+
1714+[unicast_master_table]
1715+table_id 1
1716+logQueryInterval 2
1717+UDPv4 192.168.123.1
1718+UDPv4 192.168.123.2"
1719+
1720+run_ptp4l || test_fail
1721+check_sync || test_fail
1722+
1723+
1724+# 3 GMs, one client. Second node will be selected as best master, then
1725+# the first node will start and become best master due to portIdentity.
1726+
1727+nodes=4
1728+master_nodes="1 2 3"
1729+node_start[1]=100
1730+max_sync_time=200
1731+master_conf="hybrid_e2e 1
1732+inhibit_multicast_service 1
1733+unicast_listen 1"
1734+slave_conf="
1735+inhibit_multicast_service 1
1736+unicast_req_duration 60
1737+unicast_master_table 1
1738+slaveOnly 1
1739+
1740+[unicast_master_table]
1741+table_id 1
1742+logQueryInterval 2
1743+UDPv4 192.168.123.1
1744+UDPv4 192.168.123.2
1745+UDPv4 192.168.123.3"
1746+
1747+run_ptp4l || test_fail
1748+check_sync || test_fail
1749+
1750+check_any_log_message 4 "selected best master clock" "123456\.fffe\.78..02" || test_fail
1751+check_last_log_message 4 "selected best master clock" "123456\.fffe\.78..01" || test_fail
1752+
1753+# First node will be selected as best master, then it will go offline and
1754+# the second node will become best master due to portIdentity.
1755+
1756+node_start[1]=0
1757+# (* -1 (equal 0.1 from 1) (equal 0.1 (min time 100) 100)) means that
1758+# negative delay applies when node is 1 and time is over 100s
1759+base_delay=$(cat <<-EOF | tr -d '\n'
1760+ (+ $default_base_delay
1761+ (* -1 (equal 0.1 from 1) (equal 0.1 (min time 100) 100)))
1762+EOF
1763+)
1764+
1765+run_ptp4l || test_fail
1766+check_sync || test_fail
1767+
1768+check_any_log_message 4 "selected best master clock" "123456\.fffe\.78..01" || test_fail
1769+check_last_log_message 4 "selected best master clock" "123456\.fffe\.78..02" || test_fail
1770+
1771+# First node will be selected as best master, then it will stop and
1772+# the second node will become best master due to portIdentity.
1773+# Finally, second node will also leave, and third one becomes only master.
1774+
1775+# (* -1 (equal 0.1 from 1) (equal 0.1 (min time 100) 100)) means that
1776+# negative delay applies when node is 1 and time is over 100s
1777+# (* -1 (equal 0.1 from 2) (equal 0.1 (min time 150) 150)) means that
1778+# negative delay applies when node is 2 and time is over 150s
1779+base_delay=$(cat <<-EOF | tr -d '\n'
1780+ (+ $default_base_delay
1781+ (* -1 (equal 0.1 from 1) (equal 0.1 (min time 100) 100))
1782+ (* -1 (equal 0.1 from 2) (equal 0.1 (min time 150) 150)))
1783+EOF
1784+)
1785+
1786+run_ptp4l || test_fail
1787+check_sync || test_fail
1788+
1789+check_any_log_message 4 "selected best master clock" "123456\.fffe\.78..01" || test_fail
1790+check_any_log_message 4 "selected best master clock" "123456\.fffe\.78..02" || test_fail
1791+check_last_log_message 4 "selected best master clock" "123456\.fffe\.78..03" || test_fail
1792+
1793+
1794+# First node will be selected as best master, then it will stop and
1795+# the second node will become best master due to portIdentity,
1796+# then first one comes back and becomes master again.
1797+
1798+# we lower the expectations because of all the constant switchovers
1799+time_max_limit=1e-5
1800+time_rms_limit=1e-5
1801+freq_max_limit=1e-5
1802+freq_rms_limit=1e-5
1803+
1804+# we have negative delay (node being offline)
1805+# if the packet is sent from node 1,
1806+# and time is in the intervals of (150, 200] and (350, 400] seconds.
1807+# Delay of $default_base_delay applies otherwise.
1808+# Which translates to the node 1 appearing offline twice,
1809+# and still being re-selected as best master in the end.
1810+
1811+# (equal 0.1 from 1) selects 1st node.
1812+# (% time 200) splits our 500s run time into 200s, 200s, 100s chunks.
1813+# (min (% time 200) 150) selects min between 150 and time % 200,
1814+# splitting each 200s chunk into intervals <=150s and >150s.
1815+#
1816+# (equal 0.1 (min (% time 200) 150) 150) checks if the chunked time is >150s
1817+base_delay=$(cat <<-EOF | tr -d '\n'
1818+ (+ $default_base_delay
1819+ (* -1
1820+ (equal 0.1 from 1)
1821+ (equal 0.1
1822+ (min (% time 200) 150) 150)))
1823+EOF
1824+)
1825+
1826+run_ptp4l || test_fail
1827+check_sync || test_fail
1828+
1829+check_any_log_message 4 "selected best master clock" "123456\.fffe\.78..02" || test_fail
1830+check_last_log_message 4 "selected best master clock" "123456\.fffe\.78..01" || test_fail
1831+
1832+test_pass
1833diff --git a/debian/tests/linuxptp-testsuite/30-telecombmca b/debian/tests/linuxptp-testsuite/30-telecombmca
1834new file mode 100755
1835index 0000000..d32b300
1836--- /dev/null
1837+++ b/debian/tests/linuxptp-testsuite/30-telecombmca
1838@@ -0,0 +1,56 @@
1839+#!/bin/bash
1840+
1841+. test.common
1842+
1843+test_start "ptp4l with telecom BMCA"
1844+
1845+# 1 --> 3 --> 5 ->-
1846+# ^ ^ \
1847+# | | 7
1848+# v v /
1849+# 2 --> 4 --> 6 ->-
1850+
1851+subnets="1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 7 | 3 4 | 5 6"
1852+nodes=7
1853+max_sync_time=100
1854+time_max_limit=5e-6
1855+freq_max_limit=5e-6
1856+master_nodes="1 2"
1857+master_conf="clockClass 6"
1858+slave_conf="dataset_comparison G.8275.x"
1859+
1860+extra_node_confs[1]="masterOnly 1"
1861+extra_node_confs[2]="masterOnly 1"
1862+extra_node_confs[3]="
1863+[eth0]
1864+G.8275.portDS.localPriority 127
1865+[eth2]
1866+masterOnly 1"
1867+extra_node_confs[4]="
1868+[eth1]
1869+G.8275.portDS.localPriority 127
1870+[eth3]
1871+masterOnly 1"
1872+extra_node_confs[5]="
1873+[eth2]
1874+G.8275.portDS.localPriority 127
1875+[eth4]
1876+masterOnly 1"
1877+extra_node_confs[6]="
1878+[eth3]
1879+G.8275.portDS.localPriority 127
1880+[eth5]
1881+masterOnly 1"
1882+extra_node_confs[7]="slaveOnly 1"
1883+
1884+run_ptp4l || test_fail
1885+check_sync || test_fail
1886+
1887+for i in 3 5 7; do
1888+ check_last_log_message $i "selected best master clock" "123456\.fffe\.78..01" || test_fail
1889+done
1890+for i in 4 6; do
1891+ check_last_log_message $i "selected best master clock" "123456\.fffe\.78..02" || test_fail
1892+done
1893+
1894+test_pass
1895diff --git a/debian/tests/linuxptp-testsuite/31-leapsecond b/debian/tests/linuxptp-testsuite/31-leapsecond
1896new file mode 100755
1897index 0000000..dc39cbb
1898--- /dev/null
1899+++ b/debian/tests/linuxptp-testsuite/31-leapsecond
1900@@ -0,0 +1,100 @@
1901+#!/bin/bash
1902+
1903+. test.common
1904+
1905+test_start "ptp4l and phc2sys with leap second"
1906+
1907+export CLKNETSIM_START_DATE=$(TZ=UTC date -d 'Dec 31 2030 0:00:00' +'%s')
1908+
1909+limit=$[60 * 3600]
1910+leap_start=$[24 * 3600]
1911+utc_offset=37
1912+time_max_limit=5e-3
1913+time_rms_limit=1e-3
1914+freq_max_limit=5e-6
1915+freq_rms_limit=2e-6
1916+
1917+base_conf="logAnnounceInterval 10
1918+logSyncInterval 10
1919+logMinDelayReqInterval 10"
1920+
1921+pmc_node=3
1922+pmc_uds="1:1"
1923+pmc_start=$[12 * 3600]
1924+
1925+phc2sys_node=4
1926+phc2sys_uds="2:1"
1927+phc2sys_conf="-a -r -R 0.01 -E linreg"
1928+phc2sys_phc_base=2
1929+phc2sys_phc_swap=1
1930+
1931+for leap in "+1" "-1"; do
1932+ for master_ts in "software" "hardware"; do
1933+ for slave_ts in "software" "hardware"; do
1934+ master_conf="$base_conf
1935+ time_stamping $master_ts"
1936+ slave_conf="$base_conf
1937+ time_stamping $slave_ts
1938+ clock_servo linreg"
1939+
1940+ case "$master_ts+$slave_ts" in
1941+ software+software)
1942+ nodes=3
1943+ min_sync_time=$[$leap_start - 1]
1944+ max_sync_time=$[$leap_start]
1945+ step1=$leap
1946+ step2=$[-$leap]
1947+ ptp_timescale=0
1948+ refclock_offset=0.0
1949+ ;;
1950+ software+hardware)
1951+ nodes=4
1952+ min_sync_time=$[$leap_start + 1000]
1953+ # This should be much smaller, but
1954+ # there is no reliable way to limit
1955+ # the number of points of the servo
1956+ max_sync_time=$[$leap_start + 30000]
1957+ step1=$leap
1958+ step2=$[-$leap]
1959+ ptp_timescale=0
1960+ refclock_offset=0.0
1961+ ;;
1962+ hardware+software)
1963+ nodes=3
1964+ min_sync_time=$[$leap_start - 1]
1965+ max_sync_time=$[$leap_start]
1966+ step1=$[$utc_offset + $leap]
1967+ step2=0
1968+ ptp_timescale=1
1969+ refclock_offset=0.0
1970+ ;;
1971+ hardware+hardware)
1972+ nodes=4
1973+ min_sync_time=11000
1974+ max_sync_time=$[$leap_start]
1975+ step1=0
1976+ step2=0
1977+ ptp_timescale=1
1978+ refclock_offset=$[-($utc_offset + $leap)]
1979+ ;;
1980+ esac
1981+
1982+ case $leap in
1983+ +1)
1984+ leap_conf="leap61 1 leap59 0"
1985+ ;;
1986+ -1)
1987+ leap_conf="leap61 0 leap59 1"
1988+ ;;
1989+ esac
1990+
1991+ master_step="(+ (* $step1 (equal 0.1 (sum 1.0) 1)) (* $step2 (equal 0.1 (sum 1.0) 86400)))"
1992+ pmc_conf="SET GRANDMASTER_SETTINGS_NP clockClass 6 clockAccuracy 0xfe offsetScaledLogVariance 0xffff currentUtcOffset $utc_offset $leap_conf currentUtcOffsetValid 1 ptpTimescale $ptp_timescale timeTraceable 1 frequencyTraceable 1 timeSource 0xa1"
1993+
1994+ run_ptp4l || test_fail
1995+ check_sync || test_fail
1996+ done
1997+ done
1998+done
1999+
2000+test_pass
2001diff --git a/debian/tests/linuxptp-testsuite/32-classthreshold b/debian/tests/linuxptp-testsuite/32-classthreshold
2002new file mode 100755
2003index 0000000..8d7251e
2004--- /dev/null
2005+++ b/debian/tests/linuxptp-testsuite/32-classthreshold
2006@@ -0,0 +1,22 @@
2007+#!/bin/bash
2008+
2009+. test.common
2010+
2011+test_start "ptp4l with clock_class_threshold option"
2012+
2013+master_conf="clockClass 6"
2014+slave_conf="clock_class_threshold 7"
2015+run_ptp4l || test_fail
2016+check_sync || test_fail
2017+
2018+master_conf="clockClass 7"
2019+slave_conf="clock_class_threshold 7"
2020+run_ptp4l || test_fail
2021+check_sync || test_fail
2022+
2023+master_conf="clockClass 140"
2024+slave_conf="clock_class_threshold 7"
2025+run_ptp4l || test_fail
2026+check_sync && test_fail
2027+
2028+test_pass
2029diff --git a/debian/tests/linuxptp-testsuite/33-power b/debian/tests/linuxptp-testsuite/33-power
2030new file mode 100755
2031index 0000000..a7c0485
2032--- /dev/null
2033+++ b/debian/tests/linuxptp-testsuite/33-power
2034@@ -0,0 +1,24 @@
2035+#!/bin/bash
2036+
2037+. test.common
2038+
2039+test_start "ptp4l with power profile"
2040+
2041+nodes=3
2042+pmc_node=3
2043+
2044+master_conf="power_profile.version 2017"
2045+pmc_conf="SET ALTERNATE_TIME_OFFSET_ENABLE keyField 2 enable 1
2046+SET ALTERNATE_TIME_OFFSET_NAME keyField 2 displayName CET
2047+SET ALTERNATE_TIME_OFFSET_PROPERTIES keyField 2 currentOffset 36000 jumpSeconds -3600 timeOfNextJump 6000000000"
2048+pmc_uds="1:1"
2049+log_packets=1
2050+
2051+run_ptp4l || test_fail
2052+check_sync || test_fail
2053+
2054+test_message 2 0 "checking length of announce message:"
2055+grep ' 1 2 .* 320 ' tmp/log.packets | \
2056+ awk '{ print $8 }' | grep -q 110 && test_ok || { test_bad; test_fail; }
2057+
2058+test_pass
2059diff --git a/debian/tests/linuxptp-testsuite/36-automotive b/debian/tests/linuxptp-testsuite/36-automotive
2060new file mode 100755
2061index 0000000..b8d2dec
2062--- /dev/null
2063+++ b/debian/tests/linuxptp-testsuite/36-automotive
2064@@ -0,0 +1,57 @@
2065+#!/bin/bash
2066+
2067+. test.common
2068+
2069+test_start "ptp4l with Automotive Profile"
2070+
2071+nodes=2
2072+max_sync_time=100
2073+
2074+# Automotive Profile options carried over from gPTP, common between master and slaves
2075+common_confs="
2076+gmCapable 1
2077+priority1 248
2078+priority2 248
2079+logSyncInterval -3
2080+syncReceiptTimeout 3
2081+neighborPropDelayThresh 800
2082+min_neighbor_prop_delay -20000000
2083+assume_two_step 1
2084+path_trace_enabled 1
2085+follow_up_info 1
2086+transportSpecific 0x1
2087+ptp_dst_mac 01:80:C2:00:00:0E
2088+inhibit_announce 1
2089+delay_mechanism P2P
2090+
2091+BMCA noop
2092+inhibit_announce 1
2093+asCapable true
2094+"
2095+
2096+# Option not added.
2097+# network_transport L2 # The default is UDPv4. clknetsim does not support L2.
2098+
2099+# Automotive Profile Master specific options
2100+master_conf="$common_confs
2101+masterOnly 1
2102+inhibit_delay_req 1
2103+"
2104+
2105+# Automotive Profile Slave specific options
2106+slave_conf="$common_confs
2107+slaveOnly 1
2108+ignore_source_id 1
2109+
2110+step_threshold 1
2111+operLogSyncInterval 0
2112+operLogPdelayReqInterval 2
2113+msg_interval_request 1
2114+servo_offset_threshold 30
2115+servo_num_offset_values 10
2116+"
2117+
2118+run_ptp4l || test_fail
2119+check_sync || test_fail
2120+
2121+test_pass
2122diff --git a/debian/tests/linuxptp-testsuite/COPYING b/debian/tests/linuxptp-testsuite/COPYING
2123new file mode 100644
2124index 0000000..d159169
2125--- /dev/null
2126+++ b/debian/tests/linuxptp-testsuite/COPYING
2127@@ -0,0 +1,339 @@
2128+ GNU GENERAL PUBLIC LICENSE
2129+ Version 2, June 1991
2130+
2131+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
2132+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2133+ Everyone is permitted to copy and distribute verbatim copies
2134+ of this license document, but changing it is not allowed.
2135+
2136+ Preamble
2137+
2138+ The licenses for most software are designed to take away your
2139+freedom to share and change it. By contrast, the GNU General Public
2140+License is intended to guarantee your freedom to share and change free
2141+software--to make sure the software is free for all its users. This
2142+General Public License applies to most of the Free Software
2143+Foundation's software and to any other program whose authors commit to
2144+using it. (Some other Free Software Foundation software is covered by
2145+the GNU Lesser General Public License instead.) You can apply it to
2146+your programs, too.
2147+
2148+ When we speak of free software, we are referring to freedom, not
2149+price. Our General Public Licenses are designed to make sure that you
2150+have the freedom to distribute copies of free software (and charge for
2151+this service if you wish), that you receive source code or can get it
2152+if you want it, that you can change the software or use pieces of it
2153+in new free programs; and that you know you can do these things.
2154+
2155+ To protect your rights, we need to make restrictions that forbid
2156+anyone to deny you these rights or to ask you to surrender the rights.
2157+These restrictions translate to certain responsibilities for you if you
2158+distribute copies of the software, or if you modify it.
2159+
2160+ For example, if you distribute copies of such a program, whether
2161+gratis or for a fee, you must give the recipients all the rights that
2162+you have. You must make sure that they, too, receive or can get the
2163+source code. And you must show them these terms so they know their
2164+rights.
2165+
2166+ We protect your rights with two steps: (1) copyright the software, and
2167+(2) offer you this license which gives you legal permission to copy,
2168+distribute and/or modify the software.
2169+
2170+ Also, for each author's protection and ours, we want to make certain
2171+that everyone understands that there is no warranty for this free
2172+software. If the software is modified by someone else and passed on, we
2173+want its recipients to know that what they have is not the original, so
2174+that any problems introduced by others will not reflect on the original
2175+authors' reputations.
2176+
2177+ Finally, any free program is threatened constantly by software
2178+patents. We wish to avoid the danger that redistributors of a free
2179+program will individually obtain patent licenses, in effect making the
2180+program proprietary. To prevent this, we have made it clear that any
2181+patent must be licensed for everyone's free use or not licensed at all.
2182+
2183+ The precise terms and conditions for copying, distribution and
2184+modification follow.
2185+
2186+ GNU GENERAL PUBLIC LICENSE
2187+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
2188+
2189+ 0. This License applies to any program or other work which contains
2190+a notice placed by the copyright holder saying it may be distributed
2191+under the terms of this General Public License. The "Program", below,
2192+refers to any such program or work, and a "work based on the Program"
2193+means either the Program or any derivative work under copyright law:
2194+that is to say, a work containing the Program or a portion of it,
2195+either verbatim or with modifications and/or translated into another
2196+language. (Hereinafter, translation is included without limitation in
2197+the term "modification".) Each licensee is addressed as "you".
2198+
2199+Activities other than copying, distribution and modification are not
2200+covered by this License; they are outside its scope. The act of
2201+running the Program is not restricted, and the output from the Program
2202+is covered only if its contents constitute a work based on the
2203+Program (independent of having been made by running the Program).
2204+Whether that is true depends on what the Program does.
2205+
2206+ 1. You may copy and distribute verbatim copies of the Program's
2207+source code as you receive it, in any medium, provided that you
2208+conspicuously and appropriately publish on each copy an appropriate
2209+copyright notice and disclaimer of warranty; keep intact all the
2210+notices that refer to this License and to the absence of any warranty;
2211+and give any other recipients of the Program a copy of this License
2212+along with the Program.
2213+
2214+You may charge a fee for the physical act of transferring a copy, and
2215+you may at your option offer warranty protection in exchange for a fee.
2216+
2217+ 2. You may modify your copy or copies of the Program or any portion
2218+of it, thus forming a work based on the Program, and copy and
2219+distribute such modifications or work under the terms of Section 1
2220+above, provided that you also meet all of these conditions:
2221+
2222+ a) You must cause the modified files to carry prominent notices
2223+ stating that you changed the files and the date of any change.
2224+
2225+ b) You must cause any work that you distribute or publish, that in
2226+ whole or in part contains or is derived from the Program or any
2227+ part thereof, to be licensed as a whole at no charge to all third
2228+ parties under the terms of this License.
2229+
2230+ c) If the modified program normally reads commands interactively
2231+ when run, you must cause it, when started running for such
2232+ interactive use in the most ordinary way, to print or display an
2233+ announcement including an appropriate copyright notice and a
2234+ notice that there is no warranty (or else, saying that you provide
2235+ a warranty) and that users may redistribute the program under
2236+ these conditions, and telling the user how to view a copy of this
2237+ License. (Exception: if the Program itself is interactive but
2238+ does not normally print such an announcement, your work based on
2239+ the Program is not required to print an announcement.)
2240+
2241+These requirements apply to the modified work as a whole. If
2242+identifiable sections of that work are not derived from the Program,
2243+and can be reasonably considered independent and separate works in
2244+themselves, then this License, and its terms, do not apply to those
2245+sections when you distribute them as separate works. But when you
2246+distribute the same sections as part of a whole which is a work based
2247+on the Program, the distribution of the whole must be on the terms of
2248+this License, whose permissions for other licensees extend to the
2249+entire whole, and thus to each and every part regardless of who wrote it.
2250+
2251+Thus, it is not the intent of this section to claim rights or contest
2252+your rights to work written entirely by you; rather, the intent is to
2253+exercise the right to control the distribution of derivative or
2254+collective works based on the Program.
2255+
2256+In addition, mere aggregation of another work not based on the Program
2257+with the Program (or with a work based on the Program) on a volume of
2258+a storage or distribution medium does not bring the other work under
2259+the scope of this License.
2260+
2261+ 3. You may copy and distribute the Program (or a work based on it,
2262+under Section 2) in object code or executable form under the terms of
2263+Sections 1 and 2 above provided that you also do one of the following:
2264+
2265+ a) Accompany it with the complete corresponding machine-readable
2266+ source code, which must be distributed under the terms of Sections
2267+ 1 and 2 above on a medium customarily used for software interchange; or,
2268+
2269+ b) Accompany it with a written offer, valid for at least three
2270+ years, to give any third party, for a charge no more than your
2271+ cost of physically performing source distribution, a complete
2272+ machine-readable copy of the corresponding source code, to be
2273+ distributed under the terms of Sections 1 and 2 above on a medium
2274+ customarily used for software interchange; or,
2275+
2276+ c) Accompany it with the information you received as to the offer
2277+ to distribute corresponding source code. (This alternative is
2278+ allowed only for noncommercial distribution and only if you
2279+ received the program in object code or executable form with such
2280+ an offer, in accord with Subsection b above.)
2281+
2282+The source code for a work means the preferred form of the work for
2283+making modifications to it. For an executable work, complete source
2284+code means all the source code for all modules it contains, plus any
2285+associated interface definition files, plus the scripts used to
2286+control compilation and installation of the executable. However, as a
2287+special exception, the source code distributed need not include
2288+anything that is normally distributed (in either source or binary
2289+form) with the major components (compiler, kernel, and so on) of the
2290+operating system on which the executable runs, unless that component
2291+itself accompanies the executable.
2292+
2293+If distribution of executable or object code is made by offering
2294+access to copy from a designated place, then offering equivalent
2295+access to copy the source code from the same place counts as
2296+distribution of the source code, even though third parties are not
2297+compelled to copy the source along with the object code.
2298+
2299+ 4. You may not copy, modify, sublicense, or distribute the Program
2300+except as expressly provided under this License. Any attempt
2301+otherwise to copy, modify, sublicense or distribute the Program is
2302+void, and will automatically terminate your rights under this License.
2303+However, parties who have received copies, or rights, from you under
2304+this License will not have their licenses terminated so long as such
2305+parties remain in full compliance.
2306+
2307+ 5. You are not required to accept this License, since you have not
2308+signed it. However, nothing else grants you permission to modify or
2309+distribute the Program or its derivative works. These actions are
2310+prohibited by law if you do not accept this License. Therefore, by
2311+modifying or distributing the Program (or any work based on the
2312+Program), you indicate your acceptance of this License to do so, and
2313+all its terms and conditions for copying, distributing or modifying
2314+the Program or works based on it.
2315+
2316+ 6. Each time you redistribute the Program (or any work based on the
2317+Program), the recipient automatically receives a license from the
2318+original licensor to copy, distribute or modify the Program subject to
2319+these terms and conditions. You may not impose any further
2320+restrictions on the recipients' exercise of the rights granted herein.
2321+You are not responsible for enforcing compliance by third parties to
2322+this License.
2323+
2324+ 7. If, as a consequence of a court judgment or allegation of patent
2325+infringement or for any other reason (not limited to patent issues),
2326+conditions are imposed on you (whether by court order, agreement or
2327+otherwise) that contradict the conditions of this License, they do not
2328+excuse you from the conditions of this License. If you cannot
2329+distribute so as to satisfy simultaneously your obligations under this
2330+License and any other pertinent obligations, then as a consequence you
2331+may not distribute the Program at all. For example, if a patent
2332+license would not permit royalty-free redistribution of the Program by
2333+all those who receive copies directly or indirectly through you, then
2334+the only way you could satisfy both it and this License would be to
2335+refrain entirely from distribution of the Program.
2336+
2337+If any portion of this section is held invalid or unenforceable under
2338+any particular circumstance, the balance of the section is intended to
2339+apply and the section as a whole is intended to apply in other
2340+circumstances.
2341+
2342+It is not the purpose of this section to induce you to infringe any
2343+patents or other property right claims or to contest validity of any
2344+such claims; this section has the sole purpose of protecting the
2345+integrity of the free software distribution system, which is
2346+implemented by public license practices. Many people have made
2347+generous contributions to the wide range of software distributed
2348+through that system in reliance on consistent application of that
2349+system; it is up to the author/donor to decide if he or she is willing
2350+to distribute software through any other system and a licensee cannot
2351+impose that choice.
2352+
2353+This section is intended to make thoroughly clear what is believed to
2354+be a consequence of the rest of this License.
2355+
2356+ 8. If the distribution and/or use of the Program is restricted in
2357+certain countries either by patents or by copyrighted interfaces, the
2358+original copyright holder who places the Program under this License
2359+may add an explicit geographical distribution limitation excluding
2360+those countries, so that distribution is permitted only in or among
2361+countries not thus excluded. In such case, this License incorporates
2362+the limitation as if written in the body of this License.
2363+
2364+ 9. The Free Software Foundation may publish revised and/or new versions
2365+of the General Public License from time to time. Such new versions will
2366+be similar in spirit to the present version, but may differ in detail to
2367+address new problems or concerns.
2368+
2369+Each version is given a distinguishing version number. If the Program
2370+specifies a version number of this License which applies to it and "any
2371+later version", you have the option of following the terms and conditions
2372+either of that version or of any later version published by the Free
2373+Software Foundation. If the Program does not specify a version number of
2374+this License, you may choose any version ever published by the Free Software
2375+Foundation.
2376+
2377+ 10. If you wish to incorporate parts of the Program into other free
2378+programs whose distribution conditions are different, write to the author
2379+to ask for permission. For software which is copyrighted by the Free
2380+Software Foundation, write to the Free Software Foundation; we sometimes
2381+make exceptions for this. Our decision will be guided by the two goals
2382+of preserving the free status of all derivatives of our free software and
2383+of promoting the sharing and reuse of software generally.
2384+
2385+ NO WARRANTY
2386+
2387+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
2388+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
2389+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
2390+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
2391+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2392+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
2393+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
2394+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
2395+REPAIR OR CORRECTION.
2396+
2397+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
2398+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
2399+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
2400+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
2401+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
2402+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
2403+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
2404+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
2405+POSSIBILITY OF SUCH DAMAGES.
2406+
2407+ END OF TERMS AND CONDITIONS
2408+
2409+ How to Apply These Terms to Your New Programs
2410+
2411+ If you develop a new program, and you want it to be of the greatest
2412+possible use to the public, the best way to achieve this is to make it
2413+free software which everyone can redistribute and change under these terms.
2414+
2415+ To do so, attach the following notices to the program. It is safest
2416+to attach them to the start of each source file to most effectively
2417+convey the exclusion of warranty; and each file should have at least
2418+the "copyright" line and a pointer to where the full notice is found.
2419+
2420+ <one line to give the program's name and a brief idea of what it does.>
2421+ Copyright (C) <year> <name of author>
2422+
2423+ This program is free software; you can redistribute it and/or modify
2424+ it under the terms of the GNU General Public License as published by
2425+ the Free Software Foundation; either version 2 of the License, or
2426+ (at your option) any later version.
2427+
2428+ This program is distributed in the hope that it will be useful,
2429+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2430+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2431+ GNU General Public License for more details.
2432+
2433+ You should have received a copy of the GNU General Public License along
2434+ with this program; if not, write to the Free Software Foundation, Inc.,
2435+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2436+
2437+Also add information on how to contact you by electronic and paper mail.
2438+
2439+If the program is interactive, make it output a short notice like this
2440+when it starts in an interactive mode:
2441+
2442+ Gnomovision version 69, Copyright (C) year name of author
2443+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
2444+ This is free software, and you are welcome to redistribute it
2445+ under certain conditions; type `show c' for details.
2446+
2447+The hypothetical commands `show w' and `show c' should show the appropriate
2448+parts of the General Public License. Of course, the commands you use may
2449+be called something other than `show w' and `show c'; they could even be
2450+mouse-clicks or menu items--whatever suits your program.
2451+
2452+You should also get your employer (if you work as a programmer) or your
2453+school, if any, to sign a "copyright disclaimer" for the program, if
2454+necessary. Here is a sample; alter the names:
2455+
2456+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
2457+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
2458+
2459+ <signature of Ty Coon>, 1 April 1989
2460+ Ty Coon, President of Vice
2461+
2462+This General Public License does not permit incorporating your program into
2463+proprietary programs. If your program is a subroutine library, you may
2464+consider it more useful to permit linking proprietary applications with the
2465+library. If this is what you want to do, use the GNU Lesser General
2466+Public License instead of this License.
2467diff --git a/debian/tests/linuxptp-testsuite/README b/debian/tests/linuxptp-testsuite/README
2468new file mode 100644
2469index 0000000..65c67eb
2470--- /dev/null
2471+++ b/debian/tests/linuxptp-testsuite/README
2472@@ -0,0 +1,18 @@
2473+linuxptp-testsuite
2474+==================
2475+
2476+This is a set of tests developed for linuxptp. It uses the clknetsim simulator
2477+to run the tests quickly and with reproducible results.
2478+
2479+Links
2480+-----
2481+- http://linuxptp.sourceforge.net/
2482+- https://github.com/mlichvar/clknetsim
2483+
2484+Author
2485+------
2486+Miroslav Lichvar <mlichvar@redhat.com>
2487+
2488+License
2489+-------
2490+GPLv2+
2491diff --git a/debian/tests/linuxptp-testsuite/run b/debian/tests/linuxptp-testsuite/run
2492new file mode 100755
2493index 0000000..18f4f46
2494--- /dev/null
2495+++ b/debian/tests/linuxptp-testsuite/run
2496@@ -0,0 +1,18 @@
2497+#!/bin/bash
2498+
2499+passed=() failed=()
2500+
2501+[ $# -gt 0 ] && tests=($@) || tests=([0-9][0-9]-*[^_])
2502+
2503+for test in "${tests[@]}"; do
2504+ echo "$test ($[${#passed[@]} + ${#failed[@]} + 1]/${#tests[@]})"
2505+ ./$test && passed=(${passed[@]} $test) || failed=(${failed[@]} $test)
2506+ echo
2507+done
2508+
2509+echo "SUMMARY:"
2510+echo " TOTAL $[${#passed[@]} + ${#failed[@]}]"
2511+echo " PASSED ${#passed[@]}"
2512+echo " FAILED ${#failed[@]} (${failed[@]})"
2513+
2514+[ ${#failed} -eq 0 ]
2515diff --git a/debian/tests/linuxptp-testsuite/test.common b/debian/tests/linuxptp-testsuite/test.common
2516new file mode 100644
2517index 0000000..f5f325c
2518--- /dev/null
2519+++ b/debian/tests/linuxptp-testsuite/test.common
2520@@ -0,0 +1,367 @@
2521+# Copyright (C) 2013 Miroslav Lichvar <mlichvar@redhat.com>
2522+#
2523+# This program is free software; you can redistribute it and/or modify
2524+# it under the terms of the GNU General Public License as published by
2525+# the Free Software Foundation; either version 2 of the License, or
2526+# (at your option) any later version.
2527+#
2528+# This program is distributed in the hope that it will be useful,
2529+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2530+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2531+# GNU General Public License for more details.
2532+#
2533+# You should have received a copy of the GNU General Public License
2534+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2535+
2536+export LC_ALL=C
2537+export PATH=$(pwd):$PATH
2538+
2539+if [ ! -e clknetsim ]; then
2540+ git clone https://github.com/mlichvar/clknetsim.git || exit 1
2541+fi
2542+
2543+if [ ! -x clknetsim/clknetsim -o ! -e clknetsim/clknetsim.so ]; then
2544+ pushd clknetsim
2545+ make || exit 1
2546+ popd
2547+fi
2548+
2549+export CLKNETSIM_PATH=clknetsim
2550+
2551+. $CLKNETSIM_PATH/clknetsim.bash
2552+
2553+default_limit=500
2554+default_time_offset=1e-1
2555+default_freq_offset=1e-4
2556+default_base_delay=1e-7
2557+default_jitter=1e-7
2558+default_refclock_jitter=1e-7
2559+default_refclock_offset=0.0
2560+default_wander=1e-9
2561+default_time_rms_limit=1e-6
2562+default_freq_rms_limit=1e-6
2563+default_time_max_limit=2e-6
2564+default_freq_max_limit=2e-6
2565+default_min_sync_time=10
2566+default_max_sync_time=40
2567+default_max_ptp4l_delay_limit=1e-4
2568+default_nodes=3
2569+default_subnets=""
2570+default_master_nodes="1"
2571+default_transparent_nodes=""
2572+default_free_running_nodes=""
2573+default_delay_correction=""
2574+default_phc2sys_node=0
2575+default_pmc_node=0
2576+default_nsm_node=0
2577+default_master_start=0.0
2578+default_slave_start=9.0
2579+default_phc2sys_start=9.0
2580+default_pmc_start=50.0
2581+default_nsm_start=50.0
2582+default_master_step=""
2583+default_slave_step=""
2584+default_update_interval=0
2585+default_log_packets=0
2586+default_master_conf=""
2587+default_slave_conf=""
2588+default_transparent_conf=""
2589+default_phc2sys_conf=""
2590+default_pmc_conf=""
2591+default_nsm_conf=""
2592+default_phc2sys_uds=""
2593+default_pmc_uds=""
2594+default_phc2sys_phc_base=0
2595+default_phc2sys_phc_swap=0
2596+default_extra_ptp4l_options=""
2597+
2598+declare -a extra_node_confs
2599+declare -a node_start
2600+
2601+for defoptname in ${!default_*}; do
2602+ optname=${defoptname#default_}
2603+ [ -z "${!optname}" ] && declare "$optname"="${!defoptname}"
2604+done
2605+
2606+test_start() {
2607+ rm -f tmp/*
2608+ echo "Testing $@:"
2609+}
2610+
2611+test_pass() {
2612+ echo "PASS"
2613+ exit 0
2614+}
2615+
2616+test_fail() {
2617+ echo "FAIL"
2618+ exit 1
2619+}
2620+
2621+test_ok() {
2622+ pad_line
2623+ echo -e "\tOK"
2624+ return 0
2625+}
2626+
2627+test_bad() {
2628+ pad_line
2629+ echo -e "\tBAD"
2630+ return 1
2631+}
2632+
2633+test_error() {
2634+ pad_line
2635+ echo -e "\tERROR"
2636+ return 1
2637+}
2638+
2639+msg_length=0
2640+pad_line() {
2641+ local line_length=56
2642+ [ $msg_length -lt $line_length ] && \
2643+ printf "%$[$line_length - $msg_length]s" ""
2644+ msg_length=0
2645+}
2646+
2647+test_message() {
2648+ local level=$1 eol=$2
2649+ shift 2
2650+ local msg="$*"
2651+
2652+ while [ $level -gt 0 ]; do
2653+ echo -n " "
2654+ level=$[$level - 1]
2655+ msg_length=$[$msg_length + 2]
2656+ done
2657+ echo -n "$msg"
2658+
2659+ msg_length=$[$msg_length + ${#msg}]
2660+ if [ $eol -ne 0 ]; then
2661+ echo
2662+ msg_length=0
2663+ fi
2664+}
2665+
2666+check_sync() {
2667+ local i sync_time max_time_error max_freq_error ret=0
2668+ local rms_time_error rms_freq_error
2669+
2670+ test_message 2 1 "checking clock sync time, max/rms time/freq error:"
2671+
2672+ for i in $(seq 1 $nodes); do
2673+ [[ " $master_nodes " =~ [^0-9]$i[^0-9] ]] && continue
2674+ [ $i -eq $pmc_node ] && continue
2675+ [ $i -eq $nsm_node ] && continue
2676+ [[ " $free_running_nodes " =~ [^0-9]$i[^0-9] ]] && continue
2677+
2678+ sync_time=$(find_sync tmp/log.offset tmp/log.freq $i \
2679+ $time_max_limit $freq_max_limit 1.0)
2680+ max_time_error=$(get_stat 'Maximum absolute offset' $i)
2681+ max_freq_error=$(get_stat 'Maximum absolute frequency' $i)
2682+ rms_time_error=$(get_stat 'RMS offset' $i)
2683+ rms_freq_error=$(get_stat 'RMS frequency' $i)
2684+
2685+ test_message 3 0 "node $i: $sync_time $(printf '%.2e %.2e %.2e %.2e' \
2686+ $max_time_error $max_freq_error $rms_time_error $rms_freq_error)"
2687+
2688+ check_stat $sync_time $min_sync_time $max_sync_time && \
2689+ check_stat $max_time_error 0.0 $time_max_limit && \
2690+ check_stat $max_freq_error 0.0 $freq_max_limit && \
2691+ check_stat $rms_time_error 0.0 $time_rms_limit && \
2692+ check_stat $rms_freq_error 0.0 $freq_rms_limit && \
2693+ test_ok || test_bad
2694+
2695+ [ $? -eq 0 ] || ret=1
2696+ done
2697+
2698+ return $ret
2699+}
2700+
2701+check_ptp4l_delay() {
2702+ local i max_delay ret=0
2703+
2704+ test_message 2 1 "checking max abs path delay measured by ptp4l:"
2705+
2706+ for i in $(seq 1 $nodes); do
2707+ [[ " $master_nodes " =~ [^0-9]$i[^0-9] ]] && continue
2708+ [ $i -eq $pmc_node ] && continue
2709+ [ $i -eq $nsm_node ] && continue
2710+
2711+ max_delay=$(grep -oE 'delay +filtered +[-0-9]+ +raw +[-0-9]+$' tmp/log.$i | awk '
2712+ BEGIN {
2713+ max = 0.0
2714+ } {
2715+ abs = $5 < 0 ? -$5 : $5
2716+ if (max < abs)
2717+ max = abs
2718+ } END {
2719+ print max / 1e9
2720+ }')
2721+
2722+ test_message 3 0 "node $i: $(printf '%.2e' $max_delay)"
2723+
2724+ check_stat $max_delay 0.0 $max_ptp4l_delay_limit && test_ok || test_bad
2725+
2726+ [ $? -eq 0 ] || ret=1
2727+ done
2728+
2729+ return $ret
2730+}
2731+
2732+check_pmc_output() {
2733+ local pattern=$1
2734+ test_message 2 0 "checking pmc output:"
2735+ [[ "$(cat tmp/log.$pmc_node)" =~ $pattern ]] && test_ok || test_bad
2736+}
2737+
2738+check_nsm_output() {
2739+ local pattern=$1
2740+ test_message 2 0 "checking nsm output:"
2741+ [[ "$(cat tmp/log.$nsm_node)" =~ $pattern ]] && test_ok || test_bad
2742+}
2743+
2744+check_any_log_message() {
2745+ local matching_messages node=$1 match_pattern=$2 last_pattern=$3
2746+ matching_messages=$(grep "$match_pattern" tmp/log.$node)
2747+ test_message 2 0 "checking any \"$match_pattern\" in node $node log: "
2748+ [[ "$matching_messages" =~ $last_pattern ]] && test_ok || test_bad
2749+}
2750+
2751+check_last_log_message() {
2752+ local last_message node=$1 match_pattern=$2 last_pattern=$3
2753+ last_message=$(grep "$match_pattern" tmp/log.$node | tail -n 1)
2754+ test_message 2 0 "checking last \"$match_pattern\" in node $node log: "
2755+ [[ "$last_message" =~ $last_pattern ]] && test_ok || test_bad
2756+}
2757+
2758+print_nondefaults() {
2759+ local i defopt defoptname optname
2760+
2761+ test_message 2 1 "non-default settings:"
2762+ for defoptname in ${!default_*}; do
2763+ optname=${defoptname#default_}
2764+ [ "${!defoptname}" = "${!optname}" ] || \
2765+ test_message 3 1 $optname=${!optname}
2766+ done
2767+
2768+ for i in $(seq 1 $nodes); do
2769+ [ -z "${extra_node_confs[$i]}" ] || \
2770+ test_message 3 1 extra_node_confs[$i]=${extra_node_confs[$i]}
2771+ done
2772+}
2773+
2774+get_wander_expr() {
2775+ local scaled_wander
2776+
2777+ scaled_wander=$(awk "BEGIN {print $wander / \
2778+ sqrt($update_interval < 0 ? 2^-($update_interval) : 1)}")
2779+
2780+ echo "(+ $freq_offset (sum (* $scaled_wander (normal))))"
2781+}
2782+
2783+run_simulation() {
2784+ test_message 2 0 "running simulation:"
2785+
2786+ start_server $nodes \
2787+ -n $[$(echo "$subnets" | tr -cd '|' | wc -c) + 2] \
2788+ -o tmp/log.offset -f tmp/log.freq \
2789+ $([ $log_packets -ne 0 ] && echo -p tmp/log.packets) \
2790+ -R $(awk "BEGIN {print $update_interval < 0 ? 2^-($update_interval) : 1}") \
2791+ -r $(awk "BEGIN {print $max_sync_time * 2^$update_interval}") \
2792+ -l $(awk "BEGIN {print $limit * 2^$update_interval}") && test_ok || test_error
2793+}
2794+
2795+run_test() {
2796+ local i j s subnet ifaces test_subnets conf start
2797+
2798+ test_message 1 1 "network with $nodes nodes:"
2799+ print_nondefaults
2800+
2801+ [ -z "$subnets" ] && test_subnets=$(seq -s ' ' 1 $nodes) || test_subnets=$subnets
2802+
2803+ generate_config4 "$master_nodes $pmc_node $nsm_node" "$test_subnets" $time_offset \
2804+ "$(get_wander_expr)" \
2805+ "(+ $base_delay (* $jitter (exponential)))"
2806+
2807+ if [ -n "$delay_correction" ]; then
2808+ for i in $(seq 1 $nodes); do
2809+ for j in $(seq 1 $nodes); do
2810+ echo "node${i}_delay_correction${j} = $delay_correction" >> tmp/conf
2811+ done
2812+ done
2813+ fi
2814+
2815+ for i in $(seq 1 $nodes); do
2816+ ifaces="" subnet=0
2817+ for s in $test_subnets; do
2818+ [ $s = "|" ] && subnet=$[$subnet + 1] && continue
2819+ [ $s -eq $i ] && ifaces="$ifaces -i eth$subnet"
2820+ done
2821+
2822+ export CLKNETSIM_UNIX_SUBNET=$[$subnet + 2]
2823+
2824+ test_message 2 0 "starting node $i:"
2825+ if [ $i -eq $phc2sys_node ]; then
2826+ echo "node${i}_start = $phc2sys_start" >> tmp/conf
2827+ echo "node${i}_refclock = (+ $refclock_offset (* $refclock_jitter (normal)))" \
2828+ >> tmp/conf
2829+ if [ "$phc2sys_phc_base" -gt 0 ]; then
2830+ echo "node${i}_refclock_base = node${phc2sys_phc_base}" >> tmp/conf
2831+ fi
2832+ ifaces=""
2833+ for uds in $phc2sys_uds; do
2834+ ifaces="$ifaces -z /clknetsim/unix/$uds"
2835+ done
2836+ CLKNETSIM_PHC_SWAP=$phc2sys_phc_swap \
2837+ start_client $i phc2sys "$ifaces $phc2sys_conf" && \
2838+ test_ok || test_error
2839+ elif [ $i -eq $pmc_node ]; then
2840+ echo "node${i}_start = $pmc_start" >> tmp/conf
2841+ if [ "$pmc_uds" != "" ]; then
2842+ ifaces="-u -i /clknetsim/unix/pmc -s /clknetsim/unix/$pmc_uds"
2843+ fi
2844+ start_client $i pmc "$pmc_conf" "" "-b 0 $ifaces" && \
2845+ test_ok || test_error
2846+ elif [ $i -eq $nsm_node ]; then
2847+ echo "node${i}_start = $nsm_start" >> tmp/conf
2848+ start_client $i nsm "$nsm_conf" "" "$ifaces" && \
2849+ test_ok || test_error
2850+ else
2851+ if [[ " $transparent_nodes " =~ [^0-9]$i[^0-9] ]]; then
2852+ start=$slave_start
2853+ conf=$transparent_conf
2854+ step=$slave_step
2855+ elif [[ " $master_nodes " =~ [^0-9]$i[^0-9] ]]; then
2856+ start=$master_start
2857+ conf=$master_conf
2858+ step=$master_step
2859+ else
2860+ start=$slave_start
2861+ conf=$slave_conf
2862+ step=$slave_step
2863+ fi
2864+ conf=$( echo "uds_address /clknetsim/unix/ptp4l"
2865+ echo "uds_ro_address /clknetsim/unix/ptp4lro"
2866+ echo "${conf}"
2867+ echo "${extra_node_confs[$i]}")
2868+ [ -z "$step" ] || echo "node${i}_step = $step" >> tmp/conf
2869+
2870+ # override individual node start time if set
2871+ if [[ -n "${node_start[$i]}" ]]; then
2872+ start=${node_start[$i]}
2873+ fi
2874+ echo "node${i}_start = $start" >> tmp/conf
2875+ start_client $i ptp4l "$conf" "" "$ifaces $extra_ptp4l_options" && \
2876+ test_ok || test_error
2877+ fi
2878+
2879+ [ $? -ne 0 ] && return 1
2880+ done
2881+
2882+ run_simulation
2883+}
2884+
2885+run_ptp4l() {
2886+ run_test "$@"
2887+}
2888diff --git a/debian/tests/simulation-test-suite b/debian/tests/simulation-test-suite
2889new file mode 100755
2890index 0000000..0649aa0
2891--- /dev/null
2892+++ b/debian/tests/simulation-test-suite
2893@@ -0,0 +1,55 @@
2894+#!/bin/bash -e
2895+
2896+testdir="$PWD/debian/tests/linuxptp-testsuite"
2897+clknetsim_ver=0a11a35
2898+clknetsim_src=https://github.com/mlichvar/clknetsim/archive/"$clknetsim_ver"/clknetsim-"$clknetsim_ver".tar.gz
2899+clknetsim_archive=$(basename "$clknetsim_src")
2900+
2901+inject_local_aa() {
2902+ app="$1"
2903+ apparmor_profile=/etc/apparmor.d/usr.sbin.${app}
2904+ echo "-- Injecting complementary AppArmor rules for $app"
2905+
2906+ sudo -E bash -c "
2907+ if [ -f '$apparmor_profile' ]; then
2908+ if aa-status --enabled 2>/dev/null; then
2909+ cat <<EOF >>/etc/apparmor.d/local/usr.sbin.'${app}'
2910+/tmp/autopkgtest*/** rwm,
2911+/proc/[0-9]*/comm r,
2912+EOF
2913+ apparmor_parser -r -W -T '${apparmor_profile}' || {
2914+ echo 'Failed to reload the ${apparmor_profile} AppArmor profile, continuing anyway.'
2915+ }
2916+ fi
2917+ else
2918+ echo 'AppArmor profile for $app does not exist, skipping.'
2919+ fi
2920+ "
2921+}
2922+
2923+# Always use the same seed to get deterministic results
2924+export CLKNETSIM_RANDOM_SEED=24508
2925+
2926+# By default linuxptp-testsuite will look for clknetsim in a linuxptp-testsuite/clknetsim subdirectory
2927+echo ""
2928+cd "$testdir"
2929+mkdir clknetsim
2930+cd clknetsim
2931+
2932+echo "-- Downloading clknetsim"
2933+wget "$clknetsim_src"
2934+
2935+echo "-- Extracting clknetsim"
2936+tar -xzvf "$clknetsim_archive" --strip-components=1
2937+echo ""
2938+
2939+echo "-- Building clknetsim"
2940+make
2941+echo ""
2942+
2943+inject_local_aa "ptp4l"
2944+inject_local_aa "phc2sys"
2945+
2946+echo "-- Running test-suite"
2947+cd "$testdir"
2948+./run
2949diff --git a/debian/usr.sbin.phc2sys b/debian/usr.sbin.phc2sys
2950new file mode 100644
2951index 0000000..05d30e3
2952--- /dev/null
2953+++ b/debian/usr.sbin.phc2sys
2954@@ -0,0 +1,44 @@
2955+
2956+# vim:syntax=apparmor
2957+# Last Modified: Sun Sep 05 16:48:05 2021
2958+
2959+abi <abi/4.0>,
2960+include <tunables/global>
2961+
2962+profile phc2sys /usr/sbin/phc2sys {
2963+ include <abstractions/base>
2964+
2965+ # Needed phc2sys capabilities
2966+ capability dac_read_search,
2967+ capability dac_override,
2968+ capability sys_time,
2969+ capability sys_module,
2970+ capability net_admin,
2971+
2972+ # Allow dgram type for all net domains
2973+ network dgram,
2974+
2975+ # The phc2sys application it's own
2976+ /{usr/,}sbin/phc2sys mr,
2977+
2978+ # phc2sys runtime data
2979+ @{run}/phc2sys.[0-9]* rw,
2980+
2981+ # To be able to comunicate with ptp4l
2982+ @{run}/ptp4lro rw,
2983+
2984+ # Needed signals in case of being executed by other application
2985+ signal (receive) set=(term),
2986+
2987+ # Needed when being executed by timemaster
2988+ @{run}/timemaster/ptp4l.[0-9]*.socket rw,
2989+
2990+ # PTP devices
2991+ /dev/ptp[0-9]* rw,
2992+
2993+ # PPS devices
2994+ /dev/pps[0-9]* r,
2995+
2996+ # Site-specific additions and overrides. See local/README for details.
2997+ include if exists <local/usr.sbin.ptp4l>
2998+}
2999diff --git a/debian/usr.sbin.ptp4l b/debian/usr.sbin.ptp4l
3000new file mode 100644
3001index 0000000..750d80b
3002--- /dev/null
3003+++ b/debian/usr.sbin.ptp4l
3004@@ -0,0 +1,64 @@
3005+# vim:syntax=apparmor
3006+# Last Modified: Sun Sep 05 16:48:05 2021
3007+
3008+abi <abi/4.0>,
3009+include <tunables/global>
3010+
3011+profile ptp4l /usr/sbin/ptp4l {
3012+ include <abstractions/base>
3013+
3014+ # The ptp4l application it's own
3015+ /{usr/,}sbin/ptp4l mr,
3016+
3017+ # Needed signals in case of being executed by other application
3018+ signal (receive) set=(term),
3019+
3020+ # Needed capabilities
3021+ capability net_admin,
3022+ capability sys_module,
3023+ capability net_bind_service,
3024+ capability net_raw,
3025+
3026+ # Needed Network domains
3027+ network netlink,
3028+ network packet,
3029+ network inet,
3030+ network inet6,
3031+ network unix,
3032+ network unspec,
3033+
3034+ # Needed to define mac address for
3035+ # a network interface
3036+ /sys/class/net/*/address r,
3037+
3038+ # ptp devices
3039+ /dev/ptp[0-9]* rw,
3040+
3041+ # serial devices
3042+ /dev/ttyS[0-9]* rw,
3043+ /dev/ttyACM[0-9]* rw,
3044+
3045+ # Needed for ipc and runtime status
3046+ @{run}/cmlds_client rw,
3047+ @{run}/cmlds_server rw,
3048+ @{run}/refclock.ptp.sock rw,
3049+ @{run}/run/ptp4l rw,
3050+ @{run}/ptp4lro rw,
3051+ @{run}/ptp4l rw,
3052+ @{run}/ptp4lro rw,
3053+ @{run}/phc2sys.[0-9]+ r,
3054+
3055+ # When being runned by timemaster
3056+ @{run}/timemaster/chrony.SOCK* rw,
3057+ @{run}/timemaster/ptp4l.*.conf r,
3058+ @{run}/timemaster/ptp4l.*.socket rw,
3059+ @{run}/timemaster/ptp4lro.*.socket rw,
3060+ @{run}/phc2sys.* rw,
3061+
3062+ # ptp4l config files
3063+ @{etc_ro}/linuxptp/** r,
3064+
3065+ # Site-specific additions and overrides. See local/README for details.
3066+ include if exists <local/usr.sbin.ptp4l>
3067+}
3068+
3069diff --git a/debian/usr.sbin.timemaster b/debian/usr.sbin.timemaster
3070new file mode 100644
3071index 0000000..aaba051
3072--- /dev/null
3073+++ b/debian/usr.sbin.timemaster
3074@@ -0,0 +1,47 @@
3075+
3076+# vim:syntax=apparmor
3077+# Last Modified: Mon Sep 15 14:48:05 2024
3078+
3079+abi <abi/4.0>,
3080+include <tunables/global>
3081+
3082+profile timemaster /usr/sbin/timemaster {
3083+ include <abstractions/base>
3084+ include <abstractions/nameservice>
3085+
3086+ # To be able to kill child processes
3087+ capability kill,
3088+
3089+ # To be able to send the term signal
3090+ signal (send) set=(term),
3091+
3092+ # Runtime config files for timemaster
3093+ @{run}/timemaster/*.conf rw,
3094+ @{run}/timemaster/ rwk,
3095+
3096+ ## system files access
3097+
3098+ # RPi4 and RPi5 specific
3099+ @{sys}/devices/platform/axi/[0-9a-f]*.pcie/[0-9a-f]*.ethernet/net/*/ptp[0-9]*/ r,
3100+ @{sys}/devices/platform/axi/[0-9a-f]*.pcie/[0-9a-f]*.ethernet/net/*/ptp[0-9]*/n_vclocks rw,
3101+
3102+ # Generic arch's
3103+ @{sys}/ptp[0-9]+/ptp[0-9]* rw,
3104+ @{sys}/ptp[0-9]+/n_vclocks rw,
3105+ @{sys}/net/*/ptp[0-9]*/n_vclocks rw,
3106+
3107+ # Default location for config files
3108+ @{etc_ro}/linuxptp/** r,
3109+ @{etc_ro}/chrony/** r,
3110+ @{etc_ro}/ntpsec/** r,
3111+
3112+ # Backend applications
3113+ # Px = exec to apparmor profile that matches executable name, with environment variable scrubbing
3114+ /usr/sbin/chronyd Px,
3115+ /usr/sbin/ntpd Px,
3116+ /usr/sbin/ptp4l Px,
3117+ /usr/sbin/phc2sys Px,
3118+
3119+ # Site-specific additions and overrides. See local/README for details.
3120+ include if exists <local/usr.sbin.timemaster>
3121+}

Subscribers

People subscribed via source and target branches

to all changes: