unistd_test.cpp revision 428f5567be25b8090e3dd72e2d3d337c305b514e
1a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes/*
2a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * Copyright (C) 2012 The Android Open Source Project
3a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes *
4a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License");
5a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * you may not use this file except in compliance with the License.
6a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * You may obtain a copy of the License at
7a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes *
8a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes *      http://www.apache.org/licenses/LICENSE-2.0
9a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes *
10a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * Unless required by applicable law or agreed to in writing, software
11a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS,
12a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * See the License for the specific language governing permissions and
14a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes * limitations under the License.
15a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes */
16a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes
17a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes#include <gtest/gtest.h>
18a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes
19428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes#include <stdint.h>
20a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes#include <unistd.h>
21a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes
22a55f63083fb16b2595f517a3260083e5f8cddd02Elliott HughesTEST(unistd, sysconf_SC_MONOTONIC_CLOCK) {
23a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes  ASSERT_GT(sysconf(_SC_MONOTONIC_CLOCK), 0);
24a55f63083fb16b2595f517a3260083e5f8cddd02Elliott Hughes}
25428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes
26428f5567be25b8090e3dd72e2d3d337c305b514eElliott HughesTEST(unistd, sbrk) {
27428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes  void* initial_break = sbrk(0);
28428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes
29428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes  void* new_break = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(initial_break) + 2000);
30428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes  ASSERT_EQ(0, brk(new_break));
31428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes
32428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes  void* final_break = sbrk(0);
33428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes  ASSERT_EQ(final_break, new_break);
34428f5567be25b8090e3dd72e2d3d337c305b514eElliott Hughes}
35