[Top][All Lists]

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

Re: How to compile hashlib.c for testing?

From: Pierre Gaston
Subject: Re: How to compile hashlib.c for testing?
Date: Fri, 28 Dec 2018 09:06:32 +0200

On Fri, Dec 28, 2018 at 4:28 AM Peng Yu <address@hidden> wrote:

> We are talking about unit testing in the bash C source code, not bash
> scripts.

While toying with the loadable builtins I came up with this:


you need to set BASH_PATH  so that it points the bash sources
(eg make "BASH_PATH=/path/to/sources" after running ./configure)
and I use it as part my build so it probably needs some work to be truly
usable, but maybe you can adapt it
(or add something like it directly in the Makefile of bash and run make

I basically compile a .a instead of the bash executable which ensure I
pretty much have everything that's needed.
The problem is that this "library" contains a "main".

So as a workaround I use "-Wl,--wrap=main" when linking and a  "int
__wrap_main(void) ()" instead of main in my test programs.
(basically what is used by cmocka to mock C functions

I'm aware that it may raise more questions and difficulties for you than
actually solving anything but it is my 2 cents.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]