1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <errno.h>
18 #include <stdio.h>
19 #include <string.h>
20 #include <sys/stat.h>
21 #include <unistd.h>
22 
23 /* These stubs exist mostly to support gtest. */
24 
fopen(const char * restrict filename,const char * restrict mode)25 FILE* fopen(const char* restrict filename, const char* restrict mode) {
26     errno = ENOENT;
27     return NULL;
28 }
29 
30 /*
31  * gtest expects getcwd to return a non-empty string, otherwise it will error
32  * internally.
33  */
getcwd(char * buf,size_t size)34 char* getcwd(char* buf, size_t size) {
35     strncpy(buf, "/", size);
36     return buf;
37 }
38 
isatty(int fd)39 int isatty(int fd) {
40     return 0;
41 }
42 
remove(const char * pathname)43 int remove(const char* pathname) {
44     errno = EACCES;
45     return -1;
46 }
47 
mkdir(const char * pathname,mode_t mode)48 int mkdir(const char* pathname, mode_t mode) {
49     errno = EACCES;
50     return -1;
51 }
52 
stat(const char * path,struct stat * buf)53 int stat(const char* path, struct stat* buf) {
54     errno = EACCES;
55     return -1;
56 }
57