Re: Re: [PATCH] kunit/kunit_kernel: Rebuild .config if .kunitconfig is modified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 27 Jan 2020 16:02:48 -0800 Brendan Higgins <brendanhiggins@xxxxxxxxxx> wrote:

> On Sat, Jan 25, 2020 at 5:59 PM <sj38.park@xxxxxxxxx> wrote:
> >
> > From: SeongJae Park <sjpark@xxxxxxxxx>
> >
> > Deletions of configs in the '.kunitconfig' is not applied because kunit
> > rebuilds '.config' only if the '.config' is not a subset of the
> > '.kunitconfig'.  To allow the deletions to applied, this commit modifies
> > the '.config' rebuild condition to addtionally check the modified times
> > of those files.
> 
> The reason it only checks that .kunitconfig is a subset of .config is
> because we don't want the .kunitconfig to remove options just because
> it doesn't recognize them.
> 
> It runs `make ARCH=um olddefconfig` on the .config that it generates
> from the .kunitconfig, and most of the time that means you will get a
> .config with lots of things in it that aren't in the .kunitconfig.
> Consequently, nothing should ever be deleted from the .config just
> because it was deleted in the .kunitconfig (unless, of course, you
> change a =y to a =n or # ... is not set), so I don't see what this
> change would do.
> 
> Can you maybe provide an example?

Sorry for my insufficient explanation.  I added a kunit test
(SYSCTL_KUNIT_TEST) to '.kunitconfig', ran the added test, and then removed it
from the file.  However, '.config' is not generated again due to the condition
and therefore the test still runs.

For more detail:

    $ ./tools/testing/kunit/kunit.py run --defconfig --build_dir ../kunit.out/
    $ echo "CONFIG_SYSCTL_KUNIT_TEST=y" >> ../kunit.out/.kunitconfig
    $ ./tools/testing/kunit/kunit.py run --build_dir ../kunit.out/
    $ sed -i '4d' ../kunit.out/.kunitconfig
    $ ./tools/testing/kunit/kunit.py run --build_dir ../kunit.out/

The 2nd line command adds sysctl kunit test and the 3rd line shows it runs the
added test as expected.  Because the default kunit config contains only 3
lines, The 4th line command removes the sysctl kunit test from the
.kunitconfig.  However, the 5th line still run the test.

This patch is for such cases.  Of course, this might make more false positives
but I believe it would not be a big problem because .config generation takes no
long time.  If I missed something, please let me know.


Thanks,
SeongJae Park

> 
> > Signed-off-by: SeongJae Park <sjpark@xxxxxxxxx>
> > ---
> >  tools/testing/kunit/kunit_kernel.py | 17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
> > index cc5d844ecca1..a3a5d6c7e66d 100644
> > --- a/tools/testing/kunit/kunit_kernel.py
> > +++ b/tools/testing/kunit/kunit_kernel.py
> > @@ -111,17 +111,22 @@ class LinuxSourceTree(object):
> >                 return True
> >
> >         def build_reconfig(self, build_dir):
> > -               """Creates a new .config if it is not a subset of the .kunitconfig."""
> > +               """Creates a new .config if it is not a subset of, or older than the .kunitconfig."""
> >                 kconfig_path = get_kconfig_path(build_dir)
> >                 if os.path.exists(kconfig_path):
> >                         existing_kconfig = kunit_config.Kconfig()
> >                         existing_kconfig.read_from_file(kconfig_path)
> > -                       if not self._kconfig.is_subset_of(existing_kconfig):
> > -                               print('Regenerating .config ...')
> > -                               os.remove(kconfig_path)
> > -                               return self.build_config(build_dir)
> > -                       else:
> > +                       subset = self._kconfig.is_subset_of(existing_kconfig)
> > +
> > +                       kunitconfig_mtime = os.path.getmtime(kunitconfig_path)
> > +                       kconfig_mtime = os.path.getmtime(kconfig_path)
> > +                       older = kconfig_mtime < kunitconfig_mtime
> > +
> > +                       if subset and not older:
> >                                 return True
> > +                       print('Regenerating .config ...')
> > +                       os.remove(kconfig_path)
> > +                       return self.build_config(build_dir)
> >                 else:
> >                         print('Generating .config ...')
> >                         return self.build_config(build_dir)
> > --
> > 2.17.1
> >



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux