winpr-comm: made the unit tests to succeed when /dev/ttyS0 is not available

This commit is contained in:
Emmanuel Ledoux 2014-07-03 19:01:45 +02:00 committed by Emmanuel Ledoux
parent d1a7e8c3b8
commit 94dfce4f52
7 changed files with 58 additions and 7 deletions

View File

@ -18,6 +18,8 @@
* limitations under the License.
*/
#include <sys/stat.h>
#include <winpr/crt.h>
#include <winpr/comm.h>
#include <winpr/file.h>
@ -31,6 +33,7 @@ int TestCommConfig(int argc, char* argv[])
BOOL success;
LPCSTR lpFileName = "\\\\.\\COM1";
COMMPROP commProp;
struct stat statbuf;
hComm = CreateFileA(lpFileName,
GENERIC_READ | GENERIC_WRITE,
@ -42,7 +45,12 @@ int TestCommConfig(int argc, char* argv[])
return EXIT_FAILURE;
}
// TMP: FIXME: check if we can proceed with tests on the actual device, skip and warn otherwise but don't fail
if (stat("/dev/ttyS0", &statbuf) < 0)
{
fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
return EXIT_SUCCESS;
}
success = DefineCommDevice(lpFileName, "/dev/ttyS0");
if(!success)
{

View File

@ -19,6 +19,8 @@
#include <stdio.h>
#include <sys/stat.h>
#include <winpr/comm.h>
#include <winpr/crt.h>
@ -26,11 +28,17 @@
int TestControlSettings(int argc, char* argv[])
{
struct stat statbuf;
BOOL result;
HANDLE hComm;
DCB dcb;
// TMP: FIXME: check if we can proceed with tests on the actual device, skip and warn otherwise but don't fail
if (stat("/dev/ttyS0", &statbuf) < 0)
{
fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
return EXIT_SUCCESS;
}
result = DefineCommDevice("COM1", "/dev/ttyS0");
if (!result)
{

View File

@ -18,6 +18,7 @@
*/
#include <stdio.h>
#include <sys/stat.h>
#include <winpr/comm.h>
#include <winpr/crt.h>
@ -72,10 +73,16 @@ static BOOL test_generic(HANDLE hComm)
int TestGetCommState(int argc, char* argv[])
{
struct stat statbuf;
BOOL result;
HANDLE hComm;
// TMP: FIXME: check if we can proceed with tests on the actual device, skip and warn otherwise but don't fail
if (stat("/dev/ttyS0", &statbuf) < 0)
{
fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
return EXIT_SUCCESS;
}
result = DefineCommDevice("COM1", "/dev/ttyS0");
if (!result)
{

View File

@ -18,6 +18,7 @@
*/
#include <stdio.h>
#include <sys/stat.h>
#include <termios.h>
#include <winpr/comm.h>
@ -34,10 +35,16 @@ static BOOL test_SerialSys(HANDLE hComm)
int TestHandflow(int argc, char* argv[])
{
struct stat statbuf;
BOOL result;
HANDLE hComm;
// TMP: FIXME: check if we can proceed with tests on the actual device, skip and warn otherwise but don't fail
if (stat("/dev/ttyS0", &statbuf) < 0)
{
fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
return EXIT_SUCCESS;
}
result = DefineCommDevice("COM1", "/dev/ttyS0");
if (!result)
{

View File

@ -18,6 +18,7 @@
*/
#include <stdio.h>
#include <sys/stat.h>
#include <termios.h>
#include <winpr/comm.h>
@ -128,10 +129,16 @@ static BOOL test_SerCx2Sys(HANDLE hComm)
int TestSerialChars(int argc, char* argv[])
{
struct stat statbuf;
BOOL result;
HANDLE hComm;
// TMP: FIXME: check if we can proceed with tests on the actual device, skip and warn otherwise but don't fail
if (stat("/dev/ttyS0", &statbuf) < 0)
{
fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
return EXIT_SUCCESS;
}
result = DefineCommDevice("COM1", "/dev/ttyS0");
if (!result)
{

View File

@ -18,6 +18,7 @@
*/
#include <stdio.h>
#include <sys/stat.h>
#include <winpr/comm.h>
#include <winpr/crt.h>
@ -317,10 +318,16 @@ static BOOL test_generic(HANDLE hComm)
int TestSetCommState(int argc, char* argv[])
{
struct stat statbuf;
BOOL result;
HANDLE hComm;
// TMP: FIXME: check if we can proceed with tests on the actual device, skip and warn otherwise but don't fail
if (stat("/dev/ttyS0", &statbuf) < 0)
{
fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
return EXIT_SUCCESS;
}
result = DefineCommDevice("COM1", "/dev/ttyS0");
if (!result)
{

View File

@ -18,6 +18,7 @@
*/
#include <stdio.h>
#include <sys/stat.h>
#include <termios.h>
#include <winpr/comm.h>
@ -75,10 +76,16 @@ static BOOL test_generic(HANDLE hComm)
int TestTimeouts(int argc, char* argv[])
{
struct stat statbuf;
BOOL result;
HANDLE hComm;
// TMP: FIXME: check if we can proceed with tests on the actual device, skip and warn otherwise but don't fail
if (stat("/dev/ttyS0", &statbuf) < 0)
{
fprintf(stderr, "/dev/ttyS0 not available, making the test to succeed though\n");
return EXIT_SUCCESS;
}
result = DefineCommDevice("COM1", "/dev/ttyS0");
if (!result)
{