[LLVMdev] hexdump in test cases?

Rui Ueyama ruiu at google.com
Thu Oct 2 18:52:06 PDT 2014

On Thu, Oct 2, 2014 at 6:27 PM, Nick Kledzik <kledzik at apple.com> wrote:

> For lld to mimic the darwin linker it needs to support an option that
> dumps a binary file which contains a list of the input and output files.
> This file is used by Xcode to dynamically update its dependency graph.
> I’m a bit stumped on how to test this. Some ideas I have:
> * Use REQUIRES: shell, then run hexdump and FileCheck that (is hexdump
> output consistent on all *nix platforms?)

I doubt that hexdump output is consistent across all Unix systems.

> * Use REQUIRES: shell, then run sed or perl to format the file with lines
> and opcode values and FileCheck that (is sed/perl on all platforms?)
> * Since lit uses Python, it seems like I should be able to use python to
> transform the file into something FileCheck can process.  But I don’t know
> how to invoke python from a RUN: line in a cross platform way.

I don't see any reason to use Perl, because it may not be available on some
platforms, and Perl and Python are mostly functionally equivalent.

I'd do with Python. I'd write a binary-to-text converter as a Python
script, put it into test/ directory, and then let lit to run the script by
appending a magic comment to the script like this:

  # RUN: lld -flavor darwin -output %t.binary ...
  # python %s %t.binary | FileCheck %s
  # CHECK: <expected text output here>

* Add a C tool to llvm that dumps out a dependency file in a human and
> FileCheck readable way.  Seems like overkill to add a directory to
> llvm/tools/ that contains a tool only useful for dumping a Xcode file.
> Comparing the file bytes is all I really need.
> * Write an llvm-hexdump tool in llvm/tools/ and use that in my test case.
> Thoughts?
> -Nick
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141002/c2b1c26a/attachment.html>

More information about the llvm-dev mailing list