d65930c5a9
We currently read the input to test-delta by mmap()-ing it. However, memory-checking tools like valgrind and ASan are less able to detect reads/writes past the end of an mmap'd buffer, because the OS is likely to give us extra bytes to pad out the final page size. So instead, let's read into a heap buffer. As a bonus, this also makes it possible to write tests with empty bases, as mmap() will complain about a zero-length map. This is based on a patch by Jann Horn <jannh@google.com> which actually aligned the data at the end of a page, and followed it with another page marked with mprotect(). That would detect problems even without a tool like ASan, but it was significantly more complex and may have introduced portability problems. By comparison, this approach pushes the complexity onto existing memory-checking tools. Note that this could be done even more simply by using strbuf_read_file(), but that would defeat the purpose: strbufs generally overallocate (and at the very least include a trailing NUL which we do not care about), which would defeat most memory checkers. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Junio C Hamano <gitster@pobox.com> |
||
---|---|---|
.. | ||
.gitignore | ||
test-chmtime.c | ||
test-config.c | ||
test-ctype.c | ||
test-date.c | ||
test-delta.c | ||
test-drop-caches.c | ||
test-dump-cache-tree.c | ||
test-dump-fsmonitor.c | ||
test-dump-split-index.c | ||
test-dump-untracked-cache.c | ||
test-example-decorate.c | ||
test-fake-ssh.c | ||
test-genrandom.c | ||
test-hashmap.c | ||
test-index-version.c | ||
test-json-writer.c | ||
test-lazy-init-name-hash.c | ||
test-line-buffer.c | ||
test-match-trees.c | ||
test-mergesort.c | ||
test-mktemp.c | ||
test-online-cpus.c | ||
test-parse-options.c | ||
test-path-utils.c | ||
test-pkt-line.c | ||
test-prio-queue.c | ||
test-read-cache.c | ||
test-ref-store.c | ||
test-regex.c | ||
test-repository.c | ||
test-revision-walking.c | ||
test-run-command.c | ||
test-scrap-cache-tree.c | ||
test-sha1-array.c | ||
test-sha1.c | ||
test-sha1.sh | ||
test-sigchain.c | ||
test-strcmp-offset.c | ||
test-string-list.c | ||
test-submodule-config.c | ||
test-subprocess.c | ||
test-svn-fe.c | ||
test-tool.c | ||
test-tool.h | ||
test-urlmatch-normalization.c | ||
test-wildmatch.c | ||
test-write-cache.c |