[libc-commits] [libc] [libc][POSIX][pthreads] implement pthread_condattr_t functions (PR #88987)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Tue Apr 16 15:22:33 PDT 2024


================
@@ -0,0 +1,70 @@
+//===-- Unittests for pthread_condattr_t ----------------------------------===//
+//
+// 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 "test/UnitTest/Test.h"
+
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+TEST(LlvmLibcPThreadCondAttrTest, InitAndDestroy) {
+  pthread_condattr_t cond;
+  ASSERT_EQ(pthread_condattr_init(&cond), 0);
+  ASSERT_EQ(pthread_condattr_destroy(&cond), 0);
+}
+
+TEST(LlvmLibcPThreadCondAttrTest, GetDefaultValues) {
+  pthread_condattr_t cond;
+
+  // Invalid clock id.
+  clockid_t clock = 7;
+  // Invalid value.
+  int pshared = 42;
+
+  ASSERT_EQ(pthread_condattr_init(&cond), 0);
+  ASSERT_EQ(pthread_condattr_getclock(&cond, &clock), CLOCK_REALTIME);
----------------
nickdesaulniers wrote:

bug! (because `CLOCK_REALTIME == 0`)

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


More information about the libc-commits mailing list