Xxx (#5567)
* testability: bench test commands should have automated coverage using simulator #5562 * testability: bench test commands should have automated coverage using simulator #5562
This commit is contained in:
parent
0650898798
commit
d558a46a11
|
@ -361,6 +361,9 @@ static bool isKnownCommand(char command) {
|
||||||
|| command == TS_PAGE_COMMAND || command == TS_BURN_COMMAND || command == TS_SINGLE_WRITE_COMMAND
|
|| command == TS_PAGE_COMMAND || command == TS_BURN_COMMAND || command == TS_SINGLE_WRITE_COMMAND
|
||||||
|| command == TS_CHUNK_WRITE_COMMAND || command == TS_EXECUTE
|
|| command == TS_CHUNK_WRITE_COMMAND || command == TS_EXECUTE
|
||||||
|| command == TS_IO_TEST_COMMAND
|
|| command == TS_IO_TEST_COMMAND
|
||||||
|
#if EFI_SIMULATOR
|
||||||
|
|| command == TS_SIMULATE_CAN
|
||||||
|
#endif // EFI_SIMULATOR
|
||||||
|| command == TS_GET_SCATTERED_GET_COMMAND
|
|| command == TS_GET_SCATTERED_GET_COMMAND
|
||||||
|| command == TS_SET_LOGGER_SWITCH
|
|| command == TS_SET_LOGGER_SWITCH
|
||||||
|| command == TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY
|
|| command == TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY
|
||||||
|
@ -717,6 +720,12 @@ int TunerStudio::handleCrcCommand(TsChannelBase* tsChannel, char *data, int inco
|
||||||
case 'T':
|
case 'T':
|
||||||
handleTestCommand(tsChannel);
|
handleTestCommand(tsChannel);
|
||||||
break;
|
break;
|
||||||
|
#if EFI_SIMULATOR
|
||||||
|
case TS_SIMULATE_CAN:
|
||||||
|
void handleWrapCan(TsChannelBase* tsChannel);
|
||||||
|
handleWrapCan(tsChannel);
|
||||||
|
break;
|
||||||
|
#endif // EFI_SIMULATOR
|
||||||
case TS_IO_TEST_COMMAND:
|
case TS_IO_TEST_COMMAND:
|
||||||
{
|
{
|
||||||
uint16_t subsystem = SWAP_UINT16(data16[0]);
|
uint16_t subsystem = SWAP_UINT16(data16[0]);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
|
import com.rusefi.simulator.SimulatorFunctionalTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this class runs rusEFI functional tests against rusEFI simulator
|
* this class runs rusEFI functional tests against rusEFI simulator
|
||||||
|
@ -23,8 +24,7 @@ public class SimulatorFunctionalTestLauncher {
|
||||||
try {
|
try {
|
||||||
LinkManager linkManager = new LinkManager();
|
LinkManager linkManager = new LinkManager();
|
||||||
IoUtil.connectToSimulator(linkManager, startSimulator);
|
IoUtil.connectToSimulator(linkManager, startSimulator);
|
||||||
// todo: new implementation for unit tests?
|
new SimulatorFunctionalTest(linkManager).mainTestBody();
|
||||||
// new FunctionalTest(linkManager, linkManager.getCommandQueue()).mainTestBody();
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
failed = true;
|
failed = true;
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.rusefi.simulator;
|
||||||
|
|
||||||
|
import com.rusefi.io.LinkManager;
|
||||||
|
import etch.util.CircularByteBuffer;
|
||||||
|
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static com.rusefi.binaryprotocol.IoHelper.swap16;
|
||||||
|
import static com.rusefi.config.generated.Fields.TS_SIMULATE_CAN;
|
||||||
|
|
||||||
|
public class SimulatorFunctionalTest {
|
||||||
|
private final LinkManager linkManager;
|
||||||
|
|
||||||
|
public SimulatorFunctionalTest(LinkManager linkManager) {
|
||||||
|
this.linkManager = linkManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mainTestBody() throws InterruptedException {
|
||||||
|
CountDownLatch gotCan = new CountDownLatch(1);
|
||||||
|
linkManager.submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
byte[] response = linkManager.getBinaryProtocol().executeCommand(TS_SIMULATE_CAN, "TS_SIMULATE_CAN");
|
||||||
|
|
||||||
|
if (response == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CircularByteBuffer c = new CircularByteBuffer(response);
|
||||||
|
try {
|
||||||
|
int count = swap16(c.getShort());
|
||||||
|
|
||||||
|
c.get();
|
||||||
|
int dataLength = c.get();
|
||||||
|
c.get();
|
||||||
|
int ide = c.get();
|
||||||
|
int eid = c.getInt();
|
||||||
|
|
||||||
|
System.out.println("Got " + count + " packets");
|
||||||
|
System.out.println(response);
|
||||||
|
gotCan.countDown();
|
||||||
|
|
||||||
|
} catch (EOFException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gotCan.await(1, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,6 +47,14 @@ public class CircularByteBuffer extends ByteBuffer {
|
||||||
buf = new byte[size];
|
buf = new byte[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates buffer FILLED with specified content
|
||||||
|
*/
|
||||||
|
public CircularByteBuffer(byte[] buf) {
|
||||||
|
length = size = buf.length;
|
||||||
|
this.buf = buf;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
length = 0;
|
length = 0;
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#include "rusefi_lua.h"
|
#include "rusefi_lua.h"
|
||||||
#include "can_hw.h"
|
#include "can_hw.h"
|
||||||
#include "flash_main.h"
|
#include "flash_main.h"
|
||||||
|
#include "can_msg_tx.h"
|
||||||
|
#include "fifo_buffer.h"
|
||||||
|
extern fifo_buffer<CANTxFrame, 1024> txCanBuffer;
|
||||||
|
|
||||||
#define DEFAULT_SIM_RPM 1200
|
#define DEFAULT_SIM_RPM 1200
|
||||||
#define DEFAULT_SNIFFER_THR 2500
|
#define DEFAULT_SNIFFER_THR 2500
|
||||||
|
@ -224,3 +227,21 @@ CANDriver* detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx) {
|
||||||
|
|
||||||
void setBoardConfigOverrides() {
|
void setBoardConfigOverrides() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t wrapOutBuffer[BLOCKING_FACTOR + 100];
|
||||||
|
|
||||||
|
void handleWrapCan(TsChannelBase* tsChannel) {
|
||||||
|
int size = minI(txCanBuffer.getSize(), BLOCKING_FACTOR / sizeof(CANTxFrame));
|
||||||
|
|
||||||
|
memcpy(wrapOutBuffer, &size, 2);
|
||||||
|
int outputSize = 2;
|
||||||
|
|
||||||
|
for (int i = 0;i < size;i++) {
|
||||||
|
CANTxFrame f = txCanBuffer.get();
|
||||||
|
void *frame = (void *)&f;
|
||||||
|
memcpy(((void*)wrapOutBuffer) + outputSize, frame, sizeof(CANTxFrame));
|
||||||
|
outputSize += sizeof(CANTxFrame);
|
||||||
|
}
|
||||||
|
tsChannel->sendResponse(TS_CRC, wrapOutBuffer, outputSize, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue