Translation update done using Pootle.
[gammu.git] / tests / statemachine-init.c
blob57e187b3fb839e0b8d28069bba05dbbf67e8868c
1 #include <gammu.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <string.h>
6 #include "common.h"
8 #ifdef WIN32
9 # define NUL "NUL"
10 #else
11 # define NUL "/dev/null"
12 #endif
14 GSM_StateMachine *s;
16 void single_check(const char *device, const char *connection, const char *model, GSM_Error expected)
18 GSM_Config *smcfg;
19 GSM_Error error;
20 GSM_Debug_Info *debug_info;
22 /* Allocates state machine */
23 s = GSM_AllocStateMachine();
24 test_result(s != NULL);
26 debug_info = GSM_GetDebug(s);
27 GSM_SetDebugGlobal(TRUE, debug_info);
29 smcfg = GSM_GetConfig(s, 0);
30 strcpy(smcfg->Model, model);
31 smcfg->Device = strdup(device);
32 smcfg->UseGlobalDebugFile = TRUE;
33 smcfg->Connection = strdup(connection);
34 smcfg->PhoneFeatures[0] = F_PBK_ENCODENUMBER;
35 smcfg->PhoneFeatures[1] = 0;
36 GSM_SetConfigNum(s, 1);
38 error = GSM_InitConnection(s, 1);
39 test_result(error == expected);
41 /* Free state machine */
42 GSM_FreeStateMachine(s);
45 int main(int argc UNUSED, char **argv UNUSED)
47 GSM_Debug_Info *debug_info;
49 debug_info = GSM_GetGlobalDebug();
50 GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
51 GSM_SetDebugLevel("textall", debug_info);
53 single_check("/NONEXISTING/DEVICE/NODE", "NONSENSE", "", ERR_UNKNOWNCONNECTIONTYPESTRING);
54 #ifdef GSM_ENABLE_AT
55 single_check("/NONEXISTING/DEVICE/NODE", "at", "", ERR_DEVICENOTEXIST);
56 single_check("/NONEXISTING/DEVICE/NODE", "at-nodtr", "", ERR_DEVICENOTEXIST);
57 single_check("/NONEXISTING/DEVICE/NODE", "at19200-nopower", "", ERR_DEVICENOTEXIST);
58 single_check("/NONEXISTING/DEVICE/NODE", "at115200", "", ERR_DEVICENOTEXIST);
59 single_check("/NONEXISTING/DEVICE/NODE", "at", "at", ERR_DEVICENOTEXIST);
60 single_check("/NONEXISTING/DEVICE/NODE", "at", "atobex", ERR_DEVICENOTEXIST);
61 single_check(NUL, "at", "", ERR_DEVICEOPENERROR);
62 single_check(NUL, "at ", "", ERR_DEVICEOPENERROR);
63 #endif
64 #ifdef GSM_ENABLE_FBUS2DLR3
65 single_check("/NONEXISTING/DEVICE/NODE", "dlr3", "", ERR_DEVICENOTEXIST);
66 #ifndef WIN32
67 single_check("/dev/null ", "dlr3", "", ERR_DEVICEOPENERROR);
68 #endif
69 #endif
70 #ifdef GSM_ENABLE_DKU5FBUS2
71 single_check("/NONEXISTING/DEVICE/NODE", "dku5", "", ERR_DEVICENOTEXIST);
72 #ifndef WIN32
73 single_check("/dev/null ", "dku5", "", ERR_DEVICEOPENERROR);
74 #endif
75 #endif
77 return 0;
80 /* Editor configuration
81 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: