FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
TestHandflow.c
1
20#include <stdio.h>
21#include <sys/stat.h>
22
23#ifndef _WIN32
24#include <termios.h>
25#endif
26
27#include <winpr/comm.h>
28#include <winpr/crt.h>
29
30#include "../comm.h"
31
32static BOOL test_SerialSys(HANDLE hComm)
33{
34 // TMP: TODO:
35 return TRUE;
36}
37
38int TestHandflow(int argc, char* argv[])
39{
40 struct stat statbuf = { 0 };
41 BOOL result = 0;
42 HANDLE hComm = NULL;
43
44 if (stat("/dev/ttyS0", &statbuf) < 0)
45 {
46 (void)fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
47 return EXIT_SUCCESS;
48 }
49
50 result = DefineCommDevice("COM1", "/dev/ttyS0");
51 if (!result)
52 {
53 (void)fprintf(stderr, "DefineCommDevice failure: 0x%x\n", GetLastError());
54 return EXIT_FAILURE;
55 }
56
57 hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
58 if (hComm == INVALID_HANDLE_VALUE)
59 {
60 (void)fprintf(stderr, "CreateFileA failure: 0x%x\n", GetLastError());
61 return EXIT_FAILURE;
62 }
63
64 _comm_setServerSerialDriver(hComm, SerialDriverSerialSys);
65 if (!test_SerialSys(hComm))
66 {
67 (void)fprintf(stderr, "test_SerCxSys failure\n");
68 return EXIT_FAILURE;
69 }
70
71 /* _comm_setServerSerialDriver(hComm, SerialDriverSerCxSys); */
72 /* if (!test_SerCxSys(hComm)) */
73 /* { */
74 /* (void)fprintf(stderr, "test_SerCxSys failure\n"); */
75 /* return EXIT_FAILURE; */
76 /* } */
77
78 /* _comm_setServerSerialDriver(hComm, SerialDriverSerCx2Sys); */
79 /* if (!test_SerCx2Sys(hComm)) */
80 /* { */
81 /* (void)fprintf(stderr, "test_SerCxSys failure\n"); */
82 /* return EXIT_FAILURE; */
83 /* } */
84
85 if (!CloseHandle(hComm))
86 {
87 (void)fprintf(stderr, "CloseHandle failure, GetLastError()=%08x\n", GetLastError());
88 return EXIT_FAILURE;
89 }
90
91 return EXIT_SUCCESS;
92}