summaryrefslogtreecommitdiff
path: root/libc/test/src/unistd/getsid_test.cpp
blob: e9973487c9f2798c8dc1912e67af879ac8d04f01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//===-- Unittests for getsid ----------------------------------------------===//
//
// 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 "src/unistd/getsid.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/Test.h"

using LlvmLibcGetSidTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;

TEST_F(LlvmLibcGetSidTest, GetCurrSID) {
  pid_t sid = LIBC_NAMESPACE::getsid(0);
  ASSERT_NE(sid, -1);
  ASSERT_ERRNO_SUCCESS();

  pid_t nonexist_sid = LIBC_NAMESPACE::getsid(-1);
  ASSERT_EQ(nonexist_sid, -1);
  ASSERT_ERRNO_FAILURE();
}