14f8ec0d39eb3ccf074f453d9d8ddedaff4d1d5c
[platform/core/system/libdbuspolicy.git] / src / test_runner.h
1 /* This file is part of test-runner (see template.c)
2  *
3  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4  * Author: Kazimierz Krosman <k.krosman@samsung.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17 */
18
19 #ifndef TEST_RUNNER_H
20 #define TEST_RUNNER_H
21 #include <stdbool.h>
22
23 #define TC_NAME "libdbuspolicy-tests"
24 #define TEST_PATH "/usr/lib/dbus-tests/test-suites/libdbuspolicy-tests/"
25 #define CYNARA_PATH TEST_PATH "cynara_prepare.sh"
26 #define MAX_TC_NUM 1024
27 #define MAX_BUFFER (64*1024)
28 #define MAX_COMMENT 1024
29
30 enum {
31         INIT_TEST,
32         NEW_STDOUT,
33         NEW_STDERR,
34         RESULT_CODE,
35         RESULT_SIGNAL,
36         RESULT_ERROR,
37         RESULT_TIMEOUT
38 };
39
40 struct test_result {
41         bool is_positive;
42         char comment[MAX_COMMENT];
43         char result[MAX_COMMENT];
44         char name[MAX_COMMENT];
45 };
46
47 struct test_case {
48         const char* name;
49         const char* description;
50 };
51
52 struct binary {
53         const char* path;
54         const char* name;
55         /* can be filled by asking binary */
56         struct test_case* test_cases;
57         int timeout;
58
59         char** (*prepare_args)(const struct binary* b, const char* test_name);
60         void (*parse)(const struct binary* b, const char* test_name, char* buffer, int state_change, int state_option);
61         int (*init)(void);
62         int (*clean)(void);
63 };
64
65 char* get_test_id(char *dest, size_t dest_len, const struct binary* b, const char* test_name);
66 void add_test_result(const char* test_id, const char* result, const char* comment, int res);
67
68
69 #endif /* TEST_RUNNER_H */