diff mbox

[U-Boot,v2,17/19] test: env: Add a test of the new regex behavior for attrs

Message ID 1430286666-392-18-git-send-email-joe.hershberger@ni.com
State Superseded
Headers show

Commit Message

Joe Hershberger April 29, 2015, 5:51 a.m. UTC
The behavior of the env attrs depends on CONFIG_REGEX. Add an additional
test if that variable is set.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---

Changes in v2:
-New for version 2

 test/env/attr.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Simon Glass May 1, 2015, 3:46 a.m. UTC | #1
On 28 April 2015 at 23:51, Joe Hershberger <joe.hershberger@ni.com> wrote:
> The behavior of the env attrs depends on CONFIG_REGEX. Add an additional
> test if that variable is set.
>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> ---
>
> Changes in v2:
> -New for version 2
>
>  test/env/attr.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/test/env/attr.c b/test/env/attr.c
index 87ebdac..19e066e 100644
--- a/test/env/attr.c
+++ b/test/env/attr.c
@@ -60,3 +60,30 @@  static int env_test_attrs_lookup(struct unit_test_state *uts)
 	return 0;
 }
 ENV_TEST(env_test_attrs_lookup, 0);
+
+#ifdef CONFIG_REGEX
+static int env_test_attrs_lookup_regex(struct unit_test_state *uts)
+{
+	char attrs[32];
+
+	ut_assertok(env_attr_lookup("foo1?:bar", "foo", attrs));
+	ut_asserteq_str("bar", attrs);
+
+	ut_assertok(env_attr_lookup("foo1?:bar", "foo1", attrs));
+	ut_asserteq_str("bar", attrs);
+
+	ut_assertok(env_attr_lookup(".foo:bar", ".foo", attrs));
+	ut_asserteq_str("bar", attrs);
+
+	ut_assertok(env_attr_lookup(".foo:bar", "ufoo", attrs));
+	ut_asserteq_str("bar", attrs);
+
+	ut_assertok(env_attr_lookup("\\.foo:bar", ".foo", attrs));
+	ut_asserteq_str("bar", attrs);
+
+	ut_asserteq(-ENOENT, env_attr_lookup("\\.foo:bar", "ufoo", attrs));
+
+	return 0;
+}
+ENV_TEST(env_test_attrs_lookup_regex, 0);
+#endif