[libc-commits] [libc] [libc][POSIX] Add clock_settime() function for Linux (PR #161729)

Anton Shepelev via libc-commits libc-commits at lists.llvm.org
Mon Oct 27 23:00:42 PDT 2025


================
@@ -0,0 +1,31 @@
+//===-- Unittests for clock_settime ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "hdr/time_macros.h"
+#include "hdr/types/struct_timespec.h"
+#include "src/time/clock_settime.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
+#include "test/UnitTest/Test.h"
+
+using LlvmLibcClockSetTime = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
+
----------------
amemov wrote:

Done. I did a deeper dive in how the testing is done for functions that require super user and saw some tests following this path: 
```
if (LIBC_NAMESPACE::getuid() == 0)
    do_something();
```
I was not sure it would be a good idea to have it like in the test for CI, so I wrote it a little bit differently. 

https://github.com/llvm/llvm-project/pull/161729


More information about the libc-commits mailing list