xref: /llvm-project/llvm/unittests/Support/ProcessTest.cpp (revision 97683aa2fa23dba3f860908e367453bfdfa5a9c0)
1 //===- unittest/Support/ProcessTest.cpp -----------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/Support/Process.h"
11 #include "gtest/gtest.h"
12 
13 #ifdef LLVM_ON_WIN32
14 #include "windows.h"
15 #endif
16 
17 namespace {
18 
19 using namespace llvm;
20 using namespace sys;
21 
22 TEST(ProcessTest, SelfProcess) {
23   EXPECT_TRUE(process::get_self());
24   EXPECT_EQ(process::get_self(), process::get_self());
25 
26 #if defined(LLVM_ON_UNIX)
27   EXPECT_EQ(getpid(), process::get_self()->get_id());
28 #elif defined(LLVM_ON_WIN32)
29   EXPECT_EQ(GetCurrentProcess(), process::get_self()->get_id());
30 #endif
31 }
32 
33 } // end anonymous namespace
34