-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_common.h
86 lines (72 loc) · 2.95 KB
/
test_common.h
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
/*
*
* Copyright (C) 2022 University of Bamberg, Software Technologies Research Group
* <https://www.uni-bamberg.de/>, <http://www.swt-bamberg.de/>
*
* This file is part of the BiDiB library (libbidib), used to communicate with
* BiDiB <www.bidib.org> systems over a serial connection. This library was
* developed as part of Nicolas Gross’ student project.
*
* libbidib is licensed under the GNU GENERAL PUBLIC LICENSE (Version 3), see
* the LICENSE file at the project's top-level directory for details or consult
* <http://www.gnu.org/licenses/>.
*
* libbidib is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or any later version.
*
* libbidib is a RESEARCH PROTOTYPE and distributed WITHOUT ANY WARRANTY, without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* The following people contributed to the conception and realization of the
* present libbidib (in alphabetic order by surname):
*
* - Christof Lehanka <https://github.com/clehanka>
* - Bernhard Luedtke <https://github.com/BLuedtke>
* - Eugene Yip <https://github.com/eyip002>
*
*/
#ifndef TEST_COMMON_H
#define TEST_COMMON_H
#include "../../include/bidib.h"
#include <stdint.h>
#include <stdbool.h>
typedef struct {
int stateError;
int stateNotReached;
int stateNotReachedVerified;
int stateReached;
int stateReachedVerified;
int unknownState;
} t_testsuite_point_result;
typedef struct {
t_testsuite_point_result *points;
} t_testsuite_test_result;
typedef struct {
char **ids;
size_t length;
} t_testsuite_ids;
extern t_bidib_id_list_query points;
extern t_bidib_id_list_query signals;
// Setup
t_testsuite_test_result *testsuite_initTestSuite_common(char **excludedSignalAccessories, size_t excludedSignalAccessories_len);
t_bidib_id_list_query testsuite_filterOutIds(t_bidib_id_list_query inputIdQuery, t_testsuite_ids filterOutIds);
// Teardown
void testsuite_stopBidib(void);
void testsuite_signal_callback_handler(int signum);
// Logging
void testsuite_logTestResult(t_testsuite_test_result *result, t_bidib_unified_accessory_state_query state, int accessory_index);
void testsuite_printTestResults(t_testsuite_test_result *result);
// Driving
bool testsuite_trainReady(const char *train, const char *segment);
void testsuite_driveTo(const char *segment, int speed, const char *train);
void testsuite_driveToStop(const char *segment, int speed, const char *train);
// Accessories
void testsuite_set_signal(const char *signal, const char *aspect);
void testsuite_switch_point(const char *point, const char *aspect);
// Common test base
void testsuite_case_signal_common(char **aspects, size_t aspects_len);
void testsuite_case_pointParallel_common(t_testsuite_test_result *result);
void testsuite_case_pointSerial_common(t_testsuite_test_result *result);
#endif