Fix the gcov build error
[platform/core/api/tethering.git] / tests / mocks / tethering_dummy_client.c
1 /*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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 "tethering_dummy_client.h"
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <time.h>
23
24 #define TETHERING_STR_INFO_LEN  40
25
26 typedef struct {
27         int interface;
28         char ip[TETHERING_STR_INFO_LEN];
29         char mac[TETHERING_STR_INFO_LEN];
30         char *hostname;
31         time_t tm;
32 } __tethering_client_h;
33
34 void tethering_mock_create_dummy_client(void **dummy_client)
35 {
36         __tethering_client_h *client = NULL;
37
38         client = malloc(sizeof(__tethering_client_h));
39
40         client->interface = 2; // wifi
41         snprintf(client->ip, TETHERING_STR_INFO_LEN - 1, "%s", "192.168.43.125");
42         snprintf(client->mac, TETHERING_STR_INFO_LEN - 1, "%s", "AB:CD:EF:AB:CD:EF");
43         client->hostname = strdup("tethering-gtest");
44         time(&client->tm);
45
46         *dummy_client = (void *)client;
47 }
48
49 void tethering_mock_destroy_dummy_client(void *dummy_client)
50 {
51         __tethering_client_h *client = (__tethering_client_h *)dummy_client;
52
53         if (!client)
54                 return;
55
56         free(client->hostname);
57         free(client);
58 }