aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2016-07-10 11:15:29 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2016-07-24 12:31:05 +0200
commita6bd8412478126961b60e166d74044048cd18d04 (patch)
tree3c135a97c36b0cb121d0a3c381035600c24ff6d3 /src/test
parent3ef9ef88bd8974155e423925486ed308217f91c9 (diff)
NMT: Various fixes for SMS support
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_dms.c2
-rw-r--r--src/test/test_sms.c22
2 files changed, 20 insertions, 4 deletions
diff --git a/src/test/test_dms.c b/src/test/test_dms.c
index c773cfc..677b78e 100644
--- a/src/test/test_dms.c
+++ b/src/test/test_dms.c
@@ -68,6 +68,7 @@ nmt_t *alloc_nmt(void)
nmt_t *nmt;
nmt = calloc(sizeof(*nmt), 1);
+ dms_init_sender(nmt);
nmt->dms.frame_spl = calloc(1000000, 1);
nmt->samples_per_bit = 40;
@@ -78,6 +79,7 @@ nmt_t *alloc_nmt(void)
void free_nmt(nmt_t *nmt)
{
+ dms_cleanup_sender(nmt);
free(nmt->dms.frame_spl);
free(nmt);
}
diff --git a/src/test/test_sms.c b/src/test/test_sms.c
index 917f10e..fb63ba0 100644
--- a/src/test/test_sms.c
+++ b/src/test/test_sms.c
@@ -55,10 +55,15 @@ static uint8_t dms_buffer[256];
static int dms_buffer_count;
void dms_send(nmt_t *nmt, const uint8_t *data, int length, int eight_bits)
{
- memcpy(dms_buffer, data, length);
- dms_buffer_count = length;
// int i;
+ /* skip deliver report */
+ if (length == 13)
+ return;
+
+ dms_buffer_count = length;
+ memcpy(dms_buffer, data, length);
+
assert(length == sizeof(test_mt_sms_data), "Expecting SMS binary data length to match");
assert(!memcmp(data, test_mt_sms_data, length), "Expecting SMS binary data to match");
// for (i = 0; i < length; i++) {
@@ -71,10 +76,12 @@ void sms_release(nmt_t *nmt)
printf("(got release from SMS layer)\n");
}
-void sms_submit(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_type, uint8_t orig_plan, int msg_ref, const char *dest_address, uint8_t dest_type, uint8_t dest_plan, const char *message)
+int sms_submit(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_type, uint8_t orig_plan, int msg_ref, const char *dest_address, uint8_t dest_type, uint8_t dest_plan, const char *message)
{
strcpy((char *)dms_buffer, message);
dms_buffer_count = strlen(message);
+
+ return 0;
}
void sms_deliver_report(nmt_t *nmt, uint8_t ref, int error, uint8_t cause)
@@ -92,6 +99,7 @@ int main(void)
debuglevel = DEBUG_DEBUG;
nmt = calloc(sizeof(*nmt), 1);
+ sms_init_sender(nmt);
sms_reset(nmt);
/* deliver */
@@ -99,10 +107,13 @@ int main(void)
rc = sms_deliver(nmt, 1, test_mt_sms_tel, SMS_TYPE_INTERNATIONAL, SMS_PLAN_ISDN_TEL, test_mt_sms_time, test_mt_sms_text);
assert(rc == 0, "Expecting sms_deliver() to return 0");
+ sms_cleanup_sender(nmt);
+ free(nmt);
+
ok();
- free(nmt);
nmt = calloc(sizeof(*nmt), 1);
+ sms_init_sender(nmt);
sms_reset(nmt);
printf("(submitting SMS)\n");
@@ -113,6 +124,9 @@ int main(void)
assert(dms_buffer_count == strlen(test_mo_sms_text), "Expecting SMS text length to match");
assert(!memcmp(dms_buffer, test_mo_sms_text, dms_buffer_count), "Expecting SMS text to match");
+ sms_cleanup_sender(nmt);
+ free(nmt);
+
ok();
return 0;