blob: eff9c711a1ad0fee31a7d5f5c27e6aab0c6ada76 [file] [log] [blame]
Chandler Carruth0184a842012-12-31 11:17:50 +00001//===- 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
17namespace {
18
19using namespace llvm;
20using namespace sys;
21
22TEST(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)
Aaron Ballman0c793012013-06-08 20:29:03 +000029 EXPECT_EQ(GetCurrentProcessId(), process::get_self()->get_id());
Chandler Carruth0184a842012-12-31 11:17:50 +000030#endif
Chandler Carruth814afe92012-12-31 23:23:35 +000031
32 EXPECT_LT(1u, process::get_self()->page_size());
Chandler Carruth73c35d82013-01-04 23:19:55 +000033
34 EXPECT_LT(TimeValue::MinTime, process::get_self()->get_user_time());
35 EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_user_time());
36 EXPECT_LT(TimeValue::MinTime, process::get_self()->get_system_time());
37 EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_system_time());
38 EXPECT_LT(TimeValue::MinTime, process::get_self()->get_wall_time());
39 EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_wall_time());
Chandler Carruth0184a842012-12-31 11:17:50 +000040}
41
42} // end anonymous namespace