aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/host/machine_info_linux_test.go
Commit message (Collapse)AuthorAgeFilesLines
* pkg/host: move glob parsing to hostDmitry Vyukov2024-04-241-44/+0
| | | | | | | Move more complex glob processing to the host (into prog package). Make fuzzer just read and return globs if requested. This moves us closer to #1541
* pkg/vminfo: add packageDmitry Vyukov2024-04-241-383/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This moves significant part of logic from the target to host (#1541), eventually this will allow us to switch target code from Go to C++. Currnetly syz-fuzzer parses a number of system files (/proc/cpuinfo) in non-trivial ways and passes that info to the host. This is problematic to recreate in C++. So instead make the fuzzer part as simple as possible: now it merely reads the gives set of files and returns contents. The rest of the parsing happens on the host (the new vminfo package). Package vminfo extracts information about the target VM. The package itself runs on the host, which may be a different OS/arch. User of the package first requests set of files that needs to be fetched from the VM (Checker.RequiredFiles), then fetches these files, and calls Checker.MachineInfo to parse the files and extract information about the VM. The information includes information about kernel modules and OS-specific info (for Linux that includes things like parsed /proc/cpuinfo). This also requires changing RPC flow between fuzzer and manager. Currently, Check call is optional and happens only for first VMs. With this change Check is always done because we need to return contents of the requested files always. The plan is to switch the rest of the pkg/host package to this scheme later: instead of some complex custom logic, we need to express it as some simple operations on the target (checking file presence, etc), and the rest of the logic on the host.
* pkg/host: increase token size to enable 128+core CPUs (#3453)Taras Madan2022-10-201-1/+13
| | | | | Default maxTokenSize is 64k. On 128 cores, I experienced 120k long token (len(flags * 128)). + check for scanner errors
* all: use `t.TempDir` to create temporary test directoryEng Zer Jun2022-03-281-7/+1
| | | | | | | | | This commit replaces all `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* pkg/host: fix globs testDmitry Vyukov2021-06-151-12/+20
| | | | | | | | | | It creates a temp dir in cwd, which is not guaranteed to be writable. Create temp dir in temp instead. Also don't assume Linux path separator, won't work on Windows. Also actually check the result, current test would be happy if glob always returns empty match as well.
* all: support exclude globs in descriptorJoey Jiao2021-06-021-0/+33
|
* pkg/host: add TestCollectMachineInfoDmitry Vyukov2021-03-181-0/+8
|
* all: support coverage of kernel modulesJoey Jiao2021-03-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | The PCs returned for dynamic loaded module (DLKM) is not parsed in coverage page, these PCs are dropped. The commit is to use DLKM modules' load address and symbol file to restore the PC and show coverage data of DLKM. Introduced new config module_obj to specify module directories. Example of config: "module_obj": [ "module_path1" "module_path2" ] For linux target, before Manager.Connect run, load addresses are getting from /proc/modules in order to group PCs into modules. And so, if modules are under kernel_obj or module_obj dir, their addresses and paths can be generated automatically. kernel_obj is searched before module_obj dir and the first found ko object is always used. Also note that kaslr needs to be disabled.
* sys/targets: add OS/Arch name constsDmitry Vyukov2020-10-261-13/+15
| | | | | | | | | | | | 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/host: add canned test for cpu infoDmitry Vyukov2020-10-091-0/+231
| | | | This should prevent the test from breaking on different arches in future.
* pkg/host: refactor machine info testsDmitry Vyukov2020-10-091-34/+21
| | | | | | | Refactor tests so that they can be used with canned info. The test fails for lots of different archs and we don't have any tests, so these will keep breaking. This change prepared for tests with canned info.
* pkg/host: test for different cpuinfo fields depending on archAndrew Donnellan2020-10-091-15/+14
| | | | | | | | | | Not all architectures have fields in /proc/cpuinfo for vendor, model and flags, e.g. powerpc doesn't have an equivalent for vendor or flags. Rather than testing for the presence of at least one field name for each category, have a separate list per architecture. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
* pkg/host: use 'processor 0' as cpu model on s390x inside containerAlexander Egorenkov2020-09-161-1/+1
| | | | | | | | | | | | There is no field 'machine' in /proc/cpuinfo when we run inside a Docker container but there is a 'processor 0' field which provides the same information. Example: processor 0: version = 00, identification = 310C57, machine = 3906 Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
* pkg/host: use 'machine' field as cpu model on IBM/ZAlexander Egorenkov2020-09-151-1/+1
| | | | | | | Use the field 'machine' in /proc/cpuinfo on IBM/Z to find out the "CPU model". Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
* pkg/host: make machine info tests linux-specificDmitry Vyukov2020-09-141-0/+145
TestScanCPUInfo does not build on !linux. TestMachineInfoLinux builds, but does not do anything useful.