get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2218117/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2218117,
    "url": "http://patchwork.ozlabs.org/api/patches/2218117/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260331-clock_settime_fix-v2-1-e222fe379b16@suse.com/",
    "project": {
        "id": 59,
        "url": "http://patchwork.ozlabs.org/api/projects/59/?format=api",
        "name": "Linux Test Project development",
        "link_name": "ltp",
        "list_id": "ltp.lists.linux.it",
        "list_email": "ltp@lists.linux.it",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260331-clock_settime_fix-v2-1-e222fe379b16@suse.com>",
    "list_archive_url": null,
    "date": "2026-03-31T12:37:03",
    "name": "[v2] clock_settime: Detect external clock adjustments via CLOCK_MONOTONIC",
    "commit_ref": null,
    "pull_url": null,
    "state": "needs-review-ack",
    "archived": false,
    "hash": "4b5726a54658ef97a6fb20a4c04130e3dbc34c85",
    "submitter": {
        "id": 83220,
        "url": "http://patchwork.ozlabs.org/api/people/83220/?format=api",
        "name": "Andrea Cervesato",
        "email": "andrea.cervesato@suse.de"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/ltp/patch/20260331-clock_settime_fix-v2-1-e222fe379b16@suse.com/mbox/",
    "series": [
        {
            "id": 498189,
            "url": "http://patchwork.ozlabs.org/api/series/498189/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/ltp/list/?series=498189",
            "date": "2026-03-31T12:37:03",
            "name": "[v2] clock_settime: Detect external clock adjustments via CLOCK_MONOTONIC",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/498189/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2218117/comments/",
    "check": "success",
    "checks": "http://patchwork.ozlabs.org/api/patches/2218117/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "ltp@lists.linux.it"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "ltp@picard.linux.it"
        ],
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=1/9IzcWv;\n\tdkim=fail reason=\"signature verification failed\" header.d=suse.de\n header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519\n header.b=/BTcB89i;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key)\n header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa\n header.b=sDzAmThw;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=Xqpbmj6i;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=2001:1418:10:5::2; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)",
            "smtp-out1.suse.de;\n dkim=pass header.d=suse.de header.s=susede2_rsa header.b=sDzAmThw;\n dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Xqpbmj6i"
        ],
        "Received": [
            "from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4flSLR1smrz1y1q\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 23:37:19 +1100 (AEDT)",
            "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id 856B13E4ED7\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 14:37:16 +0200 (CEST)",
            "from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id AEF533C9314\n for <ltp@lists.linux.it>; Tue, 31 Mar 2026 14:37:12 +0200 (CEST)",
            "from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 052BB600687\n for <ltp@lists.linux.it>; Tue, 31 Mar 2026 14:37:10 +0200 (CEST)",
            "from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org\n [IPv6:2a07:de40:b281:104:10:150:64:97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out1.suse.de (Postfix) with ESMTPS id A7C044D1E3;\n Tue, 31 Mar 2026 12:37:08 +0000 (UTC)",
            "from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 769B24A0A2;\n Tue, 31 Mar 2026 12:37:08 +0000 (UTC)",
            "from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id l7neGvS/y2k6IgAAD6G6ig\n (envelope-from <andrea.cervesato@suse.de>); Tue, 31 Mar 2026 12:37:08 +0000"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1774960629;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=92+oPd689+hb96NfcS9GL+gJkp+dzhQTwt0yf/uJyCg=;\n b=1/9IzcWvfborpJqw8B5rijQuX4MqmBpvhGMZoQZSTrLNbHVT+xRkaGlfgz/Y5dig3goNhv\n wT4Q6CGZcrdgJOHEEbmvWBWhJ24lfJvJTfPT0KhT67OBt+lTU/z35AmJECxImnW+sJKc8k\n ZCRxrcDL1AAyMo7L5A8i07siA61Wvhs=",
            "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1774960629;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=92+oPd689+hb96NfcS9GL+gJkp+dzhQTwt0yf/uJyCg=;\n b=/BTcB89iqPu61Dl38cJApSfMa/WIpgTgxchm6XXVaznV2Fgry/MVv1m9Z2hS5Ky6SRmQUG\n UAizfJAnHy7J3uBw==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1774960628;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=92+oPd689+hb96NfcS9GL+gJkp+dzhQTwt0yf/uJyCg=;\n b=sDzAmThwDkYrVyRMu14I/U2I/+O4sELr3arr5NyXHUzCrvML9Vuph66aZ9fowrv0EphkvB\n mkJSPaUlCQHMqs9qU7TRQ61g58IWYqi2L0dgbCMKAZtqR3ZBOQNkKNInYikm0/zQ33xZLI\n 4qkAQflYN+TV0aJm24+TEg0hdxdO7Xw=",
            "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1774960628;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=92+oPd689+hb96NfcS9GL+gJkp+dzhQTwt0yf/uJyCg=;\n b=Xqpbmj6i2A7eY8Oxk4gNF2W3uy/u1fQ/LO/u0IqJ+A+DKKQVUYCzCNXMbamY2hv7hT5MZP\n 8bSret2sqdUMD+DA=="
        ],
        "From": "Andrea Cervesato <andrea.cervesato@suse.de>",
        "Date": "Tue, 31 Mar 2026 14:37:03 +0200",
        "MIME-Version": "1.0",
        "Message-Id": "<20260331-clock_settime_fix-v2-1-e222fe379b16@suse.com>",
        "X-B4-Tracking": "v=1; b=H4sIAO6/y2kC/32NWw6CMBBFt0Lm25o+SH18sQ9DCLZTmSjUdLDRE\n PZuZQF+npPccxdgTIQM52qBhJmY4lRA7ypwQz/dUJAvDFpqK41Rwj2iu3eM80wjdoHe4oi1Ugf\n vrlaeoOyeCYvempe28EA8x/TZLrL62X+1rIQSPvQorQ+6NrbhF+PexRHadV2/r5lZQLEAAAA=",
        "X-Change-ID": "20260331-clock_settime_fix-8e4117dcb609",
        "To": "Linux Test Project <ltp@lists.linux.it>",
        "X-Mailer": "b4 0.14.2",
        "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1774960628; l=14424;\n i=andrea.cervesato@suse.com; s=20251210; h=from:subject:message-id;\n bh=ClqqumL4eet1PbQoWvl19cSftotOt0t+nf0xd5YXUc8=;\n b=9bE4YKdCX3TucIrtNebnFi/q2cLNBFcx0fzN4zU9dOGhojVi+dmpD1w9IZSwHnwuB3rCH14OT\n xViPnDCjb9MBlmbCExH6wkh28jqUyGqx2Cc2HtDwu4vCiVG4ETOBCLx",
        "X-Developer-Key": "i=andrea.cervesato@suse.com; a=ed25519;\n pk=zKY+6GCauOiuHNZ//d8PQ/UL4jFCTKbXrzXAOQSLevI=",
        "X-Spamd-Result": "default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n NEURAL_HAM_LONG(-1.00)[-1.000];\n R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain];\n MX_GOOD(-0.01)[]; FUZZY_RATELIMITED(0.00)[rspamd.com];\n RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[];\n RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from];\n RCVD_VIA_SMTP_AUTH(0.00)[];\n SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from];\n MIME_TRACE(0.00)[0:+];\n RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received];\n DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[];\n RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2];\n TO_MATCH_ENVRCPT_ALL(0.00)[];\n DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,anthropic.com:email,suse.de:dkim,suse.com:mid,suse.com:email];\n TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]",
        "X-Rspamd-Action": "no action",
        "X-Spam-Score": "-4.51",
        "X-Spam-Level": "",
        "X-Rspamd-Server": "rspamd1.dmz-prg2.suse.org",
        "X-Rspamd-Queue-Id": "A7C044D1E3",
        "X-Spam-Status": "No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE,SPF_PASS\n shortcircuit=no autolearn=disabled version=4.0.1",
        "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on in-2.smtp.seeweb.it",
        "X-Virus-Scanned": "clamav-milter 1.0.9 at in-2.smtp.seeweb.it",
        "X-Virus-Status": "Clean",
        "Subject": "[LTP] [PATCH v2] clock_settime: Detect external clock adjustments\n via CLOCK_MONOTONIC",
        "X-BeenThere": "ltp@lists.linux.it",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Linux Test Project <ltp.lists.linux.it>",
        "List-Unsubscribe": "<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>",
        "List-Archive": "<http://lists.linux.it/pipermail/ltp/>",
        "List-Post": "<mailto:ltp@lists.linux.it>",
        "List-Help": "<mailto:ltp-request@lists.linux.it?subject=help>",
        "List-Subscribe": "<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>",
        "Cc": "Claude <noreply@anthropic.com>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it",
        "Sender": "\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>"
    },
    "content": "From: Andrea Cervesato <andrea.cervesato@suse.com>\n\nThese tests manipulate CLOCK_REALTIME to verify timer and\nclock_nanosleep behavior, but NTP or VM time sync can also adjust\nCLOCK_REALTIME during the test, causing timers to fire at wrong times\nand producing spurious failures.\n\nUse CLOCK_MONOTONIC as a sideband check to detect external interference.\nIf the monotonic elapsed time is anomalous, report UNTESTED instead of\na false FAIL. Guard the checks with _POSIX_MONOTONIC_CLOCK since\nCLOCK_MONOTONIC is optional in POSIX.1-2001.\n\nCo-authored-by: Claude <noreply@anthropic.com>\nSigned-off-by: Andrea Cervesato <andrea.cervesato@suse.com>\n---\nI used Claude to generate the right patches to fix sporadic issues in the\nclock_settime testing suite. We tried many attempt for fixing it, but the\nCLOCK_REALTIME usage seems to be the real issue in here. The idea is that\nwe use internal Openposix mechanisms to skip tests if CLOCK_MONOTONIC\nusage spots a possible interference from external tools.\n---\nChanges in v2:\n- print a message if CLOCK_MONOTONIC is not available\n- always verify that CLOCK_MONOTONIC is available\n- Link to v1: https://lore.kernel.org/r/20260331-clock_settime_fix-v1-1-dfae06df2436@suse.com\n---\n .../conformance/interfaces/clock_settime/4-1.c     | 36 ++++++++++++++++++\n .../conformance/interfaces/clock_settime/5-1.c     | 43 +++++++++++++++++++++-\n .../conformance/interfaces/clock_settime/5-2.c     | 43 +++++++++++++++++++++-\n .../conformance/interfaces/clock_settime/7-1.c     | 38 +++++++++++++++++++\n .../conformance/interfaces/clock_settime/7-2.c     | 41 ++++++++++++++++++++-\n 5 files changed, 198 insertions(+), 3 deletions(-)\n\n\n---\nbase-commit: 4688c20c01eece869b59e05ca3dd68c43e0d6af7\nchange-id: 20260331-clock_settime_fix-8e4117dcb609\n\nBest regards,",
    "diff": "diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/4-1.c\nindex f8a3e9c542ca8c9767cdd0057005e519f58b2b55..5f3f816a5fc71a9e62bb3577e1a18a19f987a802 100644\n--- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/4-1.c\n+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/4-1.c\n@@ -42,6 +42,9 @@ int main(void)\n {\n \tstruct sigevent ev;\n \tstruct timespec tpT0, tpT2, tpreset;\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tstruct timespec mono_before, mono_after;\n+#endif\n \tstruct itimerspec its;\n \ttimer_t tid;\n \tint delta;\n@@ -55,6 +58,10 @@ int main(void)\n \t\treturn PTS_UNTESTED;\n \t}\n \n+#ifndef _POSIX_MONOTONIC_CLOCK\n+\tprintf(\"CLOCK_MONOTONIC unavailable, test may fail due to external clock adjustments\\n\");\n+#endif\n+\n \t/*\n \t * set up sigevent for timer\n \t * set up signal set for sigwait\n@@ -82,6 +89,13 @@ int main(void)\n \t\treturn PTS_UNRESOLVED;\n \t}\n \n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tif (clock_gettime(CLOCK_MONOTONIC, &mono_before) != 0) {\n+\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\treturn PTS_UNRESOLVED;\n+\t}\n+#endif\n+\n \tif (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {\n \t\tperror(\"timer_create() did not return success\\n\");\n \t\treturn PTS_UNRESOLVED;\n@@ -120,6 +134,28 @@ int main(void)\n \ttpreset.tv_sec += tpT2.tv_sec - tpT0.tv_sec;\n \tsetBackTime(tpreset);\n \n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tif (clock_gettime(CLOCK_MONOTONIC, &mono_after) != 0) {\n+\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\treturn PTS_UNRESOLVED;\n+\t}\n+\n+\t/*\n+\t * The expected monotonic elapsed time is SLEEPTIME + TIMEROFFSET\n+\t * since after resetting the clock, the timer must wait another\n+\t * full TIMEROFFSET. If monotonic time is much shorter, an external\n+\t * clock adjustment (NTP, VM sync) interfered with the test.\n+\t */\n+\tif (mono_after.tv_sec - mono_before.tv_sec <\n+\t    SLEEPTIME + TIMEROFFSET - ACCEPTABLEDELTA) {\n+\t\tprintf(\"UNTESTED: external clock adjustment detected \"\n+\t\t       \"(monotonic elapsed %ds, expected ~%ds)\\n\",\n+\t\t       (int)(mono_after.tv_sec - mono_before.tv_sec),\n+\t\t       SLEEPTIME + TIMEROFFSET);\n+\t\treturn PTS_UNTESTED;\n+\t}\n+#endif\n+\n \tprintf(\"delta: %d\\n\", delta);\n \tif ((delta <= ACCEPTABLEDELTA) && (delta >= 0)) {\n \t\tprintf(\"Test PASSED\\n\");\ndiff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-1.c\nindex 75fa591e014601b2ef9308a118992a704365392b..da8cbae29fd77fcbca939ac215f5c4d6d450fe31 100644\n--- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-1.c\n+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-1.c\n@@ -46,9 +46,13 @@ int main(void)\n \tstruct sigevent ev;\n \tstruct sigaction act;\n \tstruct timespec tsclock, ts, tsleft, tsreset;\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tstruct timespec mono_before, mono_after;\n+#endif\n \tstruct itimerspec its;\n \ttimer_t tid;\n \tsigset_t set;\n+\tint ns_ret;\n \n \t/* Check that we're root...can't call clock_settime with CLOCK_REALTIME otherwise */\n \tif (getuid() != 0) {\n@@ -56,6 +60,10 @@ int main(void)\n \t\treturn PTS_UNTESTED;\n \t}\n \n+#ifndef _POSIX_MONOTONIC_CLOCK\n+\tprintf(\"CLOCK_MONOTONIC unavailable, test may fail due to external clock adjustments\\n\");\n+#endif\n+\n \t/*\n \t * set up sigevent for timer\n \t * set up signal set for sigwait\n@@ -97,6 +105,13 @@ int main(void)\n \t\treturn PTS_UNRESOLVED;\n \t}\n \n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tif (clock_gettime(CLOCK_MONOTONIC, &mono_before) != 0) {\n+\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\treturn PTS_UNRESOLVED;\n+\t}\n+#endif\n+\n \tif (clock_gettime(CLOCK_REALTIME, &tsclock) != 0) {\n \t\tprintf(\"clock_gettime() did not return success\\n\");\n \t\treturn PTS_UNRESOLVED;\n@@ -112,7 +127,33 @@ int main(void)\n \tts.tv_sec = TIMERSEC + SLEEPDELTA;\n \tts.tv_nsec = 0;\n \n-\tif (nanosleep(&ts, &tsleft) != -1) {\n+\tns_ret = nanosleep(&ts, &tsleft);\n+\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tif (clock_gettime(CLOCK_MONOTONIC, &mono_after) != 0) {\n+\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\treturn PTS_UNRESOLVED;\n+\t}\n+\n+\t/*\n+\t * The relative timer should fire after TIMERSEC regardless of\n+\t * clock_settime changes. If monotonic elapsed time is too far\n+\t * from TIMERSEC, an external clock adjustment (NTP, VM sync)\n+\t * interfered with the test.\n+\t */\n+\tif (labs(mono_after.tv_sec - mono_before.tv_sec - TIMERSEC) >\n+\t    ACCEPTABLEDELTA + 1) {\n+\t\tprintf(\"UNTESTED: external clock adjustment detected \"\n+\t\t       \"(monotonic elapsed %ds, expected ~%ds)\\n\",\n+\t\t       (int)(mono_after.tv_sec - mono_before.tv_sec),\n+\t\t       TIMERSEC);\n+\t\ttsreset.tv_sec += mono_after.tv_sec - mono_before.tv_sec;\n+\t\tsetBackTime(tsreset);\n+\t\treturn PTS_UNTESTED;\n+\t}\n+#endif\n+\n+\tif (ns_ret != -1) {\n \t\tprintf(\"nanosleep() not interrupted\\n\");\n \t\treturn PTS_FAIL;\n \t}\ndiff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-2.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-2.c\nindex b8a60028c6d3d1a3c0d75922f39697b57329c440..d12d18861ca78b174b47bae69d6e4a1146393159 100644\n--- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-2.c\n+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-2.c\n@@ -46,9 +46,13 @@ int main(void)\n \tstruct sigevent ev;\n \tstruct sigaction act;\n \tstruct timespec tsclock, ts, tsleft, tsreset;\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tstruct timespec mono_before, mono_after;\n+#endif\n \tstruct itimerspec its;\n \ttimer_t tid;\n \tsigset_t set;\n+\tint ns_ret;\n \n \t/* Check that we're root...can't call clock_settime with CLOCK_REALTIME otherwise */\n \tif (getuid() != 0) {\n@@ -56,6 +60,10 @@ int main(void)\n \t\treturn PTS_UNTESTED;\n \t}\n \n+#ifndef _POSIX_MONOTONIC_CLOCK\n+\tprintf(\"CLOCK_MONOTONIC unavailable, test may fail due to external clock adjustments\\n\");\n+#endif\n+\n \t/*\n \t * set up sigevent for timer\n \t * set up signal set for sigwait\n@@ -97,6 +105,13 @@ int main(void)\n \t\treturn PTS_UNRESOLVED;\n \t}\n \n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tif (clock_gettime(CLOCK_MONOTONIC, &mono_before) != 0) {\n+\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\treturn PTS_UNRESOLVED;\n+\t}\n+#endif\n+\n \tif (clock_gettime(CLOCK_REALTIME, &tsclock) != 0) {\n \t\tprintf(\"clock_gettime() did not return success\\n\");\n \t\treturn PTS_UNRESOLVED;\n@@ -112,7 +127,33 @@ int main(void)\n \tts.tv_sec = TIMERSEC + SLEEPDELTA;\n \tts.tv_nsec = 0;\n \n-\tif (nanosleep(&ts, &tsleft) != -1) {\n+\tns_ret = nanosleep(&ts, &tsleft);\n+\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tif (clock_gettime(CLOCK_MONOTONIC, &mono_after) != 0) {\n+\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\treturn PTS_UNRESOLVED;\n+\t}\n+\n+\t/*\n+\t * The relative timer should fire after TIMERSEC regardless of\n+\t * clock_settime changes. If monotonic elapsed time is too far\n+\t * from TIMERSEC, an external clock adjustment (NTP, VM sync)\n+\t * interfered with the test.\n+\t */\n+\tif (labs(mono_after.tv_sec - mono_before.tv_sec - TIMERSEC) >\n+\t    ACCEPTABLEDELTA + 1) {\n+\t\tprintf(\"UNTESTED: external clock adjustment detected \"\n+\t\t       \"(monotonic elapsed %ds, expected ~%ds)\\n\",\n+\t\t       (int)(mono_after.tv_sec - mono_before.tv_sec),\n+\t\t       TIMERSEC);\n+\t\ttsreset.tv_sec += mono_after.tv_sec - mono_before.tv_sec;\n+\t\tsetBackTime(tsreset);\n+\t\treturn PTS_UNTESTED;\n+\t}\n+#endif\n+\n+\tif (ns_ret != -1) {\n \t\tprintf(\"nanosleep() not interrupted\\n\");\n \t\treturn PTS_FAIL;\n \t}\ndiff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/7-1.c\nindex 569eae904ef2eff41441029d3427313107febe53..d372d2d48af0a29133eb833979ae37d682768170 100644\n--- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/7-1.c\n+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/7-1.c\n@@ -36,6 +36,9 @@\n int main(void)\n {\n \tstruct timespec tsT0, tsT1;\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tstruct timespec mono_before, mono_after;\n+#endif\n \tint pid;\n \n \t/* Check that we're root...can't call clock_settime with CLOCK_REALTIME otherwise */\n@@ -44,11 +47,22 @@ int main(void)\n \t\treturn PTS_UNTESTED;\n \t}\n \n+#ifndef _POSIX_MONOTONIC_CLOCK\n+\tprintf(\"CLOCK_MONOTONIC unavailable, test may fail due to external clock adjustments\\n\");\n+#endif\n+\n \tif (clock_gettime(CLOCK_REALTIME, &tsT0) != 0) {\n \t\tperror(\"clock_gettime() did not return success\\n\");\n \t\treturn PTS_UNRESOLVED;\n \t}\n \n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\tif (clock_gettime(CLOCK_MONOTONIC, &mono_before) != 0) {\n+\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\treturn PTS_UNRESOLVED;\n+\t}\n+#endif\n+\n \tif ((pid = fork()) == 0) {\n \t\t/* child here */\n \t\tint flags = 0;\n@@ -103,6 +117,30 @@ int main(void)\n \t\tgetBeforeTime(&tsreset);\t// get current time\n \t\ttsreset.tv_sec += SMALLTIME;\n \t\tsetBackTime(tsreset);\n+\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\t\tif (clock_gettime(CLOCK_MONOTONIC, &mono_after) != 0) {\n+\t\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\t\treturn PTS_UNRESOLVED;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Expected monotonic elapsed time is SMALLTIME + SLEEPOFFSET\n+\t\t * since after resetting the clock, the child must wait\n+\t\t * another full SLEEPOFFSET. If monotonic time is much\n+\t\t * shorter, an external clock adjustment (NTP, VM sync)\n+\t\t * interfered with the test.\n+\t\t */\n+\t\tif (mono_after.tv_sec - mono_before.tv_sec <\n+\t\t    SMALLTIME + SLEEPOFFSET - ACCEPTABLEDELTA - 1) {\n+\t\t\tprintf(\"UNTESTED: external clock adjustment detected \"\n+\t\t\t       \"(monotonic elapsed %ds, expected ~%ds)\\n\",\n+\t\t\t       (int)(mono_after.tv_sec - mono_before.tv_sec),\n+\t\t\t       SMALLTIME + SLEEPOFFSET);\n+\t\t\treturn PTS_UNTESTED;\n+\t\t}\n+#endif\n+\n \t\tif (WIFEXITED(i) && WEXITSTATUS(i)) {\n \t\t\tprintf(\"Test PASSED\\n\");\n \t\t\treturn PTS_PASS;\ndiff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/7-2.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/7-2.c\nindex 7c340b6c97ce03a1b04709f06996e5a66e1a653a..b9f10bfd5dfc517f0372662b1b1247298d2bee32 100644\n--- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/7-2.c\n+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/7-2.c\n@@ -31,6 +31,7 @@\n \n #define CHILDPASS 1\n #define CHILDFAIL 0\n+#define CHILDUNTESTED 2\n \n int main(void)\n {\n@@ -43,6 +44,10 @@ int main(void)\n \t\treturn PTS_UNTESTED;\n \t}\n \n+#ifndef _POSIX_MONOTONIC_CLOCK\n+\tprintf(\"CLOCK_MONOTONIC unavailable, test may fail due to external clock adjustments\\n\");\n+#endif\n+\n \tif (clock_gettime(CLOCK_REALTIME, &tsT0) != 0) {\n \t\tperror(\"clock_gettime() did not return success\\n\");\n \t\treturn PTS_UNRESOLVED;\n@@ -58,13 +63,44 @@ int main(void)\n \t\t/* child here */\n \t\tint flags = 0;\n \t\tstruct timespec tsT3;\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\t\tstruct timespec mono_start, mono_end;\n+#endif\n \n \t\tflags |= TIMER_ABSTIME;\n+\n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\t\tif (clock_gettime(CLOCK_MONOTONIC, &mono_start) != 0) {\n+\t\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\t\treturn CHILDFAIL;\n+\t\t}\n+#endif\n+\n \t\tif (clock_nanosleep(CLOCK_REALTIME, flags, &tsT1, NULL) != 0) {\n \t\t\tprintf(\"clock_nanosleep() did not return success\\n\");\n \t\t\treturn CHILDFAIL;\n \t\t}\n \n+#ifdef _POSIX_MONOTONIC_CLOCK\n+\t\tif (clock_gettime(CLOCK_MONOTONIC, &mono_end) != 0) {\n+\t\t\tperror(\"clock_gettime() was not successful\\n\");\n+\t\t\treturn CHILDFAIL;\n+\t\t}\n+\n+\t\t/*\n+\t\t * The parent sleeps 1s before jumping the clock forward.\n+\t\t * If clock_nanosleep returned in less than 1s monotonic,\n+\t\t * an external clock adjustment (NTP, VM sync) woke us\n+\t\t * instead of the parent's clock_settime.\n+\t\t */\n+\t\tif (mono_end.tv_sec - mono_start.tv_sec < 1) {\n+\t\t\tprintf(\"UNTESTED: external clock adjustment detected \"\n+\t\t\t       \"(monotonic elapsed %ds)\\n\",\n+\t\t\t       (int)(mono_end.tv_sec - mono_start.tv_sec));\n+\t\t\treturn CHILDUNTESTED;\n+\t\t}\n+#endif\n+\n \t\tif (clock_gettime(CLOCK_REALTIME, &tsT3) != 0) {\n \t\t\tperror(\"clock_gettime() did not return success\\n\");\n \t\t\treturn CHILDFAIL;\n@@ -105,7 +141,10 @@ int main(void)\n \n \t\tsetBackTime(tsreset);\t//should be ~= before time\n \n-\t\tif (WIFEXITED(i) && WEXITSTATUS(i)) {\n+\t\tif (WIFEXITED(i) && WEXITSTATUS(i) == CHILDUNTESTED) {\n+\t\t\tprintf(\"Test UNTESTED\\n\");\n+\t\t\treturn PTS_UNTESTED;\n+\t\t} else if (WIFEXITED(i) && WEXITSTATUS(i)) {\n \t\t\tprintf(\"Test PASSED\\n\");\n \t\t\treturn PTS_PASS;\n \t\t} else {\n",
    "prefixes": [
        "v2"
    ]
}