On Wed, May 02, 2018 at 01:29:33PM +0200, Jan Kiszka wrote:
> On 2018-04-27 14:44, 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 | 53 ++++++++++++++++++++++++++++++++++-
> >  1 file changed, 52 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/tests/test_ebgenv_api.c b/tools/tests/test_ebgenv_api.c
> > index 533b50b..d99dc91 100644
> > --- a/tools/tests/test_ebgenv_api.c
> > +++ b/tools/tests/test_ebgenv_api.c
> > @@ -615,6 +615,56 @@ START_TEST(ebgenv_api_ebg_env_close)
> >  }
> >  END_TEST
> >  
> > +START_TEST(ebgenv_api_ebg_env_gc_register_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);
> > +
> > +   /* 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_gc_register_var(&e, "VarA");
> > +   ebg_env_gc_register_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);
> 
> BTW, shouldn't we rather return -ENOENT if nothing is found?

Good idea so then please wait for patch v4... I was too fast with v3.

> 
> > +   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 +682,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_gc_register_var
> >     };
> >  
> >     tc_core = tcase_create("Core");
> > 
> 
> Test itself is fine.
> 
> Jan
> 
> -- 
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> Corporate Competence Center Embedded Linux

-- 
Andreas Reichel
Dipl.-Phys. (Univ.)
Software Consultant

[email protected], +49-174-3180074
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterfoehring
Geschaeftsfuehrer: Henrik Klagges, Dr. Robert Dahlke, Gerhard Mueller
Sitz: Unterfoehring * Amtsgericht Muenchen * HRB 135082

-- 
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/20180502114448.GB14318%40iiotirae.
For more options, visit https://groups.google.com/d/optout.

Reply via email to