Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Pierre Gaston Newsgroups: gnu.bash.bug Subject: Re: How to compile hashlib.c for testing? Date: Fri, 28 Dec 2018 09:06:32 +0200 Lines: 29 Approved: bug-bash@gnu.org Message-ID: References: <31ae9367-7968-aff5-d0e8-0f9da667d584@case.edu> <20181228014136.emrgypsauyzdcmgz@crack.deadbeast.net> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1545981987 24323 208.118.235.17 (28 Dec 2018 07:26:27 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: Peng Yu Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G1U8fq/7FXv39dS1lEAgkzcCMiu+6EjVs4GABA8Ij6E=; b=sL4wABJCiPFqDT1Az3iei3wAis5NIAm+Oy4/RipA9iGiFwr9fJaj+nIsAnGjyy7qQW 6zGv1PI//TkgGcyyaERcf4hbb3cP4rpesyfqQuabx8IBDxwSI9cStt+Dp2QFTp3GD5Sp 5+9gOtiaNWV/Zki+AU6WbU1xGOJXbefDQ8MND2MeuDE6XoMmkIgqRD7wFv82iizqpoim qAR3Ut94aRBXdDAze6gqvOnqb8LQXVw1MPEPyZMRbXvKJgImezEKetFjBcucNpRoZzQK /nDh5vsyHIDBXmDqQL9LhB05djofnN4J9x02ETzu3CVJKd0yp4d1okkzeznpt1knzhGr yEIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G1U8fq/7FXv39dS1lEAgkzcCMiu+6EjVs4GABA8Ij6E=; b=DUK2NNTLENSHpm2TiccvE3qssPTPisNNd85YUSowLdLdK0OFQRMKZVMiD0WAoM6Ljq 369Gu8oW7qC4TuWs6d0QL9YLe2dih3EIqCxbXo79rWSNq7fHij2cZivsJR5LL0Z2uq83 JEPKOlKP+eR0DH4iho/HJ388Tn5+S+O2tuFyAdxkNwcd8Qg3M9yUWRFVEbOR3kCLTd1D i5ZBM8JMn/iahBBGFLA0P0UWa8ZaxNVT4kluF2hW5WIim5ZSjhjeKR7cj0ObIELi0UcF MY9+YvXW17suE1+OgOpDs3DFIKd2FpAu8TMhrmfrY/zMHPPFm/IMXxaTjbTpxXg+Q1wW H5PA== X-Gm-Message-State: AJcUuke6uHapQaOpmvT23D6jusNnLQQOO5MfrddYxGf0oMnfff0toh8X rtOXEELq2AYsGQwAkVb47lYYvvlBXp5y/ARnalw= X-Google-Smtp-Source: ALg8bN6Wg98Ydo0pZEELmdaER2O67ulJZ5VVJ2Sq6gsrLfe47jWYM73aDTE2/kOZhKp0JJXmZ7QNfo8eMI3buo2tip8= X-Received: by 2002:a0c:ace4:: with SMTP id n33mr25297686qvc.79.1545980803831; Thu, 27 Dec 2018 23:06:43 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::834 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14988 On Fri, Dec 28, 2018 at 4:28 AM Peng Yu 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