aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2024-04-03 10:58:57 -0500
committerDenis Kenzior <denkenz@gmail.com>2024-04-03 11:42:58 -0500
commit393b6cc3dcbeb40c1a5b2068d5d1abaa32050397 (patch)
tree03da2e8512ea27d267eabe6ba238bc83f8b7dbff
parent64e2380f4b3769661162bf34c39d2b858992fcdc (diff)
downloadofono-393b6cc3dcbeb40c1a5b2068d5d1abaa32050397.tar.gz
unit: Add test cases with tags_filter provided
Replace the XYZ operator contexts with a set of two. One tagged as 'lte' and one tagged as '5g'. Add logic to the provision unit test to support filter tags.
-rw-r--r--unit/test-provision.c37
-rw-r--r--unit/test-provision.json10
2 files changed, 40 insertions, 7 deletions
diff --git a/unit/test-provision.c b/unit/test-provision.c
index b80f4d80f..d251f31b1 100644
--- a/unit/test-provision.c
+++ b/unit/test-provision.c
@@ -57,6 +57,7 @@ struct provision_test {
const char *mcc;
const char *mnc;
const char *spn;
+ const char *tags;
int result;
size_t n_items;
const struct provision_db_entry *items;
@@ -114,7 +115,7 @@ static const struct provision_db_entry charlie_contexts[] = {
},
};
-static const struct provision_db_entry xyz_contexts[] = {
+static const struct provision_db_entry xyz_lte_contexts[] = {
{
.type = OFONO_GPRS_CONTEXT_TYPE_INTERNET |
OFONO_GPRS_CONTEXT_TYPE_IA,
@@ -124,6 +125,16 @@ static const struct provision_db_entry xyz_contexts[] = {
}
};
+static const struct provision_db_entry xyz_5g_contexts[] = {
+ {
+ .type = OFONO_GPRS_CONTEXT_TYPE_INTERNET |
+ OFONO_GPRS_CONTEXT_TYPE_IA,
+ .proto = OFONO_GPRS_PROTO_IPV4V6,
+ .apn = "xyz.5g",
+ .auth_method = OFONO_GPRS_AUTH_METHOD_CHAP,
+ }
+};
+
/* Make sure mccmnc not in the database isn't found */
static const struct provision_test unknown_mcc_mnc = {
.mcc = "994",
@@ -204,13 +215,25 @@ static const struct provision_test lookup_charlie = {
};
/* Successful lookup of XYZ (MVNO on Charlie) */
-static const struct provision_test lookup_xyz = {
+static const struct provision_test lookup_lte_xyz = {
+ .mcc = "999",
+ .mnc = "11",
+ .spn = "XYZ",
+ .tags = "lte,unused",
+ .result = 0,
+ .n_items = L_ARRAY_SIZE(xyz_lte_contexts),
+ .items = xyz_lte_contexts,
+};
+
+/* Successful lookup of XYZ (MVNO on Charlie) */
+static const struct provision_test lookup_5g_xyz = {
.mcc = "999",
.mnc = "11",
.spn = "XYZ",
+ .tags = "5g",
.result = 0,
- .n_items = L_ARRAY_SIZE(xyz_contexts),
- .items = xyz_contexts,
+ .n_items = L_ARRAY_SIZE(xyz_5g_contexts),
+ .items = xyz_5g_contexts,
};
/* No match with for an MCC/MNC present in the DB, but no wildcard entry */
@@ -224,11 +247,12 @@ static void provision_lookup(const void *data)
{
const struct provision_test *test = data;
struct provision_db_entry *items;
+ _auto_(l_strv_free) char **tags = l_strsplit(test->tags, ',');
size_t n_items;
size_t i;
int r;
- r = provision_db_lookup(pdb, test->mcc, test->mnc, test->spn, NULL,
+ r = provision_db_lookup(pdb, test->mcc, test->mnc, test->spn, tags,
&items, &n_items);
assert(r == test->result);
@@ -270,7 +294,8 @@ int main(int argc, char **argv)
l_test_add("Successful lookup (Alpha)", provision_lookup, &lookup_alpha);
l_test_add("Successful lookup (ZYX)", provision_lookup, &lookup_zyx);
l_test_add("Exact match (Charlie)", provision_lookup, &lookup_charlie);
- l_test_add("Exact match (XYZ)", provision_lookup, &lookup_xyz);
+ l_test_add("Exact match (XYZ)", provision_lookup, &lookup_lte_xyz);
+ l_test_add("Exact match (XYZ 5G)", provision_lookup, &lookup_5g_xyz);
l_test_add("Exact math (no match)", provision_lookup, &lookup_no_match);
pdb = provision_db_new(UNITDIR "test-provision.db");
diff --git a/unit/test-provision.json b/unit/test-provision.json
index 61d060ad4..fcf82a67b 100644
--- a/unit/test-provision.json
+++ b/unit/test-provision.json
@@ -85,7 +85,15 @@
"apn": "xyz",
"type": [
"internet", "ia"
- ]
+ ],
+ "tags": "lte"
+ },
+ {
+ "apn": "xyz.5g",
+ "type": [
+ "internet", "ia"
+ ],
+ "tags": "5g"
}
]
}