Re: [PATCH] selftests/nolibc: only run constructor tests on nolibc

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

 



Hi Thomas,

On Mon, Feb 17, 2025 at 10:24:11PM +0100, Thomas Weißschuh wrote:
> On 2025-02-16 10:39:40+0100, Willy Tarreau wrote:
> > On Wed, Feb 12, 2025 at 07:01:01PM +0100, Thomas Weißschuh wrote:
> > > The nolibc testsuite can be run against other libcs to test for
> > > interoperability. Some aspects of the constructor execution are not
> > > standardized and musl does not provide all tested feature, for one it
> > > does not provide arguments to the constructors, anymore?
> > >
> > > Skip the constructor tests on non-nolibc configurations.
> > 
> > I'm not much surprised, I've always avoided arguments in my use of
> > constructors due to a lack of portability. However the patch disables
> > all constructors tests, while I'm seeing that the linkage_test version
> > does not make use of arguments, though there is an implied expectation
> > that they're executed in declaration order, which is not granted.
> 
> The tests are written specifically to test for execution order.
> While we can not rely on the order for other libcs, the idea was to
> expect a given order for the nolibc implementation.

OK.

> > I'm wondering if we shouldn't make the tests more robust:
> >   1) explicitly set linkage_test_constructor_test_value to zero in the
> >      declaration, because here it's not set so we have no guarantee
> >      (we're not in the kernel)
> 
> Ack.
> 
> >   2) only add values to check for cumulated values (e.g. |1 in const1,
> >      |2 in const2) and verify that the result is properly 3
> 
> This would stop validating the order.

That was my purpose but OK I got it. Then there's another option which
preserves the order and even gives history:

  __attribute__((constructor))
  static void constructor1(void)
  {
      constructor_test_value = constructor_test_value * 0x10 + 1;
  }

  __attribute__((constructor))
  static void constructor2(void)
  {
      constructor_test_value = constructor_test_value * 0x10 + 2;
  }
 
Then if executed in the right order, you'll find 0x12. If both
are executed in any order, it will always be >= 0x10. If only one
is executed, it will be < 0x10, and if none is executed, it's 0.

Willy




[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