unit: convert usage of g_test_verbose

Convert all usages of this function in favor of using a static VERBOSE
variable.  We almost never use verbose output except while debugging.

Additionally this allows us to more easily convert all unit tests to the
ell unit test framework
This commit is contained in:
Denis Kenzior 2018-12-20 15:54:40 -06:00
parent 538804e191
commit 71544d7fe1
4 changed files with 182 additions and 174 deletions

View File

@ -29,10 +29,14 @@
#include <assert.h>
#include <glib.h>
#include <ell/ell.h>
#include <ofono/types.h>
#include "common.h"
static const bool VERBOSE = false;
static const char *invalid_strings[] = {
"33",
"*",
@ -71,8 +75,8 @@ static void test_invalid(void)
gboolean ret;
for (i = 0; invalid_strings[i]; i++) {
if (g_test_verbose())
g_print("%s...\n", invalid_strings[i]);
if (VERBOSE)
printf("%s...\n", invalid_strings[i]);
str = strdup(invalid_strings[i]);
@ -122,8 +126,8 @@ static void test_valid(void)
int i;
for (i = 0; valid_strings[i]; i++) {
if (g_test_verbose())
g_print("%s...", valid_strings[i]);
if (VERBOSE)
printf("%s...", valid_strings[i]);
str = strdup(valid_strings[i]);
@ -134,8 +138,8 @@ static void test_valid(void)
g_assert(ret == TRUE);
if (g_test_verbose())
g_print("parsed as: %d, %s, %s, %s, %s, %s\n",
if (VERBOSE)
printf("parsed as: %d, %s, %s, %s, %s, %s\n",
type, sc, sia, sib, sic, dn);
free(str);
@ -164,8 +168,8 @@ static void test_apn(void)
gboolean res;
for (i = 0; valid_apns[i]; i++) {
if (g_test_verbose())
g_print("Test Valid:%s\n", valid_apns[i]);
if (VERBOSE)
printf("Test Valid:%s\n", valid_apns[i]);
res = is_valid_apn(valid_apns[i]);
@ -173,8 +177,8 @@ static void test_apn(void)
}
for (i = 0; invalid_apns[i]; i++) {
if (g_test_verbose())
g_print("Test Invalid:%s\n", invalid_apns[i]);
if (VERBOSE)
printf("Test Invalid:%s\n", invalid_apns[i]);
res = is_valid_apn(invalid_apns[i]);

View File

@ -29,11 +29,12 @@
#include <string.h>
#include <glib.h>
#include <glib/gprintf.h>
#include "util.h"
#include "smsutil.h"
static const bool VERBOSE = false;
static const char *assembly_pdu1 = "038121F340048155550119906041001222048C0500"
"031E0301041804420430043A002C002004100"
"43B0435043A04410430043D04340440002000"
@ -81,10 +82,10 @@ static void test_serialize_assembly(void)
l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
&sms.deliver.oaddr, ref, max, seq);
if (g_test_verbose()) {
g_print("Ref: %u\n", ref);
g_print("Max: %u\n", max);
g_print("From: %s\n",
if (VERBOSE) {
printf("Ref: %u\n", ref);
printf("Max: %u\n", max);
printf("From: %s\n",
sms_address_to_string(&sms.deliver.oaddr));
}

View File

@ -30,11 +30,12 @@
#include <ell/ell.h>
#include <glib.h>
#include <glib/gprintf.h>
#include "util.h"
#include "smsutil.h"
static const bool VERBOSE = false;
static const char *simple_deliver = "07911326040000F0"
"040B911346610089F60000208062917314480CC8F71D14969741F977FD07";
static const char *alnum_sender = "0791447758100650"
@ -57,13 +58,13 @@ static void print_scts(struct sms_scts *scts, const char *prefix)
struct tm remote;
char buf[128];
g_print("%s: (YY-MM-DD) %02d-%02d-%02d\n", prefix,
printf("%s: (YY-MM-DD) %02d-%02d-%02d\n", prefix,
(int)scts->year, (int)scts->month, (int)scts->day);
g_print("%s: (HH-MM-SS) %02d:%02d:%02d\n", prefix,
printf("%s: (HH-MM-SS) %02d:%02d:%02d\n", prefix,
(int)scts->hour, (int)scts->minute, (int)scts->second);
g_print("%s: Timezone %d hours %d minutes\n", prefix,
printf("%s: Timezone %d hours %d minutes\n", prefix,
(int)scts->timezone / 4,
(int)((abs(scts->timezone) % 4) * 15));
@ -72,32 +73,32 @@ static void print_scts(struct sms_scts *scts, const char *prefix)
strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(&ts));
buf[127] = '\0';
g_print("local time: %s\n", buf);
printf("local time: %s\n", buf);
strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", &remote);
buf[127] = '\0';
g_print("remote time: %s\n", buf);
printf("remote time: %s\n", buf);
}
static void print_vpf(enum sms_validity_period_format vpf,
struct sms_validity_period *vp)
{
g_print("Validity Period Format: %d\n", (int)vpf);
printf("Validity Period Format: %d\n", (int)vpf);
switch (vpf) {
case SMS_VALIDITY_PERIOD_FORMAT_ABSENT:
g_print("Validity-Period: Absent\n");
printf("Validity-Period: Absent\n");
break;
case SMS_VALIDITY_PERIOD_FORMAT_RELATIVE:
g_print("Validity-Period: %d\n",
printf("Validity-Period: %d\n",
(int)vp->relative);
break;
case SMS_VALIDITY_PERIOD_FORMAT_ABSOLUTE:
print_scts(&vp->absolute, "Validity-Period:");
break;
case SMS_VALIDITY_PERIOD_FORMAT_ENHANCED:
g_print("Validity-Period: Enhanced");
printf("Validity-Period: Enhanced");
break;
}
}
@ -105,39 +106,39 @@ static void print_vpf(enum sms_validity_period_format vpf,
static void dump_details(struct sms *sms)
{
if (sms->sc_addr.address[0] == '\0')
g_print("SMSC Address absent, default will be used\n");
printf("SMSC Address absent, default will be used\n");
else
g_print("SMSC Address number_type: %d, number_plan: %d, %s\n",
printf("SMSC Address number_type: %d, number_plan: %d, %s\n",
(int)sms->sc_addr.number_type,
(int)sms->sc_addr.numbering_plan, sms->sc_addr.address);
switch (sms->type) {
case SMS_TYPE_DELIVER:
g_print("Type: Deliver\n");
printf("Type: Deliver\n");
g_print("Originator-Address: %d, %d, %s\n",
printf("Originator-Address: %d, %d, %s\n",
(int)sms->deliver.oaddr.number_type,
(int)sms->deliver.oaddr.numbering_plan,
sms->deliver.oaddr.address);
g_print("PID: %d\n", (int)sms->deliver.pid);
g_print("DCS: %d\n", (int)sms->deliver.dcs);
printf("PID: %d\n", (int)sms->deliver.pid);
printf("DCS: %d\n", (int)sms->deliver.dcs);
print_scts(&sms->deliver.scts, "Timestamp");
break;
case SMS_TYPE_SUBMIT:
g_print("Type: Submit\n");
printf("Type: Submit\n");
g_print("Message Reference: %u\n", (int)sms->submit.mr);
printf("Message Reference: %u\n", (int)sms->submit.mr);
g_print("Destination-Address: %d, %d, %s\n",
printf("Destination-Address: %d, %d, %s\n",
(int)sms->submit.daddr.number_type,
(int)sms->submit.daddr.numbering_plan,
sms->submit.daddr.address);
g_print("PID: %d\n", (int)sms->submit.pid);
g_print("DCS: %d\n", (int)sms->submit.dcs);
printf("PID: %d\n", (int)sms->submit.pid);
printf("DCS: %d\n", (int)sms->submit.dcs);
print_vpf(sms->submit.vpf, &sms->submit.vp);
@ -175,7 +176,7 @@ static void test_simple_deliver(void)
g_assert(ret);
g_assert(sms.type == SMS_TYPE_DELIVER);
if (g_test_verbose())
if (VERBOSE)
dump_details(&sms);
g_assert(sms.sc_addr.number_type == SMS_NUMBER_TYPE_INTERNATIONAL);
@ -216,8 +217,8 @@ static void test_simple_deliver(void)
g_assert(utf8);
if (g_test_verbose())
g_print("Decoded user data is: %s\n", utf8);
if (VERBOSE)
printf("Decoded user data is: %s\n", utf8);
g_assert(strcmp(utf8, "How are you?") == 0);
@ -246,7 +247,7 @@ static void test_alnum_sender(void)
g_assert(ret);
g_assert(sms.type == SMS_TYPE_DELIVER);
if (g_test_verbose())
if (VERBOSE)
dump_details(&sms);
g_assert(sms.sc_addr.number_type == SMS_NUMBER_TYPE_INTERNATIONAL);
@ -287,8 +288,8 @@ static void test_alnum_sender(void)
g_assert(utf8);
if (g_test_verbose())
g_print("Decoded user data is: %s\n", utf8);
if (VERBOSE)
printf("Decoded user data is: %s\n", utf8);
g_assert(strcmp(utf8, "Testmail") == 0);
@ -320,12 +321,12 @@ static void test_deliver_encode(void)
ret = sms_encode(&sms, &encoded_pdu_len, &encoded_tpdu_len, pdu);
if (g_test_verbose()) {
if (VERBOSE) {
int i;
for (i = 0; i < encoded_pdu_len; i++)
g_print("%02X", pdu[i]);
g_print("\n");
printf("%02X", pdu[i]);
printf("\n");
}
g_assert(ret);
@ -352,12 +353,12 @@ static void test_deliver_encode(void)
ret = sms_encode(&sms, &encoded_pdu_len, &encoded_tpdu_len, pdu);
if (g_test_verbose()) {
if (VERBOSE) {
int i;
for (i = 0; i < encoded_pdu_len; i++)
g_print("%02X", pdu[i]);
g_print("\n");
printf("%02X", pdu[i]);
printf("\n");
}
g_assert(ret);
@ -384,12 +385,12 @@ static void test_deliver_encode(void)
ret = sms_encode(&sms, &encoded_pdu_len, &encoded_tpdu_len, pdu);
if (g_test_verbose()) {
if (VERBOSE) {
int i;
for (i = 0; i < encoded_pdu_len; i++)
g_print("%02X", pdu[i]);
g_print("\n");
printf("%02X", pdu[i]);
printf("\n");
}
g_assert(ret);
@ -425,7 +426,7 @@ static void test_simple_submit(void)
g_assert(ret);
g_assert(sms.type == SMS_TYPE_SUBMIT);
if (g_test_verbose())
if (VERBOSE)
dump_details(&sms);
g_assert(strlen(sms.sc_addr.address) == 0);
@ -461,8 +462,8 @@ static void test_simple_submit(void)
g_assert(utf8);
if (g_test_verbose())
g_print("Decoded user data is: %s\n", utf8);
if (VERBOSE)
printf("Decoded user data is: %s\n", utf8);
g_assert(strcmp(utf8, "hellohello") == 0);
@ -494,12 +495,12 @@ static void test_submit_encode(void)
ret = sms_encode(&sms, &encoded_pdu_len, &encoded_tpdu_len, pdu);
if (g_test_verbose()) {
if (VERBOSE) {
int i;
for (i = 0; i < encoded_pdu_len; i++)
g_print("%02X", pdu[i]);
g_print("\n");
printf("%02X", pdu[i]);
printf("\n");
}
g_assert(ret);
@ -535,7 +536,7 @@ static void test_simple_mwi(void)
g_assert(ret);
g_assert(sms.type == SMS_TYPE_DELIVER);
if (g_test_verbose())
if (VERBOSE)
dump_details(&sms);
g_assert(sms.sc_addr.number_type == SMS_NUMBER_TYPE_INTERNATIONAL);
@ -577,8 +578,8 @@ static void test_simple_mwi(void)
sms_udh_iter_get_ie_data(&iter, evm_iei);
sms_udh_iter_get_ie_length(&iter);
if (g_test_verbose())
g_print("Enhanced Voicemail IEI\n");
if (VERBOSE)
printf("Enhanced Voicemail IEI\n");
break;
}
@ -589,8 +590,8 @@ static void test_simple_mwi(void)
sms_udh_iter_get_ie_data(&iter, special_iei);
sms_udh_iter_get_ie_length(&iter);
if (g_test_verbose())
g_print("Special Voicemail IEI\n");
if (VERBOSE)
printf("Special Voicemail IEI\n");
break;
}
@ -607,8 +608,8 @@ static void test_simple_mwi(void)
&discard);
g_assert(ret);
if (g_test_verbose()) {
g_print("Type: %d, Active: %d, Discard: %d\n",
if (VERBOSE) {
printf("Type: %d, Active: %d, Discard: %d\n",
type, active, discard);
}
@ -979,7 +980,7 @@ static void test_ems_udh(gconstpointer data)
g_assert(ret);
g_assert(sms.type == SMS_TYPE_SUBMIT);
if (g_test_verbose())
if (VERBOSE)
dump_details(&sms);
udhl = sms.submit.ud[0];
@ -991,17 +992,17 @@ static void test_ems_udh(gconstpointer data)
g_assert(ret);
for (i = 0; test->formats[i].len; i++) {
if (g_test_verbose()) {
if (VERBOSE) {
int j;
unsigned char ie_data[4];
sms_udh_iter_get_ie_data(&iter, ie_data);
g_print("Header:\n");
printf("Header:\n");
for (j = 0; j < sms_udh_iter_get_ie_length(&iter); j++)
g_print("0x%02x ", ie_data[j]);
printf("0x%02x ", ie_data[j]);
g_print("\n");
printf("\n");
}
g_assert(sms_udh_iter_get_ie_type(&iter) ==
@ -1037,8 +1038,8 @@ static void test_ems_udh(gconstpointer data)
g_assert(utf8);
if (g_test_verbose())
g_print("Decoded user data is: %s\n", utf8);
if (VERBOSE)
printf("Decoded user data is: %s\n", utf8);
g_assert(strcmp(utf8, test->expected) == 0);
@ -1094,10 +1095,10 @@ static void test_assembly(void)
l = sms_assembly_add_fragment(assembly, &sms, time(NULL),
&sms.deliver.oaddr, ref, max, seq);
if (g_test_verbose()) {
g_print("Ref: %u\n", ref);
g_print("Max: %u\n", max);
g_print("From: %s\n",
if (VERBOSE) {
printf("Ref: %u\n", ref);
printf("Max: %u\n", max);
printf("From: %s\n",
sms_address_to_string(&sms.deliver.oaddr));
}
@ -1137,8 +1138,8 @@ static void test_assembly(void)
sms_assembly_free(assembly);
if (g_test_verbose())
g_printf("Text:\n%s\n", utf8);
if (VERBOSE)
printf("Text:\n%s\n", utf8);
l = sms_text_prepare("555", utf8, ref, TRUE, FALSE);
g_assert(l);
@ -1148,8 +1149,8 @@ static void test_assembly(void)
g_slist_free_full(l, g_free);
if (g_test_verbose())
g_printf("ReEncoded:\n%s\n", reencoded);
if (VERBOSE)
printf("ReEncoded:\n%s\n", reencoded);
g_assert(strcmp(utf8, reencoded) == 0);
@ -1183,8 +1184,8 @@ static void test_prepare_7bit(void)
sms->sc_addr.numbering_plan = SMS_NUMBERING_PLAN_ISDN;
strcpy(sms->sc_addr.address, sc_addr+1);
if (g_test_verbose())
g_print("sc_addr: %s\n", sms_address_to_string(&sms->sc_addr));
if (VERBOSE)
printf("sc_addr: %s\n", sms_address_to_string(&sms->sc_addr));
g_assert(!strcmp(sc_addr, sms_address_to_string(&sms->sc_addr)));
@ -1192,8 +1193,8 @@ static void test_prepare_7bit(void)
sms->submit.daddr.numbering_plan = SMS_NUMBERING_PLAN_ISDN;
strcpy(sms->submit.daddr.address, da_addr+1);
if (g_test_verbose())
g_print("da_addr: %s\n",
if (VERBOSE)
printf("da_addr: %s\n",
sms_address_to_string(&sms->submit.daddr));
g_assert(!strcmp(da_addr,
@ -1203,12 +1204,12 @@ static void test_prepare_7bit(void)
g_assert(ret);
if (g_test_verbose()) {
if (VERBOSE) {
int i;
for (i = 0; i < encoded_pdu_len; i++)
g_print("%02X", pdu[i]);
g_print("\n");
printf("%02X", pdu[i]);
printf("\n");
}
encoded_pdu = encode_hex(pdu, encoded_pdu_len, 0);
@ -1251,8 +1252,8 @@ static void test_prepare_concat(gconstpointer data)
guint8 max;
guint8 seq;
if (g_test_verbose())
g_print("strlen: %zd\n", strlen(test->str));
if (VERBOSE)
printf("strlen: %zd\n", strlen(test->str));
r = sms_text_prepare("+15554449999", test->str, 0, TRUE, FALSE);
g_assert(r);
@ -1268,8 +1269,8 @@ static void test_prepare_concat(gconstpointer data)
strpdu = encode_hex(pdu, pdu_len, 0);
if (g_test_verbose())
g_printf("PDU: %s, len: %d, tlen: %d\n",
if (VERBOSE)
printf("PDU: %s, len: %d, tlen: %d\n",
strpdu, pdu_len, tpdu_len);
pdus = g_slist_append(pdus, strpdu);
}
@ -1282,14 +1283,14 @@ static void test_prepare_concat(gconstpointer data)
decode_hex_own_buf((char *)l->data, -1, &len, 0, pdu);
if (g_test_verbose())
g_print("PDU Len: %ld\n", len);
if (VERBOSE)
printf("PDU Len: %ld\n", len);
ok = sms_decode(pdu, len, TRUE, len - 1, &decoded);
g_assert(ok);
if (g_test_verbose())
g_print("Pdu udl: %d\n", (int)decoded.submit.udl);
if (VERBOSE)
printf("Pdu udl: %d\n", (int)decoded.submit.udl);
sms_extract_concatenation(&decoded, &ref, &max, &seq);
r = sms_assembly_add_fragment(assembly, &decoded, time(NULL),
@ -1301,8 +1302,8 @@ static void test_prepare_concat(gconstpointer data)
decoded_str = sms_decode_text(r);
if (g_test_verbose())
g_printf("Decoded String: %s\n", decoded_str);
if (VERBOSE)
printf("Decoded String: %s\n", decoded_str);
g_assert(decoded_str);
g_assert(strcmp(decoded_str, test->str) == 0);
@ -1424,12 +1425,12 @@ static void test_cbs_encode_decode(void)
g_assert(utf8);
if (g_test_verbose()) {
g_printf("%s\n", utf8);
if (VERBOSE) {
printf("%s\n", utf8);
if (iso639_lang[0] == '\0')
g_printf("Lang: Unspecified\n");
printf("Lang: Unspecified\n");
else
g_printf("Lang: %s\n", iso639_lang);
printf("Lang: %s\n", iso639_lang);
}
g_assert(strcmp(utf8, "Belconnen") == 0);
@ -1519,12 +1520,12 @@ static void test_cbs_assembly(void)
g_assert(utf8);
if (g_test_verbose()) {
g_printf("%s\n", utf8);
if (VERBOSE) {
printf("%s\n", utf8);
if (iso639_lang[0] == '\0')
g_printf("Lang: Unspecified\n");
printf("Lang: Unspecified\n");
else
g_printf("Lang: %s\n", iso639_lang);
printf("Lang: %s\n", iso639_lang);
}
g_assert(strcmp(utf8, "BelconnenFraserBelconnen") == 0);
@ -1570,12 +1571,12 @@ static void test_cbs_padding_character(void)
g_assert(utf8);
if (g_test_verbose()) {
g_printf("%s\n", utf8);
if (VERBOSE) {
printf("%s\n", utf8);
if (iso639_lang[0] == '\0')
g_printf("Lang: Unspecified\n");
printf("Lang: Unspecified\n");
else
g_printf("Lang: %s\n", iso639_lang);
printf("Lang: %s\n", iso639_lang);
}
g_assert(strcmp(utf8, "b£$¥èéùìòÇ\x0AØø\x0DÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\""
@ -1617,8 +1618,8 @@ static void test_range_minimizer(void)
g_assert(rangestr);
if (g_test_verbose())
g_print("range: %s\n", rangestr);
if (VERBOSE)
printf("range: %s\n", rangestr);
g_free(rangestr);
g_slist_free_full(r, g_free);
@ -1659,16 +1660,16 @@ static void test_sr_assembly(void)
decode_hex_own_buf(sr_pdu3, -1, &pdu_len, 0, pdu);
g_assert(sms_decode(pdu, pdu_len, FALSE, 24, &sr3) == TRUE);
if (g_test_verbose()) {
g_print("sr1 address: %s, mr: %d\n",
if (VERBOSE) {
printf("sr1 address: %s, mr: %d\n",
sms_address_to_string(&sr1.status_report.raddr),
sr1.status_report.mr);
g_print("sr2 address: %s, mr: %d\n",
printf("sr2 address: %s, mr: %d\n",
sms_address_to_string(&sr2.status_report.raddr),
sr2.status_report.mr);
g_print("sr3 address: %s, mr: %d\n",
printf("sr3 address: %s, mr: %d\n",
sms_address_to_string(&sr3.status_report.raddr),
sr3.status_report.mr);
}
@ -1763,7 +1764,7 @@ static void test_wap_push(gconstpointer data)
g_assert(ret);
g_assert(sms.type == SMS_TYPE_DELIVER);
if (g_test_verbose())
if (VERBOSE)
dump_details(&sms);
ret = sms_dcs_decode(sms.deliver.dcs, &cls, &charset, NULL, NULL);
@ -1773,9 +1774,9 @@ static void test_wap_push(gconstpointer data)
g_assert(sms_extract_app_port(&sms, &dst_port, &src_port, &is_8bit));
if (g_test_verbose()) {
g_print("8bit: %d\n", is_8bit);
g_print("src: %d, dst: %d\n", src_port, dst_port);
if (VERBOSE) {
printf("8bit: %d\n", is_8bit);
printf("src: %d, dst: %d\n", src_port, dst_port);
}
g_assert(is_8bit == FALSE);
@ -1785,19 +1786,19 @@ static void test_wap_push(gconstpointer data)
wap_push = sms_decode_datagram(list, &data_len);
if (g_test_verbose()) {
if (VERBOSE) {
int i;
g_print("data_len: %ld\n", data_len);
printf("data_len: %ld\n", data_len);
for (i = 0; i < data_len; i++) {
g_print("%02x", wap_push[i]);
printf("%02x", wap_push[i]);
if ((i % 16) == 15)
g_print("\n");
printf("\n");
}
g_print("\n");
printf("\n");
}
g_assert(wap_push);

View File

@ -31,6 +31,8 @@
#include "util.h"
static const bool VERBOSE = false;
const unsigned char invalid_gsm_extended[] = {
0x1b, 0x15
};
@ -428,8 +430,8 @@ static void test_valid(void)
res = convert_gsm_to_utf8(buf, size, &nread, &nwritten, 0);
g_assert(res);
if (g_test_verbose())
g_print("size: %ld, nread:%ld, nwritten:%ld, %s\n",
if (VERBOSE)
printf("size: %ld, nread:%ld, nwritten:%ld, %s\n",
size, nread, nwritten, res);
g_assert(nread == size);
@ -491,8 +493,8 @@ static void test_valid_turkish(void)
&nwritten, 0, 1, 1);
g_assert(res);
if (g_test_verbose())
g_print("size: %ld, nread:%ld, nwritten:%ld, %s\n",
if (VERBOSE)
printf("size: %ld, nread:%ld, nwritten:%ld, %s\n",
size, nread, nwritten, res);
g_assert(nread == size);
@ -542,23 +544,23 @@ static void test_decode_encode(void)
long gsm_encoded_size;
long i;
if (g_test_verbose())
g_print("Size of the orig string: %u\n",
if (VERBOSE)
printf("Size of the orig string: %u\n",
(unsigned int)strlen(sms));
decoded = decode_hex(sms, -1, &hex_decoded_size, 0);
g_assert(decoded != NULL);
if (g_test_verbose())
g_print("Decode to %ld bytes\n", hex_decoded_size);
if (VERBOSE)
printf("Decode to %ld bytes\n", hex_decoded_size);
if (g_test_verbose()) {
g_print("%s\n", sms);
if (VERBOSE) {
printf("%s\n", sms);
for (i = 0; i < hex_decoded_size; i++)
g_print("%02X", decoded[i]);
g_print("\n");
printf("%02X", decoded[i]);
printf("\n");
}
gsm = unpack_7bit(decoded, hex_decoded_size, 0, false,
@ -566,15 +568,15 @@ static void test_decode_encode(void)
g_assert(gsm != NULL);
if (g_test_verbose())
g_print("String unpacked to %ld bytes\n", unpacked_size);
if (VERBOSE)
printf("String unpacked to %ld bytes\n", unpacked_size);
utf8 = convert_gsm_to_utf8(gsm, -1, NULL, NULL, 0xff);
g_assert(utf8 != NULL);
if (g_test_verbose())
g_print("String is: -->%s<--\n", utf8);
if (VERBOSE)
printf("String is: -->%s<--\n", utf8);
g_assert(strcmp(utf8, expected) == 0);
@ -583,8 +585,8 @@ static void test_decode_encode(void)
g_assert(gsm_encoded != NULL);
if (g_test_verbose())
g_print("Converted back to GSM string of %ld bytes\n",
if (VERBOSE)
printf("Converted back to GSM string of %ld bytes\n",
gsm_encoded_size);
g_assert(gsm_encoded[gsm_encoded_size] == 0xff);
@ -600,13 +602,13 @@ static void test_decode_encode(void)
g_assert(packed != NULL);
if (g_test_verbose())
g_print("Packed GSM to size of %ld bytes\n", packed_size);
if (VERBOSE)
printf("Packed GSM to size of %ld bytes\n", packed_size);
if (g_test_verbose()) {
if (VERBOSE) {
for (i = 0; i < packed_size; i++)
g_print("%02X", packed[i]);
g_print("\n");
printf("%02X", packed[i]);
printf("\n");
}
g_assert(packed_size == hex_decoded_size);
@ -620,8 +622,8 @@ static void test_decode_encode(void)
l_free(packed);
if (g_test_verbose())
g_print("Hex encoded packed to size %ld bytes\n",
if (VERBOSE)
printf("Hex encoded packed to size %ld bytes\n",
(long)strlen(hex_packed));
g_assert(strlen(hex_packed) == strlen(sms));
@ -713,8 +715,8 @@ static void test_cr_handling(void)
g_assert((packed[7] & 0x7f) == '\r');
unpacked = unpack_7bit(packed, 8, 0, true, -1, &unpacked_size, 0);
if (g_test_verbose())
g_print("Unpacked to size: %ld\n", unpacked_size);
if (VERBOSE)
printf("Unpacked to size: %ld\n", unpacked_size);
g_assert(unpacked != NULL);
g_assert(unpacked_size == 9);
@ -729,8 +731,8 @@ static void test_cr_handling(void)
g_assert(((packed[6] & 0xfe) >> 1) == '\r');
unpacked = unpack_7bit(packed, 7, 0, true, -1, &unpacked_size, 0);
if (g_test_verbose())
g_print("Unpacked to size: %ld\n", unpacked_size);
if (VERBOSE)
printf("Unpacked to size: %ld\n", unpacked_size);
g_assert(unpacked != NULL);
g_assert(unpacked_size == 7);
@ -744,8 +746,8 @@ static void test_cr_handling(void)
*/
packed = pack_7bit(c7, 7, 0, true, &packed_size, 0);
unpacked = unpack_7bit(packed, 7, 0, false, 8, &unpacked_size, 0);
if (g_test_verbose())
g_print("Unpacked to size: %ld\n", unpacked_size);
if (VERBOSE)
printf("Unpacked to size: %ld\n", unpacked_size);
g_assert(unpacked != NULL);
g_assert(unpacked_size == 8);
@ -769,8 +771,8 @@ static void test_sms_handling(void)
g_assert(packed_size == 7);
unpacked = unpack_7bit(packed, 7, 0, FALSE, 8, &unpacked_size, 0xff);
if (g_test_verbose())
g_print("Unpacked to size: %ld\n", unpacked_size);
if (VERBOSE)
printf("Unpacked to size: %ld\n", unpacked_size);
g_assert(unpacked != NULL);
g_assert(unpacked_size == 8);
@ -785,8 +787,8 @@ static void test_sms_handling(void)
g_assert(packed_size == 7);
unpacked = unpack_7bit(packed, 7, 0, FALSE, 7, &unpacked_size, 0xff);
if (g_test_verbose())
g_print("Unpacked to size: %ld\n", unpacked_size);
if (VERBOSE)
printf("Unpacked to size: %ld\n", unpacked_size);
g_assert(unpacked != NULL);
g_assert(unpacked_size == 7);
@ -809,15 +811,15 @@ static void test_offset_handling(void)
/* Pack at offset = 2 bytes, e.g. starting with 21st bit */
packed = pack_7bit(c7, 6, 2, FALSE, &packed_size, 0);
if (g_test_verbose())
g_print("Packed to size: %ld\n", packed_size);
if (VERBOSE)
printf("Packed to size: %ld\n", packed_size);
g_assert(packed != NULL);
g_assert(packed_size == 6);
unpacked = unpack_7bit(packed, 6, 2, FALSE, 6, &unpacked_size, 0xff);
if (g_test_verbose())
g_print("Unpacked to size: %ld\n", unpacked_size);
if (VERBOSE)
printf("Unpacked to size: %ld\n", unpacked_size);
g_assert(unpacked != NULL);
g_assert(unpacked_size == 6);
@ -835,15 +837,15 @@ static void test_offset_handling(void)
*/
packed = pack_7bit(c8, 8, 6, FALSE, &packed_size, 0);
if (g_test_verbose())
g_print("Packed to size: %ld\n", packed_size);
if (VERBOSE)
printf("Packed to size: %ld\n", packed_size);
g_assert(packed != NULL);
g_assert(packed_size == 8);
unpacked = unpack_7bit(packed, 8, 6, FALSE, 8, &unpacked_size, 0xff);
if (g_test_verbose())
g_print("Unpacked to size: %ld\n", unpacked_size);
if (VERBOSE)
printf("Unpacked to size: %ld\n", unpacked_size);
g_assert(unpacked != NULL);
g_assert(unpacked_size == 8);
@ -857,15 +859,15 @@ static void test_offset_handling(void)
/* Same as above, but instead pack in 9 characters */
packed = pack_7bit(c9, 9, 6, FALSE, &packed_size, 0);
if (g_test_verbose())
g_print("Packed to size: %ld\n", packed_size);
if (VERBOSE)
printf("Packed to size: %ld\n", packed_size);
g_assert(packed != NULL);
g_assert(packed_size == 8);
unpacked = unpack_7bit(packed, 8, 6, FALSE, 9, &unpacked_size, 0xff);
if (g_test_verbose())
g_print("Unpacked to size: %ld\n", unpacked_size);
if (VERBOSE)
printf("Unpacked to size: %ld\n", unpacked_size);
g_assert(unpacked != NULL);
g_assert(unpacked_size == 9);
@ -975,8 +977,8 @@ static void test_unicode_to_gsm(void)
res = convert_ucs2_to_gsm(buf, 2, &nread, &nwritten, 0);
g_assert(res);
if (g_test_verbose())
g_print("nread:%ld, nwritten:%ld, %s\n",
if (VERBOSE)
printf("nread:%ld, nwritten:%ld, %s\n",
nread, nwritten, res);
if (res[0] == 0x1B)
@ -1001,8 +1003,8 @@ static void test_unicode_to_gsm(void)
verify = back[0];
}
if (g_test_verbose())
g_print("nwritten:%ld, verify: 0x%x\n",
if (VERBOSE)
printf("nwritten:%ld, verify: 0x%x\n",
nwritten, verify);
g_assert(verify == gsm_to_unicode_map[i*2]);