Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14988 > unrolled thread

Re: How to compile hashlib.c for testing?

Started byPierre Gaston <pierre.gaston@gmail.com>
First post2018-12-28 09:06 +0200
Last post2018-12-28 09:06 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to compile hashlib.c for testing? Pierre Gaston <pierre.gaston@gmail.com> - 2018-12-28 09:06 +0200

#14988 — Re: How to compile hashlib.c for testing?

FromPierre Gaston <pierre.gaston@gmail.com>
Date2018-12-28 09:06 +0200
SubjectRe: How to compile hashlib.c for testing?
Message-ID<mailman.6449.1545981987.1284.bug-bash@gnu.org>
On Fri, Dec 28, 2018 at 4:28 AM Peng Yu <pengyu.ut@gmail.com> 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:

https://github.com/pgas/newt_builtin/blob/master/make.libbash

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
libbash.a)

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
https://lwn.net/Articles/558106/)

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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web