test: add csd_test

Show that csd_bs_list_remove() is currently broken, the next patch will
fix it.

Related: OS#4394
Change-Id: Icc98de75e97c75216a71caf94355d09330c95cba
diff --git a/tests/csd/Makefile.am b/tests/csd/Makefile.am
new file mode 100644
index 0000000..581f7d4
--- /dev/null
+++ b/tests/csd/Makefile.am
@@ -0,0 +1,37 @@
+AM_CPPFLAGS = \
+	$(all_includes) \
+	-I$(top_srcdir)/include \
+	$(NULL)
+
+AM_CFLAGS = \
+	-Wall \
+	-ggdb3 \
+	$(LIBOSMOCORE_CFLAGS) \
+	$(NULL)
+
+AM_LDFLAGS = \
+	$(COVERAGE_LDFLAGS) \
+	-no-install \
+	$(NULL)
+
+LDADD = \
+	$(top_builddir)/src/libmsc/libmsc.a \
+	$(LIBOSMOCORE_LIBS) \
+	$(NULL)
+
+EXTRA_DIST = \
+	csd_test.ok \
+	csd_test.err \
+	$(NULL)
+
+check_PROGRAMS = \
+	csd_test \
+	$(NULL)
+
+csd_test_SOURCES = \
+	csd_test.c \
+	$(NULL)
+
+.PHONY: update_exp
+update_exp:
+	$(builddir)/csd_test >$(srcdir)/csd_test.ok 2>$(srcdir)/csd_test.err
diff --git a/tests/csd/csd_test.c b/tests/csd/csd_test.c
new file mode 100644
index 0000000..ad3b0da
--- /dev/null
+++ b/tests/csd/csd_test.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <osmocom/core/application.h>
+#include <osmocom/msc/csd_bs.h>
+#include <osmocom/msc/debug.h>
+
+void test_csd_bs_list_remove(void)
+{
+	struct csd_bs_list list = {
+		.count = 3,
+		.bs = {
+			CSD_BS_21_T_V110_0k3,
+			CSD_BS_22_T_V110_1k2,
+			CSD_BS_24_T_V110_2k4,
+		},
+	};
+
+	printf("=== %s ===\n", __func__);
+	printf("initial:\n");
+	printf("  %s\n", csd_bs_list_to_str(&list));
+
+	printf("removing BS25T (not in the list):\n");
+	csd_bs_list_remove(&list, CSD_BS_25_T_V110_4k8);
+	printf("  %s\n", csd_bs_list_to_str(&list));
+
+	printf("removing BS22T:\n");
+	csd_bs_list_remove(&list, CSD_BS_22_T_V110_1k2);
+	printf("  %s\n", csd_bs_list_to_str(&list));
+
+	printf("removing BS24T:\n");
+	csd_bs_list_remove(&list, CSD_BS_24_T_V110_2k4);
+	printf("  %s\n", csd_bs_list_to_str(&list));
+
+	printf("removing BS21T:\n");
+	csd_bs_list_remove(&list, CSD_BS_21_T_V110_0k3);
+	printf("  %s\n", csd_bs_list_to_str(&list));
+}
+
+int main(void)
+{
+	test_csd_bs_list_remove();
+	return 0;
+}
diff --git a/tests/csd/csd_test.err b/tests/csd/csd_test.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/csd/csd_test.err
diff --git a/tests/csd/csd_test.ok b/tests/csd/csd_test.ok
new file mode 100644
index 0000000..8ba59b3
--- /dev/null
+++ b/tests/csd/csd_test.ok
@@ -0,0 +1,11 @@
+=== test_csd_bs_list_remove ===
+initial:
+  BS21T,BS22T,BS24T
+removing BS25T (not in the list):
+  BS21T,BS22T,BS24T
+removing BS22T:
+  BS21T,BS22T
+removing BS24T:
+  BS21T,BS22T
+removing BS21T:
+  BS21T