libgit2/tests
Patrick Steinhardt cf07db2f1b filter: only close filter if it's been initialized correctly
In the function `git_filter_list_stream_data`, we initialize, write and
subesquently close the stream which should receive content processed by
the filter. While we skip writing to the stream if its initialization
failed, we still try to close it unconditionally -- even if the
initialization failed, where the stream might not be set at all, leading
us to segfault.

Semantics in this code is not really clear. The function handling the
same logic for files instead of data seems to do the right thing here in
only closing the stream when initialization succeeded. When stepping
back a bit, this is only reasonable: if a stream cannot be initialized,
the caller would not expect it to be closed again. So actually, both
callers of `stream_list_init` fail to do so. The data streaming function
will always close the stream and the file streaming function will not
close the stream if writing to it has failed.

The fix is thus two-fold:

- callers of `stream_list_init` now close the stream iff it has been
  initialized
- `stream_list_init` now closes the lastly initialized stream if
  the current stream in the chain failed to initialize

Add a test which segfaulted previous to these changes.
2017-04-07 16:34:47 +02:00
..
apply git_patch_parse_ctx: refcount the context 2016-05-26 13:01:08 -05:00
attr cl_git_exec -> cl_git_expect 2017-02-17 13:01:49 +00:00
blame blame: use size_t for line counts in git_blame_hunk 2015-12-01 09:02:47 +01:00
buf git_buf_quote/unquote: handle > \177 2016-05-26 13:01:07 -05:00
checkout checkout::tree test: cleanup memory leak 2017-01-23 17:32:13 -06:00
cherrypick merge: rename git_merge_tree_flags_t -> git_merge_flags_t 2015-11-25 15:37:05 -05:00
clar clar: test chdir 2015-06-29 22:13:40 +00:00
clone clone::nonetwork: don't use fixed size buffer 2015-09-14 13:58:38 -04:00
commit Fix initial commit test 2016-05-04 11:15:56 -07:00
config leaks: fix some leaks in the tests 2016-03-31 10:41:33 -04:00
core inet_pton: don't assume addr families don't exist 2017-03-22 19:52:38 +00:00
date Added RFC2822 date format test cases 2014-04-11 21:55:36 +02:00
describe describe: only abort without tags if fallback is not allowed. 2015-04-07 17:32:56 +02:00
diff diff_parse: correctly set options for parsed diffs 2017-03-14 13:09:35 +01:00
fetchhead tests: update error message checking 2016-12-29 12:55:49 +00:00
filter filter: only close filter if it's been initialized correctly 2017-04-07 16:34:47 +02:00
graph Added a no path test for git_graph_descendant_of 2014-04-08 16:32:06 +02:00
index tests: index: do not re-allocate index 2016-08-29 13:29:01 +02:00
iterator tests: add merge-conflict branch for testrepo 2017-02-13 10:13:02 +01:00
merge merge_trees: introduce test for submodule renames 2017-02-09 18:13:06 +00:00
network Remove unused static functions 2016-06-21 07:58:33 +02:00
notes note: use a git_buf to return the default namespace 2015-03-17 20:50:02 +01:00
object tree: add a failing test for unsorted input 2016-11-14 12:22:20 +01:00
odb Merge pull request #4030 from libgit2/ethomson/fsync 2017-03-22 20:29:22 +00:00
online https: don't test that RC4 is invalid 2017-01-09 18:32:11 +00:00
pack Honor core.fsyncObjectFiles 2017-03-02 09:11:33 +00:00
patch diff: treat binary patches with no data special 2016-09-05 12:26:47 -05:00
path index: allow read of index w/ illegal entries 2016-02-17 13:10:33 +00:00
perf repository: remove log message override for switching the active branch 2015-03-03 14:40:50 +01:00
rebase rebase: ignore untracked files in submodules 2017-03-03 15:07:54 -05:00
refs Merge pull request #4030 from libgit2/ethomson/fsync 2017-03-22 20:29:22 +00:00
remote remote: test insteadOf for anonymous remotes 2015-05-31 13:26:05 +02:00
repo cl_git_exec -> cl_git_expect 2017-02-17 13:01:49 +00:00
reset odb: actually insert the empty blob in tests 2016-08-05 20:34:19 -04:00
resources submodule: resolve URLs relative to main worktree 2017-03-17 09:27:56 +01:00
revert merge: rename git_merge_tree_flags_t -> git_merge_flags_t 2015-11-25 15:37:05 -05:00
revwalk Skip uninteresting commits in revwalk timesort iterator 2017-03-09 14:01:10 +01:00
stash stash: const up conflict params 2015-06-29 21:23:09 +00:00
status cl_git_exec -> cl_git_expect 2017-02-17 13:01:49 +00:00
stress diff: introduce binary diff callbacks 2015-06-12 09:39:20 -04:00
submodule tests: provide better pass/failure error messages 2017-02-17 12:58:57 +00:00
threads refdb: disable concurrent compress in the threading tests on Windows 2016-12-12 17:09:12 +00:00
trace Include stacktrace summary in memory leak output. 2015-06-29 16:39:11 -04:00
transport tests: transport: fix memory leaks with registering transports 2016-03-11 11:06:42 +01:00
win32 Merge pull request #3613 from ethomson/fixups 2016-02-18 12:31:56 +01:00
worktree submodule: resolve URLs relative to main worktree 2017-03-17 09:27:56 +01:00
clar_libgit2_timer.c Converted cl_perf_timer to use git__timer internally. 2015-03-03 09:57:50 -05:00
clar_libgit2_timer.h Converted cl_perf_timer to use git__timer internally. 2015-03-03 09:57:50 -05:00
clar_libgit2_trace.c Include stacktrace summary in memory leak output. 2015-06-29 16:39:11 -04:00
clar_libgit2_trace.h Provide mechanism to let CLAR globally setup git_trace() 2015-03-02 08:20:27 -05:00
clar_libgit2.c tests: provide better pass/failure error messages 2017-02-17 12:58:57 +00:00
clar_libgit2.h cl_git_exec -> cl_git_expect 2017-02-17 13:01:49 +00:00
clar.c clar: fix parsing of test suite prefixes 2016-08-04 11:49:39 +02:00
clar.h Update to clar 2b73f5e 2015-02-27 00:30:50 -05:00
generate_crlf.sh crlf: script to generate expected crlf data 2015-06-22 11:59:58 -04:00
generate.py Update clar to e3985dd 2014-12-07 22:09:00 +08:00
main.c Include stacktrace summary in memory leak output. 2015-06-29 16:39:11 -04:00
README.md Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
valgrind-supp-mac.txt Test cancel from indexer progress callback 2013-12-11 15:02:20 -08:00

Writing Clar tests for libgit2

For information on the Clar testing framework and a detailed introduction please visit:

https://github.com/vmg/clar

  • Write your modules and tests. Use good, meaningful names.

  • Make sure you actually build the tests by setting:

      cmake -DBUILD_CLAR=ON build/
    
  • Test:

      ./build/libgit2_clar
    
  • Make sure everything is fine.

  • Send your pull request. That's it.