11 # define NUL "/dev/null"
14 GSM_Error
GSM_USB_ParseDevice(GSM_StateMachine
*s
, int *vendor
, int *product
, int *bus
, int *deviceid
, char **serial
);
16 int vendor
= -1, product
= -1, bus
= -1, deviceid
= -1;
19 GSM_Debug_Info
*debug_info
;
22 void single_check(const char *string
, int vendor_match
, int product_match
, int bus_match
, int deviceid_match
, const char *serial_match
)
24 cfg
->Device
= strdup(string
);
25 GSM_USB_ParseDevice(s
, &vendor
, &product
, &bus
, &deviceid
, &serial
);
26 test_result(vendor
== vendor_match
);
27 test_result(product
== product_match
);
28 test_result(bus
== bus_match
);
29 test_result(deviceid
== deviceid_match
);
30 test_result((serial
== NULL
&& serial_match
== NULL
) || strcmp(serial
, serial_match
) == 0);
35 int main(int argc UNUSED
, char **argv UNUSED
)
37 debug_info
= GSM_GetGlobalDebug();
38 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
39 GSM_SetDebugLevel("textall", debug_info
);
41 s
= GSM_AllocStateMachine();
42 test_result(s
!= NULL
);
44 cfg
= GSM_GetConfig(s
, -1);
46 debug_info
= GSM_GetDebug(s
);
47 GSM_SetDebugGlobal(TRUE
, debug_info
);
49 single_check("0x1234:0x5678", 0x1234, 0x5678, -1, -1, NULL
);
50 single_check("1234:5678", 1234, 5678, -1, -1, NULL
);
51 single_check("0x1234:-1", 0x1234, -1, -1, -1, NULL
);
52 single_check("1.10", -1, -1, 1, 10, NULL
);
53 single_check("10", -1, -1, -1, 10, NULL
);
54 single_check("serial:123456", -1, -1, -1, -1, "123456");
55 single_check("serial : 123456", -1, -1, -1, -1, "123456");
57 /* Free state machine */
58 GSM_FreeStateMachine(s
);
63 /* Editor configuration
64 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: