JNI for test coverage #3965

This commit is contained in:
rusefillc 2022-03-15 13:57:40 -04:00
parent 72b85e3a32
commit e9625b3cd8
3 changed files with 8 additions and 3 deletions

View File

@ -5,6 +5,9 @@ import org.junit.Test;
import java.nio.ByteBuffer;
import static com.rusefi.config.generated.Fields.TS_FILE_VERSION;
import static com.rusefi.shared.FileUtil.littleEndianWrap;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
public class JniUnitTest {
@ -21,8 +24,8 @@ public class JniUnitTest {
byte[] outputs = engineLogic.getOutputs();
Sensor sensor = Sensor.FIRMWARE_VERSION;
ByteBuffer bb = ByteBuffer.wrap(outputs, sensor.getOffset(), 4);
ByteBuffer bb = littleEndianWrap(outputs, sensor.getOffset(), 4);
double value = sensor.getValueForChannel(bb);
System.out.println(value);
assertEquals(TS_FILE_VERSION, (int)value);
}
}

View File

@ -8,6 +8,7 @@
#include "pch.h"
#include "com_rusefi_native__EngineLogic.h"
#include "auto_generated_sensor.h"
#include "tunerstudio.h"
#include <memory>
@ -64,6 +65,7 @@ JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getOutputs(JNI
jbyteArray retVal = env->NewByteArray(sizeof(TunerStudioOutputChannels));
jbyte *buf = env->GetByteArrayElements(retVal, NULL);
EngineTestHelper* eth = getEth();
updateTunerStudioState();
memcpy(buf, (const void*)&eth->engine.outputChannels, sizeof(TunerStudioOutputChannels));
env->ReleaseByteArrayElements(retVal, buf, 0);

View File

@ -497,7 +497,7 @@ TEST(misc, testMenuTree) {
}
int getRusEfiVersion(void) {
return 776655;
return TS_FILE_VERSION;
}
TEST(util, PeakDetect) {