Testing improvements- C/C++

This commit is contained in:
Chris Teubert
2014-12-01 15:36:37 -08:00
parent 9ea7011bfb
commit 851cebeea0
7 changed files with 375 additions and 80 deletions

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<VariablesViewState
version = "1.0">
<ContextStates>
<ContextState
contextName = "parseRequest:xplaneConnect.c">
<PersistentStrings>
<PersistentString
value = "resultArray[i]">
</PersistentString>
</PersistentStrings>
</ContextState>
</ContextStates>
</VariablesViewState>

View File

@@ -2,4 +2,180 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "C Tests/main.c"
timestampString = "439166919.543326"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "368"
endingLineNumber = "368"
landmarkName = "test9()"
landmarkType = "7">
<Locations>
<Location
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "test9"
moduleName = "C Tests"
urlString = "file:///Users/cteubert/Documents/XPC%20Project/XPlaneConnect/TestScripts/C%20Tests/main.c"
timestampString = "439166920.353158"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "368"
endingLineNumber = "368"
offsetFromSymbolStart = "39">
</Location>
<Location
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "test9"
moduleName = "C Tests"
urlString = "file:///Users/cteubert/Documents/XPC%20Project/XPlaneConnect/TestScripts/C%20Tests/main.c"
timestampString = "439166920.355533"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "368"
endingLineNumber = "368"
offsetFromSymbolStart = "133">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "C Tests/main.c"
timestampString = "439166958.157499"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "371"
endingLineNumber = "371"
landmarkName = "test9()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "C Tests/main.c"
timestampString = "439166960.12566"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "372"
endingLineNumber = "372"
landmarkName = "test9()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "C Tests/main.c"
timestampString = "439166980.676448"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "383"
endingLineNumber = "383"
landmarkName = "test9()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../C/src/xplaneConnect.c"
timestampString = "439168827.040532"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "584"
endingLineNumber = "584"
landmarkName = "parseRequest()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "C Tests/main.c"
timestampString = "439168847.889951"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "327"
endingLineNumber = "327"
landmarkName = "test8()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "C Tests/main.c"
timestampString = "439168878.242947"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "369"
endingLineNumber = "369"
landmarkName = "test9()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "C Tests/main.c"
timestampString = "439168983.670569"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "411"
endingLineNumber = "411"
landmarkName = "test9()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "C Tests/main.c"
timestampString = "439169099.982578"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "412"
endingLineNumber = "412"
landmarkName = "test9()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@@ -44,6 +44,7 @@ short test2() // closeUDP test
printf("closeUDP - ");
struct xpcSocket sendPort = openUDP( 49063, "127.0.0.1", 49009 );
closeUDP(sendPort);
sendPort = openUDP( 49063, "127.0.0.1", 49009 );
return 0;
}
@@ -240,41 +241,47 @@ short test7() // sendCTRL test
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( 49067, "127.0.0.1", 49009 );
sendPort = openUDP( 49066, "127.0.0.1", 49009 );
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status");
for (i=0;i<1;i++) {
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/flaprqsts");
for (i=0;i<5;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
}
CTRL[3] = 0.8; // Throttle
// Execute
sendCTRL(sendPort, 4, CTRL);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Test
// if (requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes) < 0)// Request 1 value
// {
// return -1;
// }
// if (DREFSizes[0] != 1)
// {
// return -2;
// }
// if (*recDATA[0] != value)
// {
// return -3;
// }
// Tests
if ( result < 0 )// Request 1 value
{
return -6;
}
for (i=0;i<6-1;i++)
{
if (abs(recDATA[i][0]-CTRL[i])>1e-4)
{
return -i;
}
}
return 0;
}
@@ -289,16 +296,23 @@ short test8() // sendPOSI test
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( 49067, "127.0.0.1", 49009 );
sendPort = openUDP( 49063, "127.0.0.1", 49009 );
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status");
for (i=0;i<1;i++) {
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
@@ -311,12 +325,29 @@ short test8() // sendPOSI test
// Execution
sendPOSI( sendPort, 0, 7, POSI );
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 7, recDATA, DREFSizes); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Test
// Tests
if ( result < 0 )// Request 1 value
{
return -7;
}
for (i=0;i<7-1;i++)
{
if (i==2)
{
continue;
}
if (abs(recDATA[i][0]-POSI[i])>1e-4)
{
return -i;
}
}
return 0;
}
@@ -326,20 +357,65 @@ short test9() // pauseSim test
printf("pauseSim - ");
// Initialize
int i; // Iterator
char DREFArray[100][100];
float *recDATA[100];
short DREFSizes[100],RECSizes[100];
struct xpcSocket sendPort, recvPort;
short result;
// Setup
sendPort = openUDP( 49067, "127.0.0.1", 49009 );
for (i = 0; i < 100; i++) {
recDATA[i] = (float *) malloc(40*sizeof(float));
memset(DREFArray[i],0,100);
}
// 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
pauseSim(sendPort, 1);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Test
if (result < 0) {
return -1;
}
if (recDATA[0][0] != 1)
{
return -2;
}
// Reopen
sendPort = openUDP( 49064, "127.0.0.1", 49009 );
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
// Execute 2
pauseSim(sendPort, 0);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test
// Close 2
closeUDP(sendPort);
closeUDP(recvPort);
// Test 2
if (result < 0)
{
return -3;
}
if (recDATA[0][0] != 0)
{
return -4;
}
return 0;
}
@@ -389,7 +465,7 @@ short test10() // setConn test
int main(int argc, const char * argv[])
{
printf("XPC Tests-cpp ");
printf("XPC Tests-c ");
#ifdef _WIN32
printf("(Windows)\n");

View File

@@ -48,6 +48,7 @@ void test2() // closeUDP test
std::cout << "closeUDP - ";
struct xpcSocket sendPort = openUDP( 49063, "127.0.0.1", 49009 );
closeUDP(sendPort);
sendPort = openUDP( 49063, "127.0.0.1", 49009 );
}
void test3() // send/read Test
@@ -239,82 +240,112 @@ void test7() // sendCTRL test
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( 49067, "127.0.0.1", 49009 );
sendPort = openUDP( 49066, "127.0.0.1", 49009 );
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]);
}
CTRL[3] = 0.8; // Throttle
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/flaprqsts");
for (i=0;i<5;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
}
CTRL[3] = 0.8; // Throttle
// Execute
sendCTRL(sendPort, 4, CTRL);
sendCTRL(sendPort, 4, CTRL);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
closeUDP(sendPort);
closeUDP(recvPort);
// Test
// if (requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes) < 0)// Request 1 value
// {
// throw 1;
// }
// if (DREFSizes[0] != 1)
// {
// throw 2;
// }
// if (*recDATA[0] != value)
// {
// throw 3;
// }
// Tests
if ( result < 0 )// Request 1 value
{
throw -6;
}
for (i=0;i<6-1;i++)
{
if (abs(recDATA[i][0]-CTRL[i])>1e-4)
{
throw -i;
}
}
}
void test8() // sendPOSI test
{
std::cout << "sendPOSI - ";
// Initialization
int i; // Iterator
char DREFArray[100][100];
float POSI[8] = {0.0};
float *recDATA[100];
short DREFSizes[100];
struct xpcSocket sendPort, recvPort;
// Initialize
int i; // Iterator
char DREFArray[100][100];
float *recDATA[100];
short DREFSizes[100],RECSizes[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( 49067, "127.0.0.1", 49009 );
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]);
}
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
for (i = 0; i < 100; i++) {
recDATA[i] = (float *) malloc(40*sizeof(float));
memset(DREFArray[i],0,100);
}
// Execution
sendPOSI( sendPort, 0, 7, POSI );
// 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
pauseSim(sendPort, 1);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
closeUDP(sendPort);
closeUDP(recvPort);
// Test
if (result < 0) {
throw -1;
}
if (recDATA[0][0] != 1)
{
throw -2;
}
// Reopen
sendPort = openUDP( 49064, "127.0.0.1", 49009 );
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
// Execute 2
pauseSim(sendPort, 0);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test
// Close 2
closeUDP(sendPort);
closeUDP(recvPort);
// Test 2
if (result < 0)
{
throw -3;
}
if (recDATA[0][0] != 0)
{
throw -4;
}
}
void test9() // pauseSim test