diff options
Diffstat (limited to 'tests/ctrl')
-rw-r--r-- | tests/ctrl/ctrl_test.c | 36 | ||||
-rw-r--r-- | tests/ctrl/ctrl_test.ok | 9 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c new file mode 100644 index 00000000..3bbab76a --- /dev/null +++ b/tests/ctrl/ctrl_test.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <stdbool.h> + +#include <osmocom/core/utils.h> +#include <osmocom/ctrl/control_cmd.h> + +inline void check_type(enum ctrl_type c) +{ + const char *t = get_value_string(ctrl_type_vals, c); + int v = get_string_value(ctrl_type_vals, t); + + printf("ctrl type %d is %s ", c, t); + if (v < 0) + printf("[PARSE FAILED]\n"); + else + printf("-> %d %s\n", v, c != v ? "FAIL" : "OK"); +} + +int main(int argc, char **argv) +{ + printf("Checking ctrl types...\n"); + + check_type(CTRL_TYPE_UNKNOWN); + check_type(CTRL_TYPE_GET); + check_type(CTRL_TYPE_SET); + check_type(CTRL_TYPE_GET_REPLY); + check_type(CTRL_TYPE_SET_REPLY); + check_type(CTRL_TYPE_TRAP); + check_type(CTRL_TYPE_ERROR); + check_type(64); + + return 0; +} diff --git a/tests/ctrl/ctrl_test.ok b/tests/ctrl/ctrl_test.ok new file mode 100644 index 00000000..c4b05e9a --- /dev/null +++ b/tests/ctrl/ctrl_test.ok @@ -0,0 +1,9 @@ +Checking ctrl types... +ctrl type 0 is unknown 0x0 [PARSE FAILED] +ctrl type 1 is GET -> 1 OK +ctrl type 2 is SET -> 2 OK +ctrl type 3 is GET_REPLY -> 3 OK +ctrl type 4 is SET_REPLY -> 4 OK +ctrl type 5 is TRAP -> 5 OK +ctrl type 6 is ERROR -> 6 OK +ctrl type 64 is unknown 0x40 [PARSE FAILED] |