syzkaller/pkg
Marco Vanotti 37a6ea34f1 pkg/compiler: add error handler in CollectUnused
* pkg/compiler: Add error handler in `CollectUnused`.

This commit adds an error handler for the `CollectUnused` function. The
error handler just panics on any error, but is useful for debugging.

The error handler is used any time `comp` finds an error, and if it's
missing, it will panic due to a `nil` pointer dereference. At least now
we get a better understanding of the errors.

The only user of `CollectUnused` is `sys/fuchsia/fidlgen`, which is
failing now and will be fixed in a future commit.

The output message looks like this:
```
panic: could not collect unused nodes. fidl_net-stack.txt:110:15:
unknown type zx_chan_zircon_ethernet_Device_client
```

* pkg/compiler Better error handling in CollectUnused

This commit changes the default error handler for compiler to
`ast.LoggingHandler`, meaning that if `nil` is passed as an error
handler, `LoggingHandler` will be used instead.

`CollectUnused` now returns an error if any of the subfunctions produce errors.

`fidlgen` is the only caller of `CollectUnused`, and now checks for errors
as well.

* pkg/compiler Add tests for CollectUnused

This commit adds basic tests for the CollectUnused function. There's one
test that checks that it returns the right nodes, and another one that
makes sure that it returns errors when needed.

To make the test clearer, I had to add the error handler as an explicit
parameter in `CollectUnunsed`, instead of using the default one. This
avoid printing garbage in the logs. The `TestCollectUnusedError` function
uses a nopErrorHandler to avoid printing anything.

* pkg/compiler fix presubmit warnings
2018-11-21 02:37:06 +01:00
..
ast sys/fuchsia: prune unused structs in syscall description generated by fidlgen 2018-09-11 13:01:53 +02:00
bisect pkg/mgrconfig: move from syz-manager/mgrconfig 2018-08-02 16:57:32 +02:00
build [fuchsia] SSH fix and build invocation fix. 2018-11-16 11:58:29 -08:00
compiler pkg/compiler: add error handler in CollectUnused 2018-11-21 02:37:06 +01:00
config .gometalinter.json: enable gofmt 2018-07-31 12:16:54 +02:00
cover all: fix gometalinter warnings 2018-03-08 18:48:26 +01:00
csource executor: OpenBSD network package injection 2018-11-17 15:42:37 -08:00
db gometalinter: clean up some errcheck warnings 2018-08-02 16:57:31 +02:00
email pkg/email, pkg/vcs: test that OpenBSD-style commits are handled 2018-10-11 19:47:32 +02:00
gce .gometalinter.json: enable gofmt 2018-07-31 12:16:54 +02:00
gcs syz-ci: upload coverage reports to GCS 2018-09-20 18:29:38 +02:00
hash pkg/hash: allow to hash multiple byte slices 2017-07-21 10:06:46 +02:00
host openbsd: enable packet injection 2018-11-19 20:29:38 -08:00
ifuzz gometalinter: clean up vetshadow 2018-07-31 20:38:33 +02:00
instance syz-ci: use gmake instead of make on openbsd 2018-09-13 12:13:54 +02:00
ipc all: fix code formatting 2018-10-16 13:57:24 +02:00
kd pkg/kd: add KD protocol decoder 2017-09-28 16:53:58 +02:00
log gometalinter: enable package comment checking 2018-05-03 13:53:01 +02:00
mgrconfig RFC: android: Add support for untrusted_app sandboxing (#697) 2018-09-17 11:33:11 +02:00
osutil pkg/runtest: fixes for fuchsia 2018-09-06 10:56:09 +02:00
report pkg/report: do not interpret reorder_kernel lines as a crash on OpenBSD 2018-11-12 12:34:06 -08:00
repro pkg/mgrconfig: move from syz-manager/mgrconfig 2018-08-02 16:57:32 +02:00
rpctype pkg/host: improve KMEMLEAK support 2018-09-28 14:57:20 +02:00
runtest pkg/host: improve KMEMLEAK support 2018-09-28 14:57:20 +02:00
serializer pkg/serializer: refactor 2018-08-02 16:57:31 +02:00
signal prog: add stronger fallback signal 2018-06-29 20:34:43 +02:00
symbolizer pkg/symbolizer: favor portable nm(1) format 2018-09-24 10:12:38 +02:00
vcs pkg/vcs: also recognize Tested-by: git commit tags 2018-11-20 14:20:38 +01:00