On Fri, Dec 28, 2018 at 4:28 AM Peng Yu <pengyu...@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