summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-16 20:47:37 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-16 20:56:08 +0100
commit13cd1199b92b98241d594c02873cd80a218a80ac (patch)
treed6f06e31bfc08b4e24f930edb936dfb1954f530b /tests
parentec5409ca4f46c30813c7d213d15880a691e8e91f (diff)
sccp: Rewrite the sccp_test_addr to set the size correctly
Fix the code to set the number of consumed bytes correctly and return the number of bytes consumed for for the address. Add a simple but expandable test case to test the SCCP address
Diffstat (limited to 'tests')
-rw-r--r--tests/sccp/sccp_test.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/sccp/sccp_test.c b/tests/sccp/sccp_test.c
index c5c6f4f..35b4cb7 100644
--- a/tests/sccp/sccp_test.c
+++ b/tests/sccp/sccp_test.c
@@ -887,6 +887,48 @@ static void test_sccp_parsing(void)
}
}
+/*
+ * Test the creation of SCCP addresses
+ */
+int sccp_create_sccp_addr(struct msgb *msg, const struct sockaddr_sccp *sock);
+
+struct sccp_addr_tst {
+ const struct sockaddr_sccp *addr;
+
+ const uint8_t *output;
+ const int output_len;
+};
+
+static uint8_t ssn_out[] = {
+ 0x02, 0x42, 0xfe,
+};
+
+static struct sccp_addr_tst sccp_addr_tst[] = {
+ {
+ .addr = &sccp_ssn_bssap,
+ .output = ssn_out,
+ .output_len = ARRAY_SIZE(ssn_out),
+ },
+};
+
+static void test_sccp_address()
+{
+ int i, ret;
+ struct msgb *msg = msgb_alloc(128, "sccp-addr");
+
+ for (i = 0; i < ARRAY_SIZE(sccp_addr_tst); ++i) {
+ msgb_reset(msg);
+ ret = sccp_create_sccp_addr(msg, sccp_addr_tst[i].addr);
+ if (ret != sccp_addr_tst[i].output_len) {
+ FAIL("Length is from for %d\n", i);
+ }
+
+ if (memcmp(msg->data, sccp_addr_tst[i].output, ret) != 0) {
+ FAIL("Unexpected data for %d\n", i);
+ }
+ }
+}
+
static const struct log_info_cat default_categories[] = {
[0] = {
.name = "DSCCP",
@@ -921,6 +963,7 @@ int main(int argc, char **argv)
test_sccp_connection();
test_sccp_system_crash();
test_sccp_parsing();
+ test_sccp_address();
return 0;
}