ipa-kernel-tests: ULSO tests, HPC based header insertion tests

Unit tests for the IPv5 ULSO feature and for HPC based
header insertion feature.

Change-Id: I312b135f33486c1171a355a69e6631764d021947
Acked-by: Eliad Ben Yishay <ebenyish@qti.qualcomm.com>
Signed-off-by: Ilia Lin <ilialin@codeaurora.org>
This commit is contained in:
Ilia Lin
2021-08-11 14:51:51 +03:00
parent bedfbae7e6
commit 15ae40cd76
13 changed files with 920 additions and 60 deletions

View File

@@ -30,10 +30,14 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <iostream>
#include "InterfaceAbstraction.h"
#define MAX_OPEN_RETRY 10000
using std::cout;
using std::endl;
bool InterfaceAbstraction::Open(const char * toIPAPath, const char * fromIPAPath)
{
int tries_cnt = MAX_OPEN_RETRY;
@@ -95,9 +99,9 @@ void InterfaceAbstraction::Close()
close(m_fromIPADescriptor);
}
bool InterfaceAbstraction::SendData(unsigned char *buf, size_t size)
long InterfaceAbstraction::SendData(unsigned char *buf, size_t size)
{
int bytesWritten = 0;
long bytesWritten = 0;
printf("Trying to write %zu bytes to %d.\n", size, m_toIPADescriptor);
@@ -118,7 +122,7 @@ bool InterfaceAbstraction::SendData(unsigned char *buf, size_t size)
exit(-1);
}
printf("bytesWritten = %d.\n", bytesWritten);
cout << "bytesWritten = " << bytesWritten << endl;
return bytesWritten;
}
@@ -145,6 +149,30 @@ int InterfaceAbstraction::ReceiveData(unsigned char *buf, size_t size)
return totalBytesRead;
}
int InterfaceAbstraction::ReceiveSingleDataChunk(unsigned char *buf, size_t size){
size_t bytesRead = 0;
printf("Trying to read %zu bytes from %d.\n", size, m_fromIPADescriptor);
bytesRead = read(m_fromIPADescriptor, (void*)buf, size);
printf("Read %zu bytes.\n", bytesRead);
return bytesRead;
}
int InterfaceAbstraction::setReadNoBlock(){
int flags = fcntl(m_fromIPADescriptor, F_GETFL, 0);
if(flags == -1){
return -1;
}
return fcntl(m_fromIPADescriptor, F_SETFL, flags | O_NONBLOCK);
}
int InterfaceAbstraction::clearReadNoBlock(){
int flags = fcntl(m_fromIPADescriptor, F_GETFL, 0);
if(flags == -1){
return -1;
}
return fcntl(m_fromIPADescriptor, F_SETFL, flags & ~O_NONBLOCK);
}
InterfaceAbstraction::~InterfaceAbstraction()
{
close(m_fromIPADescriptor);