Added C Testing Scripts

This commit is contained in:
Chris Teubert
2014-11-28 10:57:21 -08:00
parent 6e05c4fe32
commit 2cb1d541d5
22 changed files with 913 additions and 16 deletions

View File

@@ -0,0 +1,241 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
BEB0F5071A28F9A3001975A6 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = BEB0F5061A28F9A3001975A6 /* main.c */; };
BEB0F5091A28F9A3001975A6 /* C_Tests.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = BEB0F5081A28F9A3001975A6 /* C_Tests.1 */; };
BEB0F5111A28F9D5001975A6 /* xplaneConnect.c in Sources */ = {isa = PBXBuildFile; fileRef = BEB0F50F1A28F9D5001975A6 /* xplaneConnect.c */; };
BEB0F5121A28F9D5001975A6 /* xplaneConnect.h in Sources */ = {isa = PBXBuildFile; fileRef = BEB0F5101A28F9D5001975A6 /* xplaneConnect.h */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
BEB0F5011A28F9A3001975A6 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
BEB0F5091A28F9A3001975A6 /* C_Tests.1 in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
BEB0F5031A28F9A3001975A6 /* C Tests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "C Tests"; sourceTree = BUILT_PRODUCTS_DIR; };
BEB0F5061A28F9A3001975A6 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
BEB0F5081A28F9A3001975A6 /* C_Tests.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = C_Tests.1; sourceTree = "<group>"; };
BEB0F50F1A28F9D5001975A6 /* xplaneConnect.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = xplaneConnect.c; path = ../C/src/xplaneConnect.c; sourceTree = "<group>"; };
BEB0F5101A28F9D5001975A6 /* xplaneConnect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = xplaneConnect.h; path = ../C/src/xplaneConnect.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
BEB0F5001A28F9A3001975A6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
BEB0F4FA1A28F9A3001975A6 = {
isa = PBXGroup;
children = (
BEB0F50F1A28F9D5001975A6 /* xplaneConnect.c */,
BEB0F5101A28F9D5001975A6 /* xplaneConnect.h */,
BEB0F5051A28F9A3001975A6 /* C Tests */,
BEB0F5041A28F9A3001975A6 /* Products */,
);
sourceTree = "<group>";
};
BEB0F5041A28F9A3001975A6 /* Products */ = {
isa = PBXGroup;
children = (
BEB0F5031A28F9A3001975A6 /* C Tests */,
);
name = Products;
sourceTree = "<group>";
};
BEB0F5051A28F9A3001975A6 /* C Tests */ = {
isa = PBXGroup;
children = (
BEB0F5061A28F9A3001975A6 /* main.c */,
BEB0F5081A28F9A3001975A6 /* C_Tests.1 */,
);
path = "C Tests";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
BEB0F5021A28F9A3001975A6 /* C Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = BEB0F50C1A28F9A3001975A6 /* Build configuration list for PBXNativeTarget "C Tests" */;
buildPhases = (
BEB0F4FF1A28F9A3001975A6 /* Sources */,
BEB0F5001A28F9A3001975A6 /* Frameworks */,
BEB0F5011A28F9A3001975A6 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = "C Tests";
productName = "C Tests";
productReference = BEB0F5031A28F9A3001975A6 /* C Tests */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
BEB0F4FB1A28F9A3001975A6 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
ORGANIZATIONNAME = "Chris Teubert";
};
buildConfigurationList = BEB0F4FE1A28F9A3001975A6 /* Build configuration list for PBXProject "C Tests" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = BEB0F4FA1A28F9A3001975A6;
productRefGroup = BEB0F5041A28F9A3001975A6 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
BEB0F5021A28F9A3001975A6 /* C Tests */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
BEB0F4FF1A28F9A3001975A6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BEB0F5111A28F9D5001975A6 /* xplaneConnect.c in Sources */,
BEB0F5121A28F9D5001975A6 /* xplaneConnect.h in Sources */,
BEB0F5071A28F9A3001975A6 /* main.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
BEB0F50A1A28F9A3001975A6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
BEB0F50B1A28F9A3001975A6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SDKROOT = macosx;
};
name = Release;
};
BEB0F50D1A28F9A3001975A6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
BEB0F50E1A28F9A3001975A6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
BEB0F4FE1A28F9A3001975A6 /* Build configuration list for PBXProject "C Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
BEB0F50A1A28F9A3001975A6 /* Debug */,
BEB0F50B1A28F9A3001975A6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
BEB0F50C1A28F9A3001975A6 /* Build configuration list for PBXNativeTarget "C Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
BEB0F50D1A28F9A3001975A6 /* Debug */,
BEB0F50E1A28F9A3001975A6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = BEB0F4FB1A28F9A3001975A6 /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:C Tests.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>E65C5E87-7590-4DC1-B98C-7F49BB1C166C</string>
<key>IDESourceControlProjectName</key>
<string>C Tests</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>C03F0B00-9A73-4E8C-88E5-1BC53A92AE34</key>
<string>https://github.com/nasa/XPlaneConnect.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>TestScripts/C Tests/C Tests.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>C03F0B00-9A73-4E8C-88E5-1BC53A92AE34</key>
<string>../../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/nasa/XPlaneConnect.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>C03F0B00-9A73-4E8C-88E5-1BC53A92AE34</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>C03F0B00-9A73-4E8C-88E5-1BC53A92AE34</string>
<key>IDESourceControlWCCName</key>
<string>XPlaneConnect</string>
</dict>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEB0F5021A28F9A3001975A6"
BuildableName = "C Tests"
BlueprintName = "C Tests"
ReferencedContainer = "container:C Tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEB0F5021A28F9A3001975A6"
BuildableName = "C Tests"
BlueprintName = "C Tests"
ReferencedContainer = "container:C Tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEB0F5021A28F9A3001975A6"
BuildableName = "C Tests"
BlueprintName = "C Tests"
ReferencedContainer = "container:C Tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEB0F5021A28F9A3001975A6"
BuildableName = "C Tests"
BlueprintName = "C Tests"
ReferencedContainer = "container:C Tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>C Tests.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>BEB0F5021A28F9A3001975A6</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View File

@@ -0,0 +1,79 @@
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
.\"See Also:
.\"man mdoc.samples for a complete listing of options
.\"man mdoc for the short list of editing options
.\"/usr/share/misc/mdoc.template
.Dd 11/28/14 \" DATE
.Dt C Tests 1 \" Program name and manual section number
.Os Darwin
.Sh NAME \" Section Header - required - don't modify
.Nm C Tests,
.\" The following lines are read in generating the apropos(man -k) database. Use only key
.\" words here as the database is built based on the words here and in the .ND line.
.Nm Other_name_for_same_program(),
.Nm Yet another name for the same program.
.\" Use .Nm macro to designate other names for the documented program.
.Nd This line parsed for whatis database.
.Sh SYNOPSIS \" Section Header - required - don't modify
.Nm
.Op Fl abcd \" [-abcd]
.Op Fl a Ar path \" [-a path]
.Op Ar file \" [file]
.Op Ar \" [file ...]
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
arg2 ... \" Arguments
.Sh DESCRIPTION \" Section Header - required - don't modify
Use the .Nm macro to refer to your program throughout the man page like such:
.Nm
Underlining is accomplished with the .Ar macro like this:
.Ar underlined text .
.Pp \" Inserts a space
A list of items with descriptions:
.Bl -tag -width -indent \" Begins a tagged list
.It item a \" Each item preceded by .It macro
Description of item a
.It item b
Description of item b
.El \" Ends the list
.Pp
A list of flags and their descriptions:
.Bl -tag -width -indent \" Differs from above in tag removed
.It Fl a \"-a flag as a list item
Description of -a flag
.It Fl b
Description of -b flag
.El \" Ends the list
.Pp
.\" .Sh ENVIRONMENT \" May not be needed
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
.\" .It Ev ENV_VAR_1
.\" Description of ENV_VAR_1
.\" .It Ev ENV_VAR_2
.\" Description of ENV_VAR_2
.\" .El
.Sh FILES \" File used or created by the topic of the man page
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
.It Pa /usr/share/file_name
FILE_1 description
.It Pa /Users/joeuser/Library/really_long_file_name
FILE_2 description
.El \" Ends the list
.\" .Sh DIAGNOSTICS \" May not be needed
.\" .Bl -diag
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .El
.Sh SEE ALSO
.\" List links in ascending order by section, alphabetically within a section.
.\" Please do not reference files that do not exist without filing a bug report
.Xr a 1 ,
.Xr b 1 ,
.Xr c 1 ,
.Xr a 2 ,
.Xr b 2 ,
.Xr a 3 ,
.Xr b 3
.\" .Sh BUGS \" Document known, unremedied bugs
.\" .Sh HISTORY \" Document history if command behaves in a unique manner

417
TestScripts/C Tests/main.c Normal file
View File

@@ -0,0 +1,417 @@
//
// main.cpp
// XPC Tests
//
// Created by Chris Teubert on 11/25/14.
// Copyright (c) 2014 Chris Teubert. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "xplaneconnect.h"
int testFailed = 0;
int testPassed = 0;
void runTest(short (*f)())
{
short result;
printf("Test %i: ",testPassed+testFailed+1);
result = (*f)(); // Run Test
if (result == 0)
{
printf("PASSED\n");
testPassed++;
}
else
{
printf("FAILED\n\tError: %i\n", result);
testFailed++;
}
}
short test1() // openUDP Test
{
printf("openUDP - ");
struct xpcSocket sendPort = openUDP( 49062, "127.0.0.1", 49009 );
return 0;
}
short test2() // closeUDP test
{
printf("closeUDP - ");
struct xpcSocket sendPort = openUDP( 49063, "127.0.0.1", 49009 );
closeUDP(sendPort);
return 0;
}
short test3() // send/read Test
{
printf("send/readUDP - ");
// Initialization
int i; // Iterator
char test[] = {0, 1, 2, 3};
char buf[5] = {0};
struct xpcSocket sendPort, recvPort;
// Setup
sendPort = openUDP( 49064, "127.0.0.1", 49063 );
recvPort = openUDP( 49063, "127.0.0.1", 49009 );
// Execution
sendUDP( sendPort, test, sizeof(test) );
readUDP( recvPort, buf, NULL ); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Tests
for (i=0; i<4; i++)
{
if (test[i] != buf[i]) // Not received correctly
{
return -1;
}
}
return 0;
}
short test4() // Request DREF Test (Required for next tests)
{
printf("requestDREF - ");
// Initialization
int i; // Iterator
char DREFArray[100][100];
float *recDATA[100];
short DREFSizes[100];
struct xpcSocket sendPort, recvPort;
short result = 0;
// Setup
for (i = 0; i < 100; i++) {
recDATA[i] = (float *) malloc(40*sizeof(float));
memset(DREFArray[i],0,100);
}
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],"cockpit2/switches/panel_brightness_ratio");
for (i=0;i<2;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
}
// Execution
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 2, recDATA, DREFSizes);
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Tests
if ( result < 0)// Request 2 values
{
return -1;
}
if (DREFSizes[0] != 1 || DREFSizes[1] != 4)
{
return -2;
}
return 0;
}
short test5() // sendDREF test
{
printf("sendDREF - ");
// Initialization
int i; // Iterator
char DREFArray[100][100];
float *recDATA[100];
short DREFSizes[100];
float value = 0.0;
struct xpcSocket sendPort, recvPort;
short result = 0;
// 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/cockpit/switches/gear_handle_status");
for (i=0;i<1;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
}
// Execution
sendDREF(sendPort, DREFArray[0], DREFSizes[0], &value, 1);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes);
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Tests
if (result < 0)// Request 1 value
{
return -1;
}
if (DREFSizes[0] != 1)
{
return -2;
}
if (*recDATA[0] != value)
{
return -3;
}
return 0;
}
short test6() // sendDATA test
{
printf("sendData - ");
// Initialize
int i,j; // Iterator
char DREFArray[100][100];
float data[4][9] = {0};
float *recDATA[100];
short DREFSizes[100];
struct xpcSocket sendPort, recvPort;
short result = 0;
// 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/aircraft/parts/acf_gear_deploy");
for (i=0;i<1;i++) {
DREFSizes[i] = (int) strlen(DREFArray[i]);
}
for (i=0;i<4;i++) { // Set array to -999
for (j=0;j<9;j++) data[i][j] = -999;
}
data[0][0] = 14; // Gear
data[0][1] = 1;
data[0][2] = 0;
// Execution
sendDATA(sendPort, data, 1); // Gear
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Tests
if ( result < 0 )// Request 1 value
{
return -1;
}
if (DREFSizes[0] != 10)
{
return -2;
}
if (*recDATA[0] != data[0][1])
{
return -3;
}
return 0;
}
short test7() // sendCTRL test
{
printf("sendCTRL - ");
// Initialize
int i; // Iterator
char DREFArray[100][100];
float CTRL[5] = {0.0};
float *recDATA[100];
short DREFSizes[100];
struct xpcSocket sendPort, recvPort;
// 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]);
}
CTRL[3] = 0.8; // Throttle
// Execute
sendCTRL(sendPort, 4, CTRL);
// 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;
// }
return 0;
}
short test8() // sendPOSI test
{
printf("sendPOSI - ");
// Initialization
int i; // Iterator
char DREFArray[100][100];
float POSI[8] = {0.0};
float *recDATA[100];
short DREFSizes[100];
struct xpcSocket sendPort, recvPort;
// 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
// Execution
sendPOSI( sendPort, 0, 7, POSI );
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Test
return 0;
}
short test9() // pauseSim test
{
printf("pauseSim - ");
// Initialize
struct xpcSocket sendPort, recvPort;
// Setup
sendPort = openUDP( 49067, "127.0.0.1", 49009 );
recvPort = openUDP( 49008, "127.0.0.1", 49009 );
// Execute
pauseSim(sendPort, 1);
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Test
return 0;
}
short test10() // setConn test
{
printf("setConn - ");
// Initialize
int i; // Iterator
char DREFArray[100][100];
float *recDATA[100];
short DREFSizes[100];
struct xpcSocket sendPort, recvPort;
short result = 0;
usleep(0);
// Setup
sendPort = openUDP( 49067, "127.0.0.1", 49009 );
recvPort = openUDP( 49055, "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
setCONN(sendPort, 49055);
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes); // Test
// Close
closeUDP(sendPort);
closeUDP(recvPort);
// Test
if ( result < 0 )// No data received
{
return -1;
}
// Set up for next test
sendPort = openUDP( 49067, "127.0.0.1", 49009 );
setCONN(sendPort, 49009);
closeUDP(sendPort);
return 0;
}
int main(int argc, const char * argv[])
{
printf("XPC Tests-cpp ");
#ifdef _WIN32
printf("(Windows)\n");
#elif (__APPLE__)
printf("(Mac) \n");
#elif (__linux)
printf("(Linux) \n");
#endif
runTest(test1);
runTest(test2);
runTest(test3);
runTest(test4);
runTest(test5);
runTest(test6);
runTest(test7);
runTest(test8);
runTest(test9);
runTest(test10);
printf( "----------------\nTest Summary\n\tFailed: %i\n\tPassed: %i\n", testFailed, testPassed );
return 0;
}

