diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2015-05-20 14:27:38 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2015-05-21 09:16:18 -0400 |
commit | f68c2b259298177763c285d8e4b2394d8b2833c3 (patch) | |
tree | fc35a6a8a14391b8519643d2646d2436fefcdc72 /test | |
parent | b04d3553ee389ea8abf13e52930ddde5943ed8a4 (diff) | |
download | u-boot-imx-f68c2b259298177763c285d8e4b2394d8b2833c3.zip u-boot-imx-f68c2b259298177763c285d8e4b2394d8b2833c3.tar.gz u-boot-imx-f68c2b259298177763c285d8e4b2394d8b2833c3.tar.bz2 |
test: env: Add a test of the new regex behavior for attrs
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>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/env/attr.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/env/attr.c b/test/env/attr.c index d9be825..45b8c75 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 |