Fixed C client tests to work with new client version.

This commit is contained in:
Jason Watkins
2015-04-16 14:44:06 -07:00
parent b7ace82649
commit 556b3622ee

View File

@@ -16,12 +16,10 @@
int testFailed = 0; int testFailed = 0;
int testPassed = 0; int testPassed = 0;
void runTest(short (*f)()) void runTest(int (*test)(), char* name)
{ {
short result; int result = test(); // Run Test
printf("Test %i: %s - ", testPassed + testFailed + 1, name);
printf("Test %i: ",testPassed+testFailed+1);
result = (*f)(); // Run Test
if (result == 0) if (result == 0)
{ {
printf("PASSED\n"); printf("PASSED\n");
@@ -34,63 +32,54 @@ void runTest(short (*f)())
} }
} }
short openTest() // openUDP Test int openTest() // openUDP Test
{ {
printf("openUDP - "); XPCSocket sock = openUDP( 49062, "127.0.0.1", 49009 );
struct xpcSocket sendPort = openUDP( 49062, "127.0.0.1", 49009 ); closeUDP(sock);
return 0; return 0;
} }
short closeTest() // closeUDP test int closeTest() // closeUDP test
{ {
printf("closeUDP - "); XPCSocket sendPort = openUDP( 49063, "127.0.0.1", 49009 );
struct xpcSocket sendPort = openUDP( 49063, "127.0.0.1", 49009 );
closeUDP(sendPort); closeUDP(sendPort);
sendPort = openUDP(49063, "127.0.0.1", 49009); sendPort = openUDP(49063, "127.0.0.1", 49009);
closeUDP(sendPort); closeUDP(sendPort);
return 0; return 0;
} }
short sendReadTest() // send/read Test int sendReadTest() // send/read Test
{ {
printf("send/readUDP - ");
// Initialization // Initialization
int i; // Iterator
char test[] = {0, 1, 2, 3, 5}; char test[] = {0, 1, 2, 3, 5};
char buf[5] = {0}; char buf[5] = {0};
struct xpcSocket sendPort, recvPort; XPCSocket outSock = openUDP(49064, "127.0.0.1", 49063);
XPCSocket inSock = openUDP(49063, "127.0.0.1", 49009);
// Setup
sendPort = openUDP( 49064, "127.0.0.1", 49063 );
recvPort = openUDP( 49063, "127.0.0.1", 49009 );
// Execution // Execution
sendUDP( sendPort, test, sizeof(test) ); sendUDP(outSock, test, sizeof(test));
readUDP( recvPort, buf, NULL ); // Test readUDP(inSock, buf, sizeof(buf), NULL);
// Close // Close
closeUDP(sendPort); closeUDP(outSock);
closeUDP(recvPort); closeUDP(inSock);
// Tests // Tests
for (i=0; i<4; i++) for (int i = 0; i < sizeof(buf); i++)
{ {
if (test[i] != buf[i]) // Not received correctly if (test[i] != buf[i]) // Not received correctly
{ {
return -1; return -1;
} }
} }
return 0; return 0;
} }
short sendTEXTTest() int sendTEXTTest()
{ {
printf("sendTEXT - ");
// Setup // Setup
struct xpcSocket sendPort = openUDP(49064, "127.0.0.1", 49009); XPCSocket sendPort = openUDP(49064, "127.0.0.1", 49009);
int x = 100; int x = 100;
int y = 700; int y = 700;
char* msg = "XPlaneConnect test message. Now with 100% fewer new lines!"; char* msg = "XPlaneConnect test message. Now with 100% fewer new lines!";
@@ -104,262 +93,177 @@ short sendTEXTTest()
return 0; return 0;
} }
short requestDREFTest() // Request DREF Test (Required for next tests) int requestDREFTest() // Request DREF Test (Required for next tests)
{ {
printf("requestDREF - ");
// Initialization // Initialization
int i; // Iterator char* drefs[100] =
char DREFArray[100][100]; {
float *recDATA[100]; "sim/cockpit/switches/gear_handle_status",
short DREFSizes[100]; "sim/cockpit2/switches/panel_brightness_ratio"
struct xpcSocket sendPort, recvPort; };
short result = 0; float* data[100];
int sizes[100];
XPCSocket sock = openUDP(49064, "127.0.0.1", 49009);
// Setup // Setup
for (i = 0; i < 100; i++) { for (int i = 0; i < 100; ++i)
recDATA[i] = (float *) malloc(40*sizeof(float)); {
memset(DREFArray[i],0,100); data[i] = (float*)malloc(40 * sizeof(float));
} sizes[i] = 40;
sendPort = openUDP( 49064, "127.0.0.1", 49009 ); }
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status");
strcpy(DREFArray[1],"sim/cockpit2/switches/panel_brightness_ratio");
for (i=0;i<2;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
}
// Execution // Execution
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 2, recDATA, DREFSizes); int result = getDREFs(sock, drefs, data, 2, sizes);
// Close // Close
closeUDP(sendPort); closeUDP(sock);
closeUDP(recvPort);
// Tests // Tests
if ( result < 0)// Request 2 values if ( result < 0)// Request 2 values
{ {
return -1; return -1;
} }
if (DREFSizes[0] != 1 || DREFSizes[1] != 4) if (sizes[0] != 1 || sizes[1] != 4)
{ {
return -2; return -2;
} }
return 0; return 0;
} }
short sendDREFTest() // sendDREF test int sendDREFTest() // sendDREF test
{ {
printf("sendDREF - ");
// Initialization // Initialization
int i; // Iterator char* drefs[100] =
char DREFArray[100][100]; {
float *recDATA[100]; "sim/cockpit/switches/gear_handle_status"
short DREFSizes[100]; };
float value = 0.0; float* data[100];
struct xpcSocket sendPort, recvPort; int sizes[100];
short result = 0; XPCSocket sock = openUDP(49066, "127.0.0.1", 49009);
float value = 1.0F;
// Setup
for (i = 0; i < 100; i++) { // Setup
recDATA[i] = (float *) malloc(40*sizeof(float)); for (int i = 0; i < 100; ++i)
memset(DREFArray[i],0,100); {
} data[i] = (float*)malloc(40 * sizeof(float));
sendPort = openUDP( 49066, "127.0.0.1", 49009 ); sizes[i] = 40;
recvPort = openUDP( 49008, "127.0.0.1", 49009 ); }
strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status");
for (i=0;i<1;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
}
// Execution // Execution
sendDREF(sendPort, DREFArray[0], DREFSizes[0], &value, 1); setDREF(sock, drefs[0], &value, 1);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes); int result = getDREFs(sock, drefs, data, 1, sizes);
// Close // Close
closeUDP(sendPort); closeUDP(sock);
closeUDP(recvPort);
// Tests // Tests
if (result < 0)// Request 1 value if (result < 0)// Request 1 value
{ {
return -1; return -1;
} }
if (DREFSizes[0] != 1) if (sizes[0] != 1)
{ {
return -2; return -2;
} }
if (*recDATA[0] != value) if (data[0][0] != value)
{ {
return -3; return -3;
} }
return 0; return 0;
} }
short sendDATATest() // sendDATA test int sendDATATest() // sendDATA test
{ {
printf("sendData - ");
// Initialize // Initialize
int i,j; // Iterator int i,j; // Iterator
char DREFArray[100][100]; char* drefs[100] =
float data[4][9] = {0}; {
float *recDATA[100]; "sim/aircraft/parts/acf_gear_deploy"
short DREFSizes[100]; };
struct xpcSocket sendPort, recvPort; float* data[100];
short result = 0; int sizes[100];
float DATA[4][9];
// Setup XPCSocket sock = openUDP(49066, "127.0.0.1", 49009);
for (i = 0; i < 100; i++) {
recDATA[i] = (float *) malloc(40*sizeof(float)); // Setup
memset(DREFArray[i],0,100); for (int i = 0; i < 100; ++i)
} {
sendPort = openUDP( 49066, "127.0.0.1", 49009 ); data[i] = (float*)malloc(40 * sizeof(float));
recvPort = openUDP( 49008, "127.0.0.1", 49009 ); sizes[i] = 40;
strcpy(DREFArray[0],"sim/aircraft/parts/acf_gear_deploy"); }
for (i=0;i<1;i++) { for (i = 0; i < 4; i++)
DREFSizes[i] = (int) strlen(DREFArray[i]); {
} for (j = 0; j < 9; j++)
for (i=0;i<4;i++) { // Set array to -999 {
for (j=0;j<9;j++) data[i][j] = -999; data[i][j] = -998;
} }
}
data[0][0] = 14; // Gear data[0][0] = 14; // Gear
data[0][1] = 1; data[0][1] = 1;
data[0][2] = 0; data[0][2] = 0;
// Execution // Execution
sendDATA(sendPort, data, 1); // Gear sendDATA(sock, DATA, 1);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes); // Test int result = getDREFs(sock, drefs, data, 1, sizes);
// Close // Close
closeUDP(sendPort); closeUDP(sock);
closeUDP(recvPort);
// Tests // Tests
if ( result < 0 )// Request 1 value if ( result < 0 )// Request 1 value
{ {
return -1; return -1;
} }
if (DREFSizes[0] != 10) if (sizes[0] != 10)
{ {
return -2; return -2;
} }
if (*recDATA[0] != data[0][1]) if (*data[0] != data[0][1])
{ {
return -3; return -3;
} }
return 0; return 0;
} }
short sendCTRLTest() // sendCTRL test int psendCTRLTest() // sendCTRL test
{ {
printf("sendCTRL - ");
// Initialize // Initialize
int i; // Iterator char* drefs[100] =
char DREFArray[100][100]; {
float CTRL[6] = { 0.0 }; "sim/cockpit2/controls/yoke_pitch_ratio",
float *recDATA[100]; "sim/cockpit2/controls/yoke_roll_ratio",
short DREFSizes[100]; "sim/cockpit2/controls/yoke_heading_ratio",
struct xpcSocket sendPort, recvPort; "sim/flightmodel/engine/ENGN_thro",
short result; "sim/cockpit/switches/gear_handle_status",
"sim/flightmodel/controls/flaprqst"
};
float* data[100];
int sizes[100];
float CTRL[6] = { 0.0F, 0.0F, 0.0F, 0.8F, 1.0F, 0.5F };
XPCSocket sock = openUDP(49066, "127.0.0.1", 49009);
// Setup // Setup
for (i = 0; i < 100; i++) { for (int i = 0; i < 100; i++)
recDATA[i] = (float *)malloc(40 * sizeof(float)); {
memset(DREFArray[i], 0, 100); data[i] = (float*)malloc(40 * sizeof(float));
sizes[i] = 40;
} }
sendPort = openUDP(49066, "127.0.0.1", 49009);
recvPort = openUDP(49008, "127.0.0.1", 49009);
strcpy(DREFArray[0], "sim/cockpit2/controls/yoke_pitch_ratio");
strcpy(DREFArray[1], "sim/cockpit2/controls/yoke_roll_ratio");
strcpy(DREFArray[2], "sim/cockpit2/controls/yoke_heading_ratio");
strcpy(DREFArray[3], "sim/flightmodel/engine/ENGN_thro");
strcpy(DREFArray[4], "sim/cockpit/switches/gear_handle_status");
strcpy(DREFArray[5], "sim/flightmodel/controls/flaprqst");
for (i = 0; i < 100; i++) {
DREFSizes[i] = (int)strlen(DREFArray[i]);
}
CTRL[3] = 0.8; // Throttle
CTRL[4] = 1; // Gear
CTRL[5] = 0.5; // Flaps
// Execute // Execute
sendCTRL(sendPort, 6, CTRL); psendCTRL(sock, CTRL, 6);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test int result = getDREFs(sock, drefs, data, 6, sizes);
// Close // Close socket
closeUDP(sendPort); closeUDP(sock);
closeUDP(recvPort);
// Tests // Tests
if (result < 0)// Request 1 value if (result < 0)// Request 1 value
{ {
return -6; return -6;
} }
for (i = 0; i<6; i++) for (int i = 0; i < 6; i++)
{ {
if (fabs(recDATA[i][0] - CTRL[i])>1e-4) if (fabs(data[i][0] - CTRL[i]) > 1e-4)
{
return -i - 1;
}
}
return 0;
}
short sendpCTRLTest()
{
printf("sendNonPlayerCTRL - ");
// Initialize
int i; // Iterator
char DREFArray[100][100];
float CTRL[6] = { 0.0 };
float *recDATA[100];
short DREFSizes[100];
struct xpcSocket sendPort, recvPort;
short result;
// Setup
for (i = 0; i < 100; i++)
{
recDATA[i] = (float *)malloc(40 * sizeof(float));
memset(DREFArray[i], 0, 100);
}
sendPort = openUDP(49066, "127.0.0.1", 49009);
recvPort = openUDP(49008, "127.0.0.1", 49009);
strcpy(DREFArray[0], "sim/multiplayer/position/plane1_yolk_pitch");
strcpy(DREFArray[1], "sim/multiplayer/position/plane1_yolk_roll");
strcpy(DREFArray[2], "sim/multiplayer/position/plane1_yolk_yaw");
strcpy(DREFArray[3], "sim/multiplayer/position/plane1_throttle");
strcpy(DREFArray[4], "sim/multiplayer/position/plane1_gear_deploy");
strcpy(DREFArray[5], "sim/multiplayer/position/plane1_flap_ratio");
for (i = 0; i < 100; i++)
{
DREFSizes[i] = (int)strlen(DREFArray[i]);
}
CTRL[3] = 0.8; // Throttle
CTRL[4] = 1; // Gear
CTRL[5] = 0.5; // Flaps
// Execute
sendpCTRL(sendPort, 6, CTRL, 1);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 9, recDATA, DREFSizes); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Tests
if (result < 0)// Request 1 value
{
return -6;
}
for (i = 0; i<6; i++)
{
if (fabs(recDATA[i][0] - CTRL[i])>1e-4)
{ {
return -i - 1; return -i - 1;
} }
@@ -368,51 +272,85 @@ short sendpCTRLTest()
return 0; return 0;
} }
short sendPOSITest() // sendPOSI test int sendCTRLTest()
{
// Initialize
char* drefs[100] =
{
"sim/multiplayer/position/plane1_yolk_pitch",
"sim/multiplayer/position/plane1_yolk_roll",
"sim/multiplayer/position/plane1_yolk_yaw",
"sim/multiplayer/position/plane1_throttle",
"sim/multiplayer/position/plane1_gear_deploy",
"sim/multiplayer/position/plane1_flap_ratio",
};
float* data[100];
int sizes[100];
float CTRL[6] = { 0.0F, 0.0F, 0.0F, 0.8F, 1.0F, 0.5F };
XPCSocket sock = openUDP(49066, "127.0.0.1", 49009);
// Setup
for (int i = 0; i < 100; i++)
{
data[i] = (float*)malloc(40 * sizeof(float));
sizes[i] = 40;
}
// Execute
sendCTRL(sock, CTRL, 6, 1);
int result = getDREFs(sock, drefs, data, 6, sizes);
// Close socket
closeUDP(sock);
// Tests
if (result < 0)// Request 1 value
{
return -6;
}
for (int i = 0; i < 6; i++)
{
if (fabs(data[i][0] - CTRL[i]) > 1e-4)
{
return -i - 1;
}
}
return 0;
}
int sendPOSITest() // sendPOSI test
{ {
printf("sendPOSI - ");
// Initialization // Initialization
int i; // Iterator int i; // Iterator
char DREFArray[100][100]; char* drefs[100] =
float POSI[8] = {0.0}; {
float *recDATA[100]; "sim/flightmodel/position/latitude",
short DREFSizes[100]; "sim/flightmodel/position/longitude",
struct xpcSocket sendPort, recvPort; "sim/flightmodel/position/y_agl",
short result; "sim/flightmodel/position/phi",
"sim/flightmodel/position/theta",
"sim/flightmodel/position/psi",
"sim/cockpit/switches/gear_handle_status"
};
float* data[100];
int sizes[100];
float POSI[8] = { 37.524F, -122.06899F, 2500, 0, 0, 0, 1 };
XPCSocket sock = openUDP(49063, "127.0.0.1", 49009);
// Setup // Setup
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++)
recDATA[i] = (float *) malloc(40*sizeof(float)); {
memset(DREFArray[i],0,100); data[i] = (float*)malloc(40 * sizeof(float));
sizes[i] = 40;
} }
sendPort = openUDP( 49063, "127.0.0.1", 49009 );
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
strcpy(DREFArray[0],"sim/flightmodel/position/latitude");
strcpy(DREFArray[1],"sim/flightmodel/position/longitude");
strcpy(DREFArray[2],"sim/flightmodel/position/y_agl");
strcpy(DREFArray[3],"sim/flightmodel/position/phi");
strcpy(DREFArray[4],"sim/flightmodel/position/theta");
strcpy(DREFArray[5],"sim/flightmodel/position/psi");
strcpy(DREFArray[6],"sim/cockpit/switches/gear_handle_status");
for (i=0;i<7;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
}
POSI[0] = 37.524; // Lat
POSI[1] = -122.06899; // Lon
POSI[2] = 2500; // Alt
POSI[3] = 0; // Pitch
POSI[4] = 0; // Roll
POSI[5] = 0; // Heading
POSI[6] = 1; // Gear
// Execution // Execution
sendPOSI( sendPort, 0, 7, POSI ); sendPOSI(sock, POSI, 7, 0);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 7, recDATA, DREFSizes); // Test int result = getDREFs(sock, drefs, data, 7, sizes);
// Close // Close
closeUDP(sendPort); closeUDP(sock);
closeUDP(recvPort);
// Tests // Tests
if ( result < 0 )// Request 1 value if ( result < 0 )// Request 1 value
@@ -421,114 +359,104 @@ short sendPOSITest() // sendPOSI test
} }
for (i=0;i<7-1;i++) for (i=0;i<7-1;i++)
{ {
if (i==2) if (i == 2)
{ {
continue; continue;
} }
if (fabs(recDATA[i][0]-POSI[i])>1e-4) if (fabs(data[i][0] - POSI[i]) > 1e-4)
{ {
return -i; return -i;
} }
} }
return 0; return 0;
} }
short sendWYPTTest() int sendWYPTTest()
{ {
printf("sendWYPT - ");
// Setup // Setup
struct xpcSocket sendPort = openUDP(49064, "127.0.0.1", 49009); XPCSocket sock = openUDP(49064, "127.0.0.1", 49009);
float points[] = float points[] =
{ {
37.5245, -122.06899, 2500, 37.5245F, -122.06899F, 2500,
37.455397, -122.050037, 2500, 37.455397F, -122.050037F, 2500,
37.469567, -122.051411, 2500, 37.469567F, -122.051411F, 2500,
37.479376, -122.060509, 2300, 37.479376F, -122.060509F, 2300,
37.482237, -122.076130, 2100, 37.482237F, -122.076130F, 2100,
37.474881, -122.087288, 1900, 37.474881F, -122.087288F, 1900,
37.467660, -122.079391, 1700, 37.467660F, -122.079391F, 1700,
37.466298, -122.090549, 1500, 37.466298F, -122.090549F, 1500,
37.362562, -122.039223, 1000, 37.362562F, -122.039223F, 1000,
37.361448, -122.034416, 1000, 37.361448F, -122.034416F, 1000,
37.361994, -122.026348, 1000, 37.361994F, -122.026348F, 1000,
37.365541, -122.022572, 1000, 37.365541F, -122.022572F, 1000,
37.373727, -122.024803, 1000, 37.373727F, -122.024803F, 1000,
37.403869, -122.041283, 50, 37.403869F, -122.041283F, 50,
37.418544, -122.049222, 6 37.418544F, -122.049222F, 6
}; };
// Test // Test
sendWYPT(sendPort, xpc_WYPT_ADD, points, 15); sendWYPT(sock, XPC_WYPT_ADD, points, 15);
// NOTE: Visually ensure waypoints are added in the sim
// Cleanup // Cleanup
closeUDP(sendPort); closeUDP(sock);
return 0; return 0;
} }
short pauseTest() // pauseSim test int pauseTest() // pauseSim test
{ {
printf("pauseSim - ");
// Initialize // Initialize
int i; // Iterator int i; // Iterator
char DREFArray[100][100]; char* drefs[100] =
float *recDATA[100]; {
short DREFSizes[100],RECSizes[100]; "sim/operation/override/override_planepath"
struct xpcSocket sendPort, recvPort; };
short result; float* data[100];
int sizes[100];
XPCSocket sock = openUDP(49064, "127.0.0.1", 49009);
// Setup // Setup
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++)
recDATA[i] = (float *) malloc(40*sizeof(float)); {
memset(DREFArray[i],0,100); data[i] = (float*)malloc(40 * sizeof(float));
} sizes[i] = 40;
// Setup
sendPort = openUDP( 49064, "127.0.0.1", 49009 );
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
strcpy(DREFArray[0],"sim/operation/override/override_planepath");
for (i=0;i<1;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
} }
// Execute // Execute
pauseSim(sendPort, 1); pauseSim(sock, 1);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test int result = getDREF(sock, drefs[0], data[0], sizes);
// Close // Close
closeUDP(sendPort); closeUDP(sock);
closeUDP(recvPort);
// Test // Test
if (result < 0) { if (result < 0)
{
return -1; return -1;
} }
if (recDATA[0][0] != 1) if (data[0][0] != 1)
{ {
return -2; return -2;
} }
// Reopen // Reopen
sendPort = openUDP( 49064, "127.0.0.1", 49009 ); sock = openUDP(49064, "127.0.0.1", 49009);
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
// Execute 2 // Execute 2
pauseSim(sendPort, 0); pauseSim(sock, 0);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test result = getDREF(sock, drefs[0], data[0], sizes);
// Close 2 // Close 2
closeUDP(sendPort); closeUDP(sock);
closeUDP(recvPort);
// Test 2 // Test 2
if (result < 0) if (result < 0)
{ {
return -3; return -3;
} }
if (recDATA[0][0] != 0) if (data[0][0] != 0)
{ {
return -4; return -4;
} }
@@ -536,48 +464,46 @@ short pauseTest() // pauseSim test
return 0; return 0;
} }
short connTest() // setConn test int connTest() // setConn test
{ {
printf("setConn - ");
// Initialize // Initialize
int i; // Iterator char* drefs[100] =
char DREFArray[100][100]; {
float *recDATA[100]; "sim/cockpit/switches/gear_handle_status"
short DREFSizes[100]; };
struct xpcSocket sendPort, recvPort; float* data[100];
short result = 0; int sizes[100];
XPCSocket sock = openUDP(49067, "127.0.0.1", 49009);
#if (__APPLE__ || __linux) #if (__APPLE__ || __linux)
usleep(0); usleep(0);
#endif #endif
// Setup // Setup
sendPort = openUDP( 49067, "127.0.0.1", 49009 ); for (int i = 0; i < 100; ++i)
recvPort = openUDP( 49055, "127.0.0.1", 49009 ); {
strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status"); data[i] = (float*)malloc(40 * sizeof(float));
for (i=0;i<1;i++) { sizes[i] -= 40;
DREFSizes[i] = (int) strlen(DREFArray[i]); }
}
// Execution // Execution
setCONN(sendPort, 49055); sock.port = 49055;
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes); // Test setCONN(sock);
int result = getDREF(sock, drefs[0], data[0], sizes);
// Close // Close
closeUDP(sendPort); closeUDP(sock);
closeUDP(recvPort);
// Test // Test
if ( result < 0 )// No data received if ( result < 0 )// No data received
{ {
return -1; return -1;
} }
// Set up for next test // Set up for next test
sendPort = openUDP( 49067, "127.0.0.1", 49009 ); sock = openUDP( 49055, "127.0.0.1", 49009 );
setCONN(sendPort, 49008); sock.port = 49008;
closeUDP(sendPort); setCONN(sock);
closeUDP(sock);
return 0; return 0;
} }
@@ -593,19 +519,19 @@ int main(int argc, const char * argv[])
printf("(Linux) \n"); printf("(Linux) \n");
#endif #endif
runTest(openTest); runTest(openTest, "open");
runTest(closeTest); runTest(closeTest, "close");
runTest(sendReadTest); runTest(sendReadTest, "send/read");
runTest(sendTEXTTest); runTest(sendTEXTTest, "TEXT");
runTest(requestDREFTest); runTest(requestDREFTest, "GETD");
runTest(sendDREFTest); runTest(sendDREFTest, "DREF");
runTest(sendDATATest); runTest(sendDATATest, "DATA");
runTest(sendCTRLTest); runTest(sendCTRLTest, "CTRL");
runTest(sendpCTRLTest); runTest(psendCTRLTest, "CTRL (player)");
runTest(sendPOSITest); runTest(sendPOSITest, "POSI");
runTest(sendWYPTTest); runTest(sendWYPTTest, "WYPT");
runTest(pauseTest); runTest(pauseTest, "SIMU");
runTest(connTest); runTest(connTest, "CONN");
printf( "----------------\nTest Summary\n\tFailed: %i\n\tPassed: %i\n", testFailed, testPassed ); printf( "----------------\nTest Summary\n\tFailed: %i\n\tPassed: %i\n", testFailed, testPassed );