#include "interfaces.h"
#include <semaphore.h>
static bool CdmaTest = true;
static bool GsmTest = true;
static le_log_TraceRef_t TraceRefPdu;
static le_log_TraceRef_t TraceRefSms;
static void Dump
(
const char *label,
const uint8_t *buffer,
size_t bufferSize
)
{
uint32_t index = 0, i = 0;
char output[65] = {0};
for (i=0;i<bufferSize;i++)
{
index += sprintf(&output[index],"%02X",buffer[i]);
if ( !((i+1)%32) )
{
index = 0;
}
}
}
static void TestRxHandler
(
void* contextPtr
)
{
uint16_t myMessageId = 0;
uint16_t myMessageSerialNumber = 0;
size_t pduLen;
uint8_t bin[50] = {0};
LE_INFO(
"-TEST- New SMS message received ! msg.%p", msg);
LE_INFO(
"-TEST- New SMS message format %d, Type %d", myformat, myType);
{
LE_ERROR(
"-TEST 1- Check le_sms_GetType failure! %d", myType);
return;
}
else
{
LE_INFO(
"-TEST 1- Check le_sms_GetType LE_SMS_TYPE_CB");
}
if (res != LE_OK)
{
LE_ERROR(
"-TEST 2- Check le_sms_GetMessageIdCellBroadcast failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 2- Check le_sms_GetMessageIdCellBroadcast OK Message Id 0x%04X (%d)",
myMessageId, myMessageId);
}
if (res != LE_OK)
{
LE_ERROR(
"-TEST 3- Check le_sms_GetCellBroadcastSerialNumber failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 3- Check le_sms_GetCellBroadcastSerialNumber OK Message Id 0x%04X (%d)",
myMessageSerialNumber, myMessageSerialNumber);
}
{
LE_INFO(
"SMS Cell Broadcast in text format");
{
LE_ERROR(
"-TEST 4- Check le_sms_GetTimeStamp failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 4- Check le_sms_GetTimeStamp LE_NOT_PERMITTED");
}
if(res != LE_OK)
{
LE_ERROR(
"-TEST 5- Check le_sms_GetText failure! %d", res);
return;
}
else
{
LE_INFO(
"SMS CB text=> '%s'",text);
LE_INFO(
"-TEST 5- Check le_sms_GetText OK.");
}
{
LE_ERROR(
"-TEST 6 Check le_sms_GetPDULen failure!");
return;
}
else
{
LE_INFO(
"SMS CB Pdu len %d", (
int) pduLen);
LE_INFO(
"-TEST 6- Check le_sms_GetPDULen OK.");
}
if(res != LE_OK)
{
LE_ERROR(
"-TEST 7 Check le_sms_GetPDU failure! %d", res);
return;
}
else
{
Dump("SMS CB PDU", pdu, pduLen);
LE_INFO(
"-TEST 7 Check le_sms_GetPDU OK.");
}
{
LE_ERROR(
"-TEST 8 Check le_sms_DeleteFromStorage failure! %d", res);
return;
}
else
{
Dump("SMS CB PDU", pdu, pduLen);
LE_INFO(
"-TEST 8 Check le_sms_DeleteFromStorage LE_NO_MEMORY.");
}
{
LE_ERROR(
"-TEST 9 Check le_sms_SetText failure !%d", res);
return;
}
else
{
LE_INFO(
"-TEST 9 Check le_sms_SetText OK.");
}
{
LE_ERROR(
"-TEST 10 Check le_sms_SetDestination failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 10 Check le_sms_SetDestination LE_NOT_PERMITTED.");
}
{
LE_ERROR(
"-TEST 11 Check le_sms_SetBinary failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 11 Check le_sms_SetBinary LE_NOT_PERMITTED.");
}
size_t binLen = sizeof(bin);
{
LE_ERROR(
"-TEST 12 Check le_sms_GetBinary failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 12 Check le_sms_GetBinary LE_FORMAT_ERROR.");
}
}
{
LE_INFO(
"SMS Cell Broadcast in binary format");
{
LE_ERROR(
"-TEST 4- Check le_sms_GetTimeStamp failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 4- Check le_sms_GetTimeStamp LE_NOT_PERMITTED");
}
{
LE_ERROR(
"-TEST 5- Check le_sms_GetText failure! %d", res);
return;
}
else
{
LE_INFO(
"SMS CB text=> '%s'",text);
LE_INFO(
"-TEST 5- Check le_sms_GetText LE_FORMAT_ERROR.");
}
{
LE_ERROR(
"-TEST 6 Check le_sms_GetPDULen failure!");
return;
}
else
{
LE_INFO(
"SMS CB Pdu len %d", (
int) pduLen);
LE_INFO(
"-TEST 6- Check le_sms_GetPDULen OK.");
}
if(res != LE_OK)
{
LE_ERROR(
"-TEST 7 Check le_sms_GetPDU failure! %d", res);
return;
}
else
{
Dump("SMS CB PDU", pdu, pduLen);
LE_INFO(
"-TEST 7 Check le_sms_GetPDU OK.");
}
{
LE_ERROR(
"-TEST 8 Check le_sms_DeleteFromStorage failure! %d", res);
return;
}
else
{
Dump("SMS CB PDU", pdu, pduLen);
LE_INFO(
"-TEST 8 Check le_sms_DeleteFromStorage LE_NO_MEMORY.");
}
{
LE_ERROR(
"-TEST 9 Check le_sms_SetText failure !%d", res);
return;
}
else
{
LE_INFO(
"-TEST 9 Check le_sms_SetText LE_NOT_PERMITTED.");
}
{
LE_ERROR(
"-TEST 10 Check le_sms_SetDestination failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 10 Check le_sms_SetDestination LE_NOT_PERMITTED.");
}
{
LE_ERROR(
"-TEST 11 Check le_sms_SetBinary failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 11 Check le_sms_SetBinary LE_NOT_PERMITTED.");
}
size_t binLen = sizeof(bin);
if(res != LE_OK)
{
LE_ERROR(
"-TEST 12 Check le_sms_GetBinary failure! %d", res);
return;
}
else
{
bin[binLen] = 0;
LE_INFO(
"SMS CB binary (%d)=> '%s'",(
int) binLen, bin);
LE_INFO(
"-TEST 12 Check le_sms_GetBinary OK.");
}
}
{
const uint16_t ucs2Pattern[]= { 0x3100, 0x3200, 0x3300 };
LE_INFO(
"SMS Cell Broadcast in UCS2 format");
{
LE_ERROR(
"-TEST 4- Check le_sms_GetTimeStamp failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 4- Check le_sms_GetTimeStamp LE_NOT_PERMITTED");
}
{
LE_ERROR(
"-TEST 5- Check le_sms_GetUCS2 failure! %d", res);
return;
}
else
{
LE_INFO(
"SMS CB text=> '%s'",text);
LE_INFO(
"-TEST 5- Check le_sms_GetUCS2 LE_FORMAT_ERROR.");
}
{
LE_ERROR(
"-TEST 6 Check le_sms_GetPDULen failure!");
return;
}
else
{
LE_INFO(
"SMS CB Pdu len %d", (
int) pduLen);
LE_INFO(
"-TEST 6- Check le_sms_GetPDULen OK.");
}
if(res != LE_OK)
{
LE_ERROR(
"-TEST 7 Check le_sms_GetPDU failure! %d", res);
return;
}
else
{
Dump("SMS CB PDU", pdu, pduLen);
LE_INFO(
"-TEST 7 Check le_sms_GetPDU OK.");
}
{
LE_ERROR(
"-TEST 8 Check le_sms_DeleteFromStorage failure! %d", res);
return;
}
else
{
Dump("SMS CB PDU", pdu, pduLen);
LE_INFO(
"-TEST 8 Check le_sms_DeleteFromStorage LE_NO_MEMORY.");
}
{
LE_ERROR(
"-TEST 9 Check le_sms_SetUCS2 failure !%d", res);
return;
}
else
{
LE_INFO(
"-TEST 9 Check le_sms_SetUCS2 LE_NOT_PERMITTED.");
}
{
LE_ERROR(
"-TEST 10 Check le_sms_SetDestination failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 10 Check le_sms_SetDestination LE_NOT_PERMITTED.");
}
{
LE_ERROR(
"-TEST 11 Check le_sms_SetBinary failure! %d", res);
return;
}
else
{
LE_INFO(
"-TEST 11 Check le_sms_SetBinary LE_NOT_PERMITTED.");
}
if(res != LE_OK)
{
LE_ERROR(
"-TEST 12 Check le_sms_GetUCS2 failure !%d", res);
return;
}
else
{
Dump("UCS2 Dump: ", (uint8_t *) ucs2, binLen * 2);
LE_INFO(
"-TEST 12 Check le_sms_GetUCS2 LE_OK");
}
}
else
{
LE_INFO(
"SMS Cell Broadcast not in test format");
}
LE_INFO(
"smsCBTest sequence PASSED");
}
(
void
)
{
if (res != LE_OK)
{
LE_ERROR(
"le_sms_AddCellBroadcastIds FAILED");
}
{
LE_ERROR(
"le_sms_AddCellBroadcastIds FAILED");
}
{
LE_ERROR(
"TestAddRemoveCellBroadcastIds FAILED");
}
if (res != LE_OK)
{
LE_ERROR(
"TestAddRemoveCellBroadcastIds FAILED");
}
{
LE_ERROR(
"TestAddRemoveCellBroadcastIds FAILED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_AddCellBroadcastIds FAILED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ClearCellBroadcastIds FAILED");
}
}
(
void
)
{
{
LE_ERROR(
"le_sms_AddCdmaCellBroadcastServices FAILED");
}
{
LE_ERROR(
"le_sms_AddCdmaCellBroadcastServices FAILED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_AddCdmaCellBroadcastServices FAILED");
}
{
LE_ERROR(
"le_sms_AddCdmaCellBroadcastServices FAILED");
}
{
LE_ERROR(
"le_sms_RemoveCdmaCellBroadcastServices FAILED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_RemoveCdmaCellBroadcastServices FAILED");
}
{
LE_ERROR(
"le_sms_RemoveCdmaCellBroadcastServices FAILED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ClearCdmaCellBroadcastServices FAILED");
}
}
static void SigHandler
(
int sigNum
)
{
bool statusPassed = true;
if (GsmTest)
{
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ClearCellBroadcastIds FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ClearCellBroadcastIds PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_DeactivateCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_DeactivateCellBroadcast PASSED");
}
}
if (CdmaTest)
{
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ClearCdmaCellBroadcastServices FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ClearCdmaCellBroadcastServices PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_DeactivateCdmaCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_DeactivateCdmaCellBroadcast PASSED");
}
}
if (statusPassed)
{
LE_INFO(
"smsCBTest sequence PASSED");
exit(EXIT_SUCCESS);
}
else
{
exit(EXIT_FAILURE);
}
}
{
bool statusPassed = true;
LE_INFO(
"PRINT USAGE => app runProc smsCBTest --exe=smsCBTest -- < cdma | gsm | >");
{
if (testmode != NULL )
{
LE_INFO(
"smsCBTest argument %s", testmode);
if ( strcmp(testmode, "cdma") == 0)
{
GsmTest = false;
}
else if ( strcmp(testmode, "gsm") == 0)
{
CdmaTest = false;
}
}
}
LE_INFO(
"smsCBTest started in CDMA %c GSM %c",
(CdmaTest ? 'Y' : 'N'),
(GsmTest ? 'Y' : 'N') );
signal(SIGINT, SigHandler);
LE_ERROR_IF((HandlerRef == NULL),
"le_sms_AddRxMessageHandler() Failed!!");
if (GsmTest)
{
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ClearCellBroadcastIds FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ClearCellBroadcastIds PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ActivateCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ActivateCellBroadcast PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_DeactivateCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_DeactivateCellBroadcast PASSED");
}
res = TestAddRemoveCellBroadcastIds();
if (res != LE_OK)
{
LE_ERROR(
"TestAddRemoveCellBroadcastIds FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"TestAddRemoveCellBroadcastIds PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ActivateCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ActivateCellBroadcast PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_AddCellBroadcastIds FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_AddCellBroadcastIds PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_DeactivateCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_DeactivateCellBroadcast PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ActivateCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ActivateCellBroadcast PASSED");
}
}
if (CdmaTest)
{
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ClearCdmaCellBroadcastServices FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ClearCdmaCellBroadcastServices PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ActivateCdmaCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ActivateCdmaCellBroadcast PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_DeactivateCdmaCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_DeactivateCdmaCellBroadcast PASSED");
}
res = TestAddRemoveCDMACellBroadcastIds();
if (res != LE_OK)
{
LE_ERROR(
"TestAddRemoveCDMACellBroadcastIds FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"TestAddRemoveCDMACellBroadcastIds PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_AddCdmaCellBroadcastServices FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_AddCdmaCellBroadcastServices PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ActivateCdmaCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ActivateCdmaCellBroadcast PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_DeactivateCdmaCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_DeactivateCdmaCellBroadcast PASSED");
}
if (res != LE_OK)
{
LE_ERROR(
"le_sms_ActivateCdmaCellBroadcast FAILED");
statusPassed = false;
}
else
{
LE_INFO(
"le_sms_ActivateCdmaCellBroadcast PASSED");
}
}
if (statusPassed)
{
LE_INFO(
"smsCBTest sequence STARTED PASSED");
}
else
{
LE_ERROR(
"smsCBTest sequence STARTED FAILED");
}
}