1 byte issue in TuneReadWriteTest fix #1512
This commit is contained in:
parent
6618f031ee
commit
7d8384d7fa
|
@ -1416,6 +1416,15 @@ void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->adcVcc = 3.0f;
|
||||
}
|
||||
engine->preCalculate(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
/**
|
||||
* TunerStudio text tune files convert negative zero into positive zero so to keep things consistent we should avoid
|
||||
* negative zeros altogether. Unfortunately default configuration had one and here we are mitigating that.
|
||||
*/
|
||||
for (int i = 0;i < CLT_CURVE_SIZE;i++) {
|
||||
engineConfiguration->cltIdleRpmBins[i] = fixNegativeZero(engineConfiguration->cltIdleRpmBins[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
|
|
|
@ -36,7 +36,7 @@ float efiFloor(float value, float precision) {
|
|||
float efiRound(float value, float precision) {
|
||||
efiAssert(CUSTOM_ERR_ASSERT, precision != 0, "zero precision", NAN);
|
||||
float a = rintf (value / precision);
|
||||
return a * precision;
|
||||
return fixNegativeZero(a * precision);
|
||||
}
|
||||
|
||||
float absF(float value) {
|
||||
|
|
|
@ -87,6 +87,7 @@ float expf_taylor(float x);
|
|||
#include <cstddef>
|
||||
|
||||
#define IS_NEGATIVE_ZERO(value) (std::signbit(value) && value==0)
|
||||
#define fixNegativeZero(value) (IS_NEGATIVE_ZERO(value) ? 0 : value)
|
||||
|
||||
// C++ helpers go here
|
||||
namespace efi
|
||||
|
|
|
@ -38,18 +38,18 @@ public class TuneReadWriteTest {
|
|||
|
||||
int mismatchCounter = compareImages(tsBinaryData, fileBinaryData);
|
||||
// todo: why one byte mismatch? since it's in floats I kind of do not care, floats are weird
|
||||
assertEquals(1, mismatchCounter);
|
||||
assertEquals(0, mismatchCounter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteAndReadTSTune() throws Exception {
|
||||
ConfigurationImage originalBinaryData = ConfigurationImageFile.readFromFile(TEST_BINARY_FILE);
|
||||
ConfigurationImage fileBinaryData = ConfigurationImageFile.readFromFile(TEST_BINARY_FILE);
|
||||
|
||||
Path path = Files.createTempFile("unit_test_", ".xml");
|
||||
String fileName = path.getFileName().toString();
|
||||
|
||||
// writing TS XML tune file with rusEFI code
|
||||
Msq tuneFromBinary = Msq.valueOf(originalBinaryData);
|
||||
Msq tuneFromBinary = Msq.valueOf(fileBinaryData);
|
||||
tuneFromBinary.writeXmlFile(fileName);
|
||||
|
||||
// and now reading that XML back
|
||||
|
@ -57,13 +57,14 @@ public class TuneReadWriteTest {
|
|||
|
||||
ConfigurationImage binaryDataFromXml = tuneFromFile.asImage(IniFileModel.getInstance());
|
||||
|
||||
assertEquals(0, compareImages(originalBinaryData, binaryDataFromXml));
|
||||
assertEquals(0, compareImages(binaryDataFromXml, fileBinaryData));
|
||||
// todo: looks like this is not removing the temporary file?
|
||||
Files.delete(path);
|
||||
}
|
||||
|
||||
private static int compareImages(ConfigurationImage image1, ConfigurationImage image2) {
|
||||
private static int compareImages(ConfigurationImage image1, ConfigurationImage fileData) {
|
||||
byte[] tsBinaryDataContent = image1.getContent();
|
||||
byte[] fileBinaryDataContent = image2.getContent();
|
||||
byte[] fileBinaryDataContent = fileData.getContent();
|
||||
|
||||
int mismatchCounter = 0;
|
||||
|
||||
|
@ -72,7 +73,7 @@ public class TuneReadWriteTest {
|
|||
byte fileByte = fileBinaryDataContent[i];
|
||||
if (tsByte != fileByte) {
|
||||
IniField field = IniFileModel.getInstance().findByOffset(i);
|
||||
System.out.println("Mismatch at " + (field == null ? "offset " + i : field) + " " + tsByte + "/" + fileByte);
|
||||
System.out.println("Mismatch at offset=" + i + ", " + (field == null ? "(no field)" : field) + " runtime=" + tsByte + "/file=" + fileByte);
|
||||
mismatchCounter++;
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue