aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/csource_test.go
Commit message (Collapse)AuthorAgeFilesLines
* pkg/testutil: add packageDmitry Vyukov2021-12-211-0/+14
| | | | | | | | Add package with RaceEnabled const that can be used in test to skip long tests in race mode. Switch existing tests to use the new package. Update #2886
* all: add the `rerun` call propertyAleksandr Nogikh2021-12-101-1/+4
| | | | | | | | | | | | | | To be able to collide specific syscalls more precisely, we need to repeat the process many times. Introduce the `rerun` call property, which instructs `syz-executor` to repeat the call the specified number of times. The intended use is: call1() (rerun: 100, async) call2() (rerun: 100) For now, assign rerun values randomly to consecutive pairs of calls, where the first one is async.
* all: replace collide mode by `async` call propertyAleksandr Nogikh2021-12-101-1/+4
| | | | | | | | | | | | | Replace the currently existing straightforward approach to race triggering (that was almost entirely implemented inside syz-executor) with a more flexible one. The `async` call property instructs syz-executor not to block until the call has completed execution and proceed immediately to the next call. The decision on what calls to mark with `async` is made by syz-fuzzer. Ultimately this should let us implement more intelligent race provoking strategies as well as make more fine-grained reproducers.
* pkg/csource: remove calls instead of skipping themAleksandr Nogikh2021-10-011-4/+4
| | | | | | | | | | | | | | | | | | Currently csource skips calls at the very last moment, which has an unpleasant consequence - if we make choice of enabled defines depend on the individual calls or call properties, we may end up with defined yet unused functions. The perfect solution would be to untie syz_emit_ethernet/syz_extract_tcp_res and NetInjection, and also to untie VhciInjection and syz_emit_vhci. For the time being, move these checks to the very beginning of csource processing, so that these calls could be removed before we construct our defines. Adjust pkg/csource/csource_test.go to better cover fault injection generation problems.
* all: refactor fault injection into call propsAleksandr Nogikh2021-09-221-0/+4
| | | | | | | | | | | | Now that call properties mechanism is implemented, we can refactor fault injection. Unfortunately, it is impossible to remove all traces of the previous apprach. In reprolist and while performing syz-ci jobs, syzkaller still needs to parse the old format. Remove the old prog options-based approach whenever possible and replace it with the use of call properties.
* pkg/csource: don't enable HandleSegv in short testsDmitry Vyukov2021-07-291-0/+6
| | | | | | | | HandleSegv can radically increase compilation time/memory consumption on large programs. For example, for one program captured from this test enabling HandleSegv increases compilation time from 1.94s to 104.73s and memory consumption from 136MB to 8116MB. This leads to CI failures on #2688. Don't enable HandleSegv in short tests.
* pkg/compiler: optimize array[const] representationDmitry Vyukov2021-04-211-24/+6
| | | | | | | | | | | | | | Represent array[const[X, int8], N] as string["XX...X"]. This replaces potentially huge number of: NONFAILING(*(uint8_t*)0x2000126c = 0); NONFAILING(*(uint8_t*)0x2000126d = 0); NONFAILING(*(uint8_t*)0x2000126e = 0); with a single memcpy. In one reproducer we had 3991 such lines. Also replace memcpy's with memset's when possible. Update #1070
* pkg/csource: add resuling source testsDmitry Vyukov2021-04-211-0/+85
| | | | | | Add some tests that verify source we get for various programs. Update #1070
* pkg/runtest: check arch requirement earlyDmitry Vyukov2021-02-081-62/+1
| | | | | | | Need to check arch requirement early as some programs may fail to deserialize on some arches due to missing syscalls. See discussion on #2380. Also support negative arch requirements (-arch=amd64).
* all: make timeouts configurableDmitry Vyukov2020-12-281-0/+1
| | | | | | Add sys/targets.Timeouts struct that parametrizes timeouts throughout the system. The struct allows to control syscall/program/no output timeouts for OS/arch/VM/etc. See comment on the struct for more details.
* sys/targets: add OS/Arch name constsDmitry Vyukov2020-10-261-2/+2
| | | | | | | | | | | | We use strings to identify OS/Arch. These strings are duplicated throughout the code base massively. golangci-lint points to possiblity of typos and duplication. We already had to define these names in pkg/csource and disable checking for prog package. A future change triggers such warnings in another package. Add OS/Arch name consts to sys/targets so that they can be used to refer to OS/Arch. Use the consts everywhere.
* pkg/csource: don't test auto-generated filesDmitry Vyukov2020-09-201-0/+6
| | | | | | syz_mount_image tests are very large and TestSysTests takes too long. syz-imagegen that generates them does some of this testing (Deserialize/SerializeForExec).
* executor: add some code style checksDmitry Vyukov2020-08-061-48/+0
| | | | | | | Move the test from pkg/csource to executor/ in order to be able to (1) run it on *.cc files, (2) run on unprocessed *.h files, (3) produce line numbers. Add a check for missed space after //.
* executor: remove block commentsDmitry Vyukov2020-08-041-11/+24
| | | | | | | | | 1. We don't generally use /* */ block comments, few precedents we have are inconsistent with the rest of the code. 2. pkg/csource does not strip them from the resulting code. Remove the cases we have and add a test to prevent new ones being added.
* .golangci.yml: enable whitespace checkerDmitry Vyukov2020-06-051-1/+0
| | | | Points to bad empty lines very precisely.
* pkg/csource: speed up testsDmitry Vyukov2020-05-181-1/+4
| | | | | | Tests run for too long. 1. Check only 1 arch per OS in short mode. 2. Dedup options. Turns out we generated 2x duplicates in allOptionsSingle.
* Get rid of "Cross" in variable namesAlexander Potapenko2020-05-131-1/+1
| | | | | | | | | Renamed Target.BrokenCrossCompiler to Target.BrokenCompiler and Target.CrossCFlags to Target.CFlags "Everything in Target is about Cross now." Signed-off-by: Alexander Potapenko <glider@google.com>
* all: reformat codeDmitry Vyukov2020-05-081-2/+2
|
* all: replace TRAVIS env var with CIDmitry Vyukov2020-05-071-2/+2
| | | | | | | | In preparation to running some tests as github actions. Both Travis and Github define CI env var, while TRAVIS is, well, too Travis-specific. Update #1699
* prog: support disabled attributeDmitry Vyukov2020-05-041-2/+2
| | | | | Update #477 Update #502
* sys/targets: better detection for missing/broken cross-compilersDmitry Vyukov2020-04-291-19/+1
| | | | | | | | | | | | | | 1. Detect when compiler is present, but is not functioning (can't build a simple program, common for Linux distros). 2. Be more strict with skipping tests due to missing/broken compilers on CI (on CI they should work, so fail loudly if not). 3. Dedup this logic across syz-env and pkg/csource tests. 4. Add better error reporting for syz-env. Fixes #1606
* pkg/csource: don't print too much error outputDmitry Vyukov2020-02-131-0/+19
| | | | | | | We print whole reproducer programs on failure, if lots of programs fail, this results in thousands of lines of output, which is esp bad on travis. Limit amount of output.
* pkg/csource: detect common mistakes in the common executor headerDmitry Vyukov2019-11-281-0/+35
|
* pkg/csoruce: test that executor does not mis-spell any of the SYZ_* macrosDmitry Vyukov2019-11-161-0/+21
|
* pkg/csource: don't run tests if compiler is brokenDmitry Vyukov2019-11-071-0/+8
| | | | | Test presence of a working compiler before running any tests for a target. This helps to make tests pass even if some cross-compilers are not installed properly.
* pkg/csource: skip cross-builds that are doomed to failDmitry Vyukov2019-07-231-0/+4
| | | | | | | | | | | OpenBSD instance failed with: --- FAIL: TestSysTests (12.50s) --- FAIL: TestSysTests/linux/386 (0.16s) csource_test.go:145: failed to generate C source for ../../sys/linux/test/binder: cpp failed: exec: "cant-build-linux-on-openbsd": executable file not found in $PATH ... Skip unsupported cross-builds in TestSysTests.
* pkg/csource: test sys/*/test programsDmitry Vyukov2019-07-221-11/+52
| | | | | | Running sys/*/test programs requires real machines and kernels for each OS. We can't do that in unit tests, but at least try to deserialize these programs so that they don't get rotten.
* Makefile: enable 386 executor build in presubmitDmitry Vyukov2019-05-071-5/+0
| | | | This hacky way to install 386 packages seems to unbreak executor build.
* Makefile: enable arm executor build in presubmitDmitry Vyukov2019-05-071-6/+0
| | | | arm build seems to work now on Travis since we switched to xenial.
* all: fix warnings pointed to by golangci-lintDmitry Vyukov2019-03-281-1/+1
| | | | Update #977
* executor: prevent non-null expected warningsDmitry Vyukov2019-03-211-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | The added test triggers warnings like these: <stdin>: In function ‘syz_mount_image.constprop’: <stdin>:298:3: error: argument 1 null where non-null expected [-Werror=nonnull] In file included from <stdin>:26:0: /usr/include/x86_64-linux-gnu/sys/stat.h:320:12: note: in a call to function ‘mkdir’ declared here extern int mkdir (const char *__path, __mode_t __mode) ^~~~~ cc1: all warnings being treated as errors <stdin>: In function ‘syz_open_procfs.constprop’: <stdin>:530:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] <stdin>:85:110: note: in definition of macro ‘NONFAILING’ <stdin>:532:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] <stdin>:85:110: note: in definition of macro ‘NONFAILING’ <stdin>:534:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] <stdin>:85:110: note: in definition of macro ‘NONFAILING’ Use volatile for all arguments of syz_ functions to prevent compiler from treating the arguments as constants in reproducers. Popped up during bisection that used a repro that previously worked. Update #501
* prog, pkg/{csource,ifuzz,ipc,repro}: make tests deterministic on travisDmitry Vyukov2019-01-021-0/+3
| | | | | Don't use random seed on travis as it produces flaky coverage reports, and probably generally better for CI setting.
* pkg/csource: exclude linux/arm64 testsDmitry Vyukov2018-12-051-7/+5
| | | | | | | | | | | | | | | I think I misinterpreted the error that episodically happens on ci: collect2: error: ld terminated with signal 11 [Segmentation fault], core dumped compiler invocation: aarch64-linux-gnu-gcc [-Wall -Werror -O1 -g -o /tmp/syz-executor570589071 -pthread -DGOOS_linux=1 -DGOARCH_arm64=1 -x c - -static] as OOM, but they all involve aarch64-linux-gnu-gcc: https://travis-ci.org/google/syzkaller/jobs/461827347 https://travis-ci.org/google/syzkaller/jobs/460226110 https://travis-ci.org/google/syzkaller/jobs/463564291 So I guess the problem can be with the arm64 toolchain that just crashes randomly.
* pkg/csource: reduce short testsDmitry Vyukov2018-12-031-39/+42
| | | | | | | | | | | | pkg/csource test gets OOM-killed on travis: https://travis-ci.org/google/syzkaller/jobs/461827347 https://travis-ci.org/google/syzkaller/jobs/460226110 Add several measures: - set GOMAXPROCS=1 to restrict parallel processes - remove -g from compiler invocation - reduce set of tests run in short mode to compensate for GOMAXPROCS=1 - also reduce set of tests in full mode as they timeout now
* openbsd: repair pkg/csource_testGreg Steuck2018-11-301-4/+0
|
* sys/targest: introduce target.BuildOSDmitry Vyukov2018-11-171-3/+3
| | | | | | | | We can't cross-compile native binaries from just any OS to any other. For most OSes we can do only native compilation. Some can only be compiled from linux. To date we avoided this problem completely (mostly assumed linux build OS). Make this notion of what can build what explicit.
* pkg/runtest, pkg/csource: don't run tests on openbsdDmitry Vyukov2018-09-171-0/+5
| | | | The tests are currently broken on openbsd.
* pkg/csource: turn off 32-bit testsDmitry Vyukov2018-07-271-0/+4
| | | | Test OS fails the same was as linux on travis.
* pkg/csource: say what compiler is missingDmitry Vyukov2018-07-251-3/+4
|
* executor: overhaulDmitry Vyukov2018-07-241-64/+33
| | | | | | | | | | | | | | | | | Make as much code as possible shared between all OSes. In particular main is now common across all OSes. Make more code shared between executor and csource (in particular, loop function and threaded execution logic). Also make loop and threaded logic shared across all OSes. Make more posix/unix code shared across OSes (e.g. signal handling, pthread creation, etc). Plus other changes along similar lines. Also support test OS in executor (based on portable posix) and add 4 arches that cover all execution modes (fork server/no fork server, shmem/no shmem). This change paves way for testing of executor code and allows to preserve consistency across OSes and executor/csource.
* pkg/csource: support fuchsiaDmitry Vyukov2018-06-291-26/+35
| | | | Lots of assorted heavylifting to support csource on fuchsia.
* pkg/csource: allow to build source fom memoryDmitry Vyukov2018-06-061-8/+1
| | | | | | In most cases we have source in memory, so provide a function to build right from memory without creating temp files.
* pkg/csource: reduce test sizeDmitry Vyukov2018-05-071-4/+6
| | | | | | | The test times out on travis: https://travis-ci.org/google/syzkaller/jobs/375965899 https://travis-ci.org/google/syzkaller/jobs/375965900
* sys/linux: add cgroup descriptionsDmitry Vyukov2018-03-251-0/+1
|
* all: fix gometalinter warningsDmitry Vyukov2018-03-081-1/+1
| | | | Fix typos, non-canonical code, remove dead code, etc.
* sys: move test syscalls to a separate targetDmitry Vyukov2017-12-171-0/+3
| | | | | | We have them in linux solely for historical reasons. Fixes #462
* pkg/csource: add function to parse serialized optionsDmitry Vyukov2017-11-171-61/+2
| | | | | Also move options and options tests into a separate file, add serialization function.
* all: basic freebsd supportDmitry Vyukov2017-10-021-0/+3
| | | | For now we just make Go part build for freebsd.
* executor, sys/windows: initial windows supportDmitry Vyukov2017-09-251-2/+4
|
* pkg/csource: disable linux/386 testsDmitry Vyukov2017-09-221-0/+5
| | | | Another attempt to fix travis build.