public void TestHALRoboRioMapsToNativeAssemblySymbols() { var halRoboRioSymbols = NetProjects.GetHALRoboRioNativeSymbols(); var assembly = Assembly.GetExecutingAssembly(); var ps = Path.DirectorySeparatorChar; var path = assembly.CodeBase.Replace("file:///", "").Replace("/", ps.ToString()); path = Path.GetDirectoryName(path); // Start the child process. Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = path + "\\..\\..\\HAL\\AthenaHAL\\Native\\frcnm.exe"; p.StartInfo.Arguments = path + "\\..\\..\\HAL\\AthenaHAL\\Native\\libHALAthena.so"; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); bool found = true; string[] nativeSymbols = output.Split('\r'); foreach (var halSymbol in halRoboRioSymbols) { bool foundSymbol = nativeSymbols.Any(nativeSymbol => nativeSymbol.EndsWith(halSymbol)); if (!foundSymbol) { found = false; Console.WriteLine(halSymbol); } } Assert.That(found); }
public void TestHALBlittable() { List <string> allowedTypes = new List <string>() { // Allowed types with arrays are also allowed "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "IntPtr", "UIntPtr", "float", "void", "double", // For now force our enum types to be OK "CTR_Code", "HALAccelerometerRange", "HALAllianceStationID", "HALAnalogTriggerType", "HALEncoderEncodingType", "HALEncoderIndexingType", "HALRuntimeType", "Mode", //Also allow any structs known to be blittable "CANStreamMessage", "HALJoystickButtons", "HALJoystickPOVs", "HALJoystickAxes", "HALControlWord", "HALJoystickDescriptor", // Make our structs blittable "HAL_NotifierProcess", "HAL_InterruptHandlerFunction", //For now allow bool, since it marshalls easily //This will change if the native windows HAL is not 1 byte bools "bool", }; List <string> notBlittableMethods = new List <string>(); var halBaseDelegates = NetProjects.GetHalBaseDelegates(); foreach (var halDelegate in halBaseDelegates) { foreach (var methodSyntax in halDelegate.Methods) { List <TypeSyntax> types = new List <TypeSyntax>(); if (methodSyntax.AttributeLists.Count != 0) { if (methodSyntax.AttributeLists[0].Attributes[0].Name.ToString() == nameof(HALAllowNonBlittable)) { //We can ignore it. } else { types.Add(methodSyntax.ReturnType); } } else { types.Add(methodSyntax.ReturnType); } List <string> param = new List <string>(); StringBuilder builder = new StringBuilder(); builder.Append($"\t {methodSyntax.ReturnType} {methodSyntax.Identifier} ("); bool first = true; foreach (var parameter in methodSyntax.ParameterList.Parameters) { if (parameter.AttributeLists.Count != 0) { if (parameter.AttributeLists[0].Attributes[0].Name.ToString() == nameof(HALAllowNonBlittable)) { //We can ignore it. } else { types.Add(parameter.Type); } } else { types.Add(parameter.Type); } param.Add(parameter.Type.ToString()); if (first) { first = false; builder.Append($"{parameter.Type} {parameter.Identifier}"); } else { builder.Append($", {parameter.Type} {parameter.Identifier}"); } } builder.Append(")"); CheckForBlittable(types, allowedTypes, notBlittableMethods, builder.ToString()); } } foreach (string s in notBlittableMethods) { Console.WriteLine(s); } if (notBlittableMethods.Count != 0) { Assert.Fail(); } else { Assert.Pass(); } }