2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "file_mock.h"
22 extern FILE *__real_fopen(const char *filename, const char *modes);
23 extern FILE *__real_fopen64(const char *filename, const char *modes);
24 extern char *__real_fgets(char *s, int n, FILE * stream);
25 extern int __real_fclose(FILE *stream);
27 static bool flag_ = false;
29 void fopen_mock_setup(bool flag) {
33 FILE* __wrap_fopen(const char *filename, const char *modes) {
35 return __real_fopen(filename, modes);
40 FILE* __wrap_fopen64(const char *filename, const char *modes) {
42 return __real_fopen64(filename, modes);
47 char * __wrap_fgets(char *s, int n, FILE *stream) {
49 return __real_fgets(s, n, stream);
51 char buf[1024] = "30005";
52 printf("wrap_fopen called\n");
53 snprintf(s, n, "%s", buf);
58 int __wrap_fclose(FILE *stream) {
60 return __real_fclose(stream);