summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/tests/libspid/utests/src/service_eoc_stub.c
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/devkit/tests/libspid/utests/src/service_eoc_stub.c')
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/service_eoc_stub.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/cleopatre/devkit/tests/libspid/utests/src/service_eoc_stub.c b/cleopatre/devkit/tests/libspid/utests/src/service_eoc_stub.c
new file mode 100644
index 0000000000..b009274337
--- /dev/null
+++ b/cleopatre/devkit/tests/libspid/utests/src/service_eoc_stub.c
@@ -0,0 +1,107 @@
+
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file service_eoc_stubs.c
+ * \brief Stubs for service related unitary tests for libspid
+ * \ingroup Cleopatre - libspid
+ *
+ * This file contains stub functions used in unitary tests
+ * for services in EoC libspid.
+ */
+
+#include <check.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <linux/if_tun.h>
+#include <linux/if_ether.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <net/if.h>
+#include <string.h>
+
+#include "eoc_utests.h"
+
+
+libspid_error_t
+service_send_single_value (unsigned int mmtype, const void *value,
+ unsigned int length)
+{
+ unsigned char action1 = 0x00;
+ unsigned char service_num = 0x01;
+ unsigned char index1 = 0x02;
+ unsigned char index2 = 0x01;
+ /* using service type as classifier rule ID */
+ unsigned char cl_rule1 = 0x01;
+ /* using matching value as classifier rule value */
+ unsigned char cl_value1[2] = {0x01, 0x00};
+ unsigned char acs_en1 = 0x01;
+ /* parameter number is always 7 */
+ unsigned char param_nb1 = 0x07;
+ /* latency */
+ unsigned char param_value1[2] = {0x32, 0x00};
+ /* jitter */
+ unsigned char param_value2[2] = {0x14, 0x00};
+ /* down PIR */
+ unsigned char param_value3[2] = {0x64, 0x00};
+ /* up PIR */
+ unsigned char param_value4[2] = {0xC8, 0x00};
+ /* down CIR */
+ unsigned char param_value5[2] = {0x64, 0x00};
+ /* up CIR */
+ unsigned char param_value6[2] = {0xC8, 0x00};
+ /* QOS prio */
+ unsigned char param_value7[2] = {0x05, 0x00};
+
+ if (memcmp (value, &action1, 1) != 0)
+ {
+ fail_if (memcmp (value + 2, &index2, 1) != 0,
+ "fail: wrong service index for remove" );
+ return 0;
+ }
+ fail_if (memcmp (value, &action1, 1) != 0,
+ "fail: wrong action" );
+ fail_if (memcmp (value + 1, &service_num, 1) != 0,
+ "fail: wrong number of services" );
+ fail_if (memcmp (value + 2, &index1, 1) != 0,
+ "fail: wrong service index1" );
+ fail_if (memcmp (value + 3, &cl_rule1, 1) != 0,
+ "fail: wrong cl_rule1 (service type)" );
+ fail_if (memcmp (value + 4, cl_value1, 2) != 0,
+ "fail: wrong cl_value1 (matching value)" );
+ fail_if (memcmp (value + 6, &acs_en1, 1) != 0,
+ "fail: wrong acs_en1" );
+ fail_if (memcmp (value + 7, &param_nb1, 1) != 0,
+ "fail: wrong number of parameters (param_nb1)" );
+ fail_if (memcmp (value + 8, param_value1, 2) != 0,
+ "fail: wrong parameter value1 (latency)" );
+ fail_if (memcmp (value + 10, param_value2, 2) != 0,
+ "fail: wrong parameter value2 (jitter)" );
+ fail_if (memcmp (value + 12, param_value3, 2) != 0,
+ "fail: wrong parameter value3 (down PIR)" );
+ fail_if (memcmp (value + 14, param_value4, 2) != 0,
+ "fail: wrong parameter value4 (up PIR)" );
+ fail_if (memcmp (value + 16, param_value5, 2) != 0,
+ "fail: wrong parameter value5 (down CIR)" );
+ fail_if (memcmp (value + 18, param_value6, 2) != 0,
+ "fail: wrong parameter value6 (up CIR)" );
+ fail_if (memcmp (value + 20, param_value7, 2) != 0,
+ "fail: wrong parameter value7 (QOS prio)" );
+
+ return 0;
+}