View File

@@ -7,10 +7,9 @@
objects = {
/* Begin PBXBuildFile section */
BE9C6BAF1A253FA100EBE08A /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE9C6BAE1A253FA100EBE08A /* main.cpp */; };
BE9C6BB11A253FA100EBE08A /* XPC_Tests.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = BE9C6BB01A253FA100EBE08A /* XPC_Tests.1 */; };
BE9C6BB91A25402300EBE08A /* xplaneConnect.c in Sources */ = {isa = PBXBuildFile; fileRef = BE9C6BB71A25402300EBE08A /* xplaneConnect.c */; };
BE9C6BBA1A25402300EBE08A /* xplaneConnect.h in Sources */ = {isa = PBXBuildFile; fileRef = BE9C6BB81A25402300EBE08A /* xplaneConnect.h */; };
BE7C5C021A28F72F00F246B9 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE7C5C001A28F72F00F246B9 /* main.cpp */; };
BEB0F4F81A28F7B0001975A6 /* xplaneConnect.c in Sources */ = {isa = PBXBuildFile; fileRef = BEB0F4F61A28F7B0001975A6 /* xplaneConnect.c */; };
BEB0F4F91A28F7B0001975A6 /* xplaneConnect.h in Sources */ = {isa = PBXBuildFile; fileRef = BEB0F4F71A28F7B0001975A6 /* xplaneConnect.h */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -20,18 +19,17 @@
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
BE9C6BB11A253FA100EBE08A /* XPC_Tests.1 in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
BE7C5C001A28F72F00F246B9 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = "CPP Tests/main.cpp"; sourceTree = SOURCE_ROOT; };
BE7C5C011A28F72F00F246B9 /* XPC_Tests.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; name = XPC_Tests.1; path = "CPP Tests/XPC_Tests.1"; sourceTree = SOURCE_ROOT; };
BE9C6BAB1A253FA100EBE08A /* Cpp Tests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Cpp Tests"; sourceTree = BUILT_PRODUCTS_DIR; };
BE9C6BAE1A253FA100EBE08A /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
BE9C6BB01A253FA100EBE08A /* XPC_Tests.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = XPC_Tests.1; sourceTree = "<group>"; };
BE9C6BB71A25402300EBE08A /* xplaneConnect.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = xplaneConnect.c; path = ../../C/src/xplaneConnect.c; sourceTree = "<group>"; };
BE9C6BB81A25402300EBE08A /* xplaneConnect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = xplaneConnect.h; path = ../../C/src/xplaneConnect.h; sourceTree = "<group>"; };
BEB0F4F61A28F7B0001975A6 /* xplaneConnect.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = xplaneConnect.c; path = ../C/src/xplaneConnect.c; sourceTree = "<group>"; };
BEB0F4F71A28F7B0001975A6 /* xplaneConnect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = xplaneConnect.h; path = ../C/src/xplaneConnect.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -48,8 +46,8 @@
BE9C6BA21A253FA100EBE08A = {
isa = PBXGroup;
children = (
BE9C6BB71A25402300EBE08A /* xplaneConnect.c */,
BE9C6BB81A25402300EBE08A /* xplaneConnect.h */,
BEB0F4F61A28F7B0001975A6 /* xplaneConnect.c */,
BEB0F4F71A28F7B0001975A6 /* xplaneConnect.h */,
BE9C6BAD1A253FA100EBE08A /* Cpp Tests */,
BE9C6BAC1A253FA100EBE08A /* Products */,
);
@@ -66,8 +64,8 @@
BE9C6BAD1A253FA100EBE08A /* Cpp Tests */ = {
isa = PBXGroup;
children = (
BE9C6BAE1A253FA100EBE08A /* main.cpp */,
BE9C6BB01A253FA100EBE08A /* XPC_Tests.1 */,
BE7C5C001A28F72F00F246B9 /* main.cpp */,
BE7C5C011A28F72F00F246B9 /* XPC_Tests.1 */,
);
name = "Cpp Tests";
path = "XPC Tests";
@@ -124,9 +122,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BE9C6BB91A25402300EBE08A /* xplaneConnect.c in Sources */,
BE9C6BBA1A25402300EBE08A /* xplaneConnect.h in Sources */,
BE9C6BAF1A253FA100EBE08A /* main.cpp in Sources */,
BEB0F4F81A28F7B0001975A6 /* xplaneConnect.c in Sources */,
BEB0F4F91A28F7B0001975A6 /* xplaneConnect.h in Sources */,
BE7C5C021A28F72F00F246B9 /* main.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -234,6 +232,7 @@
BE9C6BB61A253FA100EBE08A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>