summaryrefslogtreecommitdiff
path: root/tests/unittest/tct-user-awareness-core.cpp
blob: 2aa899cea0660d388709a1310a6ca396ebc30f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include <stdio.h>
#include <string.h>
#include "tct_common.h"

#ifdef __cplusplus
extern "C" {
#endif

#include "tct-user-awareness-core.h"

#ifdef __cplusplus
}
#endif

#include <malloc.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <stdbool.h>

#include <gtest/gtest.h>

TEST(user_awareness, public)
{
    char *pszGetTCName = NULL;
    pszGetTCName = (char *)malloc(256);
    memset(pszGetTCName, 0x00, 256);
    strcpy(pszGetTCName, "utc_ua");
    int i = 0, result = 0;

    PRINT_LOG(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName);

    int successCnt = 0;
    int errorCnt = 0;
    for (i = 0; tc_array[i].name; i++) {
        if (0 == strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName))) {
            if (tc_array[i].startup)
                tc_array[i].startup();

            result = tc_array[i].function();
            if (result == 0) {
                successCnt++;
            } else {
                PRINT_LOG(DLOG_INFO, "NativeTCT", "[Error][%d] %s returns value = %d", i, tc_array[i].name, result);
                errorCnt++;
            }

            EXPECT_EQ(result, 0);
            // ASSERT_EQ(result, 0);
            if (tc_array[i].cleanup)
                tc_array[i].cleanup();
        } else {
            PRINT_LOG(DLOG_INFO, "NativeTCT", "Name check error! [%s][%s]", pszGetTCName, tc_array[i].name);
            errorCnt++;
        }
    }

    PRINT_LOG(DLOG_INFO, "NativeTCT", "==========================");
    PRINT_LOG(DLOG_INFO, "NativeTCT", "Success [%4d / %4d]", successCnt, successCnt + errorCnt);
    PRINT_LOG(DLOG_INFO, "NativeTCT", "Error   [%4d / %4d]", errorCnt, successCnt + errorCnt);
    PRINT_LOG(DLOG_INFO, "NativeTCT", "==========================");

    FREE_MEMORY_TC(pszGetTCName);
    return;
}

int main(int argc, char **argv)
{
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}