On 2018-05-02 14:39, Andreas J. Reichel wrote:
> From: Andreas Reichel <[email protected]>
>
> Register three user variables, add two of them to the registry
> of the garbage collector and call finalize to check if the third
> remains and the registered ones are deleted.
>
> Signed-off-by: Andreas Reichel <[email protected]>
> ---
> tools/tests/test_ebgenv_api.c | 52 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/tools/tests/test_ebgenv_api.c b/tools/tests/test_ebgenv_api.c
> index 533b50b..fb6ca44 100644
> --- a/tools/tests/test_ebgenv_api.c
> +++ b/tools/tests/test_ebgenv_api.c
> @@ -615,6 +615,55 @@ START_TEST(ebgenv_api_ebg_env_close)
> }
> END_TEST
>
> +START_TEST(ebgenv_api_ebg_env_register_gc_var)
> +{
> + ebgenv_t e;
> + int ret;
> + memset(&e, 0, sizeof(e));
> +
> + bgenv_write_fake.return_val = true;
> + bgenv_close_fake.return_val = true;
> +
> + bgenv_init_fake.return_val = true;
> +
> + for (int i = 0; i < ENV_NUM_CONFIG_PARTS; i++) {
> + envdata[i].revision = i + 1;
> + }
> +
> + ret = ebg_env_create_new(&e);
Missing "ck_assert_int_eq(ret, 0);" here, right? Then I will just fix up
the patch.
Jan
> +
> + /* Create three user variables VarA, VarB and VarC */
> + ebg_env_set(&e, "VarA", "TestA");
> + ebg_env_set(&e, "VarB", "TestB");
> + ebg_env_set(&e, "VarC", "TestC");
> +
> + /* Check if variables exist */
> + int res;
> + res = ebg_env_get(&e, "VarA", NULL);
> + ck_assert_int_eq(res, strlen("TestA") + 1);
> + res = ebg_env_get(&e, "VarB", NULL);
> + ck_assert_int_eq(res, strlen("TestB") + 1);
> + res = ebg_env_get(&e, "VarC", NULL);
> + ck_assert_int_eq(res, strlen("TestC") + 1);
> +
> + /* Register variables for deletion */
> + ebg_env_register_gc_var(&e, "VarA");
> + ebg_env_register_gc_var(&e, "VarC");
> +
> + ebg_env_finalize_update(&e);
> +
> + /* Check if variables are deleted */
> + res = ebg_env_get(&e, "VarA", NULL);
> + ck_assert_int_eq(res, -EINVAL);
> + res = ebg_env_get(&e, "VarB", NULL);
> + ck_assert_int_eq(res, strlen("TestB") + 1);
> + res = ebg_env_get(&e, "VarC", NULL);
> + ck_assert_int_eq(res, -EINVAL);
> +
> + ebg_env_close(&e);
> +}
> +END_TEST
> +
> Suite *ebg_test_suite(void)
> {
> Suite *s;
> @@ -632,7 +681,8 @@ Suite *ebg_test_suite(void)
> ebgenv_api_ebg_env_user_free,
> ebgenv_api_ebg_env_getglobalstate,
> ebgenv_api_ebg_env_setglobalstate,
> - ebgenv_api_ebg_env_close
> + ebgenv_api_ebg_env_close,
> + ebgenv_api_ebg_env_register_gc_var
> };
>
> tc_core = tcase_create("Core");
>
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
--
You received this message because you are subscribed to the Google Groups "EFI
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/efibootguard-dev/d4eeee8b-0385-9c12-222b-135c6cada706%40siemens.com.
For more options, visit https://groups.google.com/d/optout.