get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2218109,
    "url": "http://patchwork.ozlabs.org/api/patches/2218109/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260331-clock_settime_fix-v1-1-dfae06df2436@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-v1-1-dfae06df2436@suse.com>",
    "list_archive_url": null,
    "date": "2026-03-31T12:11:44",
    "name": "clock_settime: Detect external clock adjustments via CLOCK_MONOTONIC",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "6f3e8ef653e2076d6285f52da6da742bf2d6bd1f",
    "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-v1-1-dfae06df2436@suse.com/mbox/",
    "series": [
        {
            "id": 498186,
            "url": "http://patchwork.ozlabs.org/api/series/498186/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/ltp/list/?series=498186",
            "date": "2026-03-31T12:11:44",
            "name": "clock_settime: Detect external clock adjustments via CLOCK_MONOTONIC",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/498186/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2218109/comments/",
    "check": "success",
    "checks": "http://patchwork.ozlabs.org/api/patches/2218109/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=Oqdw2hy7;\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=wToujE16;\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=Oqdw2hy7;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=wToujE16;\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-out2.suse.de;\n\tnone"
        ],
        "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 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4flRnG6Hpsz1yCp\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 23:12:02 +1100 (AEDT)",
            "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id 1C15B3E26C9\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 14:11:52 +0200 (CEST)",
            "from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it\n [IPv6:2001:4b78:1:20::4])\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 1A4013CC93E\n for <ltp@lists.linux.it>; Tue, 31 Mar 2026 14:11:48 +0200 (CEST)",
            "from smtp-out2.suse.de (smtp-out2.suse.de\n [IPv6:2a07:de40:b251:101:10:150:64:2])\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-4.smtp.seeweb.it (Postfix) with ESMTPS id A6C8F10009F5\n for <ltp@lists.linux.it>; Tue, 31 Mar 2026 14:11:47 +0200 (CEST)",
            "from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id 394975BD89;\n Tue, 31 Mar 2026 12:11:46 +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 69E194A0A2;\n Tue, 31 Mar 2026 12:11:45 +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 NjdJFgG6y2mWBwAAD6G6ig\n (envelope-from <andrea.cervesato@suse.de>); Tue, 31 Mar 2026 12:11:45 +0000"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1774959106;\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=wo9nfZhlJhzzwvwvKDZ9KS2qEUgcH2OuzUWtXklPXYQ=;\n b=Oqdw2hy7gpEyheV1dut4Lt+jhL+ICdQetghMhhvrAAsYdIENYHaJVEVBFT39wFJPbjd3hA\n 6zeiFsBqQVGoZNtcywlmi/bQjGYE0Br7bkUXHovjarAFxEiYxysQnTU5uf6OkeT0LaMu/b\n WsskpEZlt20QSE8Y/ul6/EBDkAvui7s=",
            "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1774959106;\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=wo9nfZhlJhzzwvwvKDZ9KS2qEUgcH2OuzUWtXklPXYQ=;\n b=wToujE16JRFuIUpS9rxhBrMfNLTREFGVrrdj3kBRlIhUt31hLIYYXZItJjM/8VYiycCUo6\n lWwh7Hy+PUmBeJDw==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1774959106;\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=wo9nfZhlJhzzwvwvKDZ9KS2qEUgcH2OuzUWtXklPXYQ=;\n b=Oqdw2hy7gpEyheV1dut4Lt+jhL+ICdQetghMhhvrAAsYdIENYHaJVEVBFT39wFJPbjd3hA\n 6zeiFsBqQVGoZNtcywlmi/bQjGYE0Br7bkUXHovjarAFxEiYxysQnTU5uf6OkeT0LaMu/b\n WsskpEZlt20QSE8Y/ul6/EBDkAvui7s=",
            "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1774959106;\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=wo9nfZhlJhzzwvwvKDZ9KS2qEUgcH2OuzUWtXklPXYQ=;\n b=wToujE16JRFuIUpS9rxhBrMfNLTREFGVrrdj3kBRlIhUt31hLIYYXZItJjM/8VYiycCUo6\n lWwh7Hy+PUmBeJDw=="
        ],
        "From": "Andrea Cervesato <andrea.cervesato@suse.de>",
        "Date": "Tue, 31 Mar 2026 14:11:44 +0200",
        "MIME-Version": "1.0",
        "Message-Id": "<20260331-clock_settime_fix-v1-1-dfae06df2436@suse.com>",
        "X-B4-Tracking": "v=1; b=H4sIAP+5y2kC/x2MWwqAIBAAryL7naAZ9rhKhJRutVQWGhFEd0/6n\n IGZByIGwggNeyDgRZF2n0BmDOzc+wk5ucSQi1wLpSS3624XE/E8aUMz0s0rLKQsnR20qCF1R8C\n k/2fbve8HmNZC4WMAAAA=",
        "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=1774959105; l=12123;\n i=andrea.cervesato@suse.com; s=20251210; h=from:subject:message-id;\n bh=bTw1tt8Dkpi/21emNIqxNNDGu6MJrbKe9SzojacQ38s=;\n b=nW1DMlk2z5SmzKBei77OUpII71ABZxZlC+X5qflSHQWxI5eyEz9aveyQpnriJ55cVWDPa+ODj\n lzbEYHgsueaBYFIpZSHe9oB4CKtSpg2cqEISkwHRCvHVuxVPYjMNSeE",
        "X-Developer-Key": "i=andrea.cervesato@suse.com; a=ed25519;\n pk=zKY+6GCauOiuHNZ//d8PQ/UL4jFCTKbXrzXAOQSLevI=",
        "X-Spam-Score": "-4.30",
        "X-Spam-Level": "",
        "X-Spamd-Result": "default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n NEURAL_HAM_LONG(-1.00)[-1.000];\n NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain];\n FUZZY_RATELIMITED(0.00)[rspamd.com];\n RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[];\n RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+];\n FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[];\n RCVD_COUNT_TWO(0.00)[2];\n DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email]",
        "X-Spam-Status": "No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no\n autolearn=disabled version=4.0.1",
        "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on in-4.smtp.seeweb.it",
        "X-Virus-Scanned": "clamav-milter 1.0.9 at in-4.smtp.seeweb.it",
        "X-Virus-Status": "Clean",
        "Subject": "[LTP] [PATCH] clock_settime: Detect external clock adjustments via\n 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>",
        "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.\n\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---\n .../conformance/interfaces/clock_settime/4-1.c     | 26 +++++++++++++++++\n .../conformance/interfaces/clock_settime/5-1.c     | 33 +++++++++++++++++++++-\n .../conformance/interfaces/clock_settime/5-2.c     | 33 +++++++++++++++++++++-\n .../conformance/interfaces/clock_settime/7-1.c     | 28 ++++++++++++++++++\n .../conformance/interfaces/clock_settime/7-2.c     | 31 +++++++++++++++++++-\n 5 files changed, 148 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..005d440985a71f62ede60b7696f6bd6f8d48f4b9 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,7 @@ int main(void)\n {\n \tstruct sigevent ev;\n \tstruct timespec tpT0, tpT2, tpreset;\n+\tstruct timespec mono_before, mono_after;\n \tstruct itimerspec its;\n \ttimer_t tid;\n \tint delta;\n@@ -82,6 +83,11 @@ int main(void)\n \t\treturn PTS_UNRESOLVED;\n \t}\n \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+\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@@ -116,10 +122,30 @@ int main(void)\n \n \tdelta = tpT2.tv_sec - its.it_value.tv_sec;\n \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// add back time waited to reset value and reset time\n \ttpreset.tv_sec += tpT2.tv_sec - tpT0.tv_sec;\n \tsetBackTime(tpreset);\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+\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..1d450c5f9feef0bafcfbb1b847bec33cb3e49a1f 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,11 @@ int main(void)\n \tstruct sigevent ev;\n \tstruct sigaction act;\n \tstruct timespec tsclock, ts, tsleft, tsreset;\n+\tstruct timespec mono_before, mono_after;\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@@ -97,6 +99,11 @@ int main(void)\n \t\treturn PTS_UNRESOLVED;\n \t}\n \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+\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 +119,31 @@ 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+\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+\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..67f90f2fb7d1d841c914614d57bccab1fe7d3537 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,11 @@ int main(void)\n \tstruct sigevent ev;\n \tstruct sigaction act;\n \tstruct timespec tsclock, ts, tsleft, tsreset;\n+\tstruct timespec mono_before, mono_after;\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@@ -97,6 +99,11 @@ int main(void)\n \t\treturn PTS_UNRESOLVED;\n \t}\n \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+\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 +119,31 @@ 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+\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+\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..ca325abb133195dad75f957f599a936a049bf657 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,7 @@\n int main(void)\n {\n \tstruct timespec tsT0, tsT1;\n+\tstruct timespec mono_before, mono_after;\n \tint pid;\n \n \t/* Check that we're root...can't call clock_settime with CLOCK_REALTIME otherwise */\n@@ -49,6 +50,11 @@ int main(void)\n \t\treturn PTS_UNRESOLVED;\n \t}\n \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+\n \tif ((pid = fork()) == 0) {\n \t\t/* child here */\n \t\tint flags = 0;\n@@ -100,9 +106,31 @@ int main(void)\n \t\t\treturn PTS_UNRESOLVED;\n \t\t}\n \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\tgetBeforeTime(&tsreset);\t// get current time\n \t\ttsreset.tv_sec += SMALLTIME;\n \t\tsetBackTime(tsreset);\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+\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..1eced660640881e559e8b739e1a59df8897b17d4 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@@ -58,13 +59,38 @@ int main(void)\n \t\t/* child here */\n \t\tint flags = 0;\n \t\tstruct timespec tsT3;\n+\t\tstruct timespec mono_start, mono_end;\n \n \t\tflags |= TIMER_ABSTIME;\n+\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+\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+\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+\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 +131,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": []
}