diff --git a/src/hal/hal_lib.c b/src/hal/hal_lib.c index 32e607c0c63..a113454c53c 100644 --- a/src/hal/hal_lib.c +++ b/src/hal/hal_lib.c @@ -3984,7 +3984,7 @@ int hal_stream_create(hal_stream_t *stream, int comp, int key, int depth, const int result = 0; hal_type_t type[HAL_STREAM_MAX_PINS]; result = halpr_parse_types(type, typestring); - if(result < 0) return result; + if(!result) return -EINVAL; int pin_count = result; size_t size = sizeof(struct hal_stream_shm) + sizeof(union hal_stream_data) * depth * (1+pin_count); diff --git a/tests/hal-stream/README b/tests/hal-stream/README new file mode 100644 index 00000000000..8798555629b --- /dev/null +++ b/tests/hal-stream/README @@ -0,0 +1 @@ +Creating a hal stream should fail if the cfg string is invalid. diff --git a/tests/hal-stream/expected b/tests/hal-stream/expected new file mode 100644 index 00000000000..2ae28399f5f --- /dev/null +++ b/tests/hal-stream/expected @@ -0,0 +1 @@ +pass diff --git a/tests/hal-stream/test.hal b/tests/hal-stream/test.hal new file mode 100644 index 00000000000..a0055ff2cdd --- /dev/null +++ b/tests/hal-stream/test.hal @@ -0,0 +1 @@ +loadusr -w ./test.py diff --git a/tests/hal-stream/test.py b/tests/hal-stream/test.py new file mode 100755 index 00000000000..e96f0f10fa8 --- /dev/null +++ b/tests/hal-stream/test.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import hal + +c = hal.component("stream_test") +try: + writer = hal.stream(c, hal.streamer_base, 10, "xx") +except: + pass +else: + assert False, "hal.stream should fail with invalid cfg arg" + +c.ready() +print("pass")