mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-24 11:59:58 +00:00
pkg/csource: detect common mistakes in the common executor header
This commit is contained in:
parent
97264cb1f3
commit
46869e3ee2
@ -2637,8 +2637,9 @@ retry:
|
||||
int fd = open(filename, O_RDONLY);
|
||||
if (fd != -1) {
|
||||
long flags = 0;
|
||||
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0)
|
||||
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) {
|
||||
debug("reset FS_XFLAG_IMMUTABLE\n");
|
||||
}
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
@ -2665,8 +2666,9 @@ retry:
|
||||
int fd = open(dir, O_RDONLY);
|
||||
if (fd != -1) {
|
||||
long flags = 0;
|
||||
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0)
|
||||
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) {
|
||||
debug("reset FS_XFLAG_IMMUTABLE\n");
|
||||
}
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
|
@ -181,3 +181,38 @@ func TestExecutorMacros(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecutorMistakes(t *testing.T) {
|
||||
mistakes := map[string][]string{
|
||||
// We strip debug() calls from the resulting C source,
|
||||
// this breaks the following pattern. Use {} around debug() to fix.
|
||||
"\\)\n\\t*(debug|debug_dump_data)\\(": {
|
||||
`
|
||||
if (foo)
|
||||
debug("foo failed");
|
||||
`, `
|
||||
if (x + y)
|
||||
debug_dump_data(data, len);
|
||||
`,
|
||||
},
|
||||
}
|
||||
for pattern, tests := range mistakes {
|
||||
re := regexp.MustCompile(pattern)
|
||||
for _, test := range tests {
|
||||
if !re.MatchString(test) {
|
||||
t.Errorf("patter %q does not match test %q", pattern, test)
|
||||
}
|
||||
}
|
||||
for _, match := range re.FindAllStringIndex(commonHeader, -1) {
|
||||
start, end := match[0], match[1]
|
||||
for start != 0 && commonHeader[start] != '\n' {
|
||||
start--
|
||||
}
|
||||
for end != len(commonHeader) && commonHeader[end] != '\n' {
|
||||
end++
|
||||
}
|
||||
t.Errorf("pattern %q matches executor source:\n%v",
|
||||
pattern, commonHeader[start:end])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5610,8 +5610,9 @@ retry:
|
||||
int fd = open(filename, O_RDONLY);
|
||||
if (fd != -1) {
|
||||
long flags = 0;
|
||||
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0)
|
||||
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) {
|
||||
debug("reset FS_XFLAG_IMMUTABLE\n");
|
||||
}
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
@ -5637,8 +5638,9 @@ retry:
|
||||
int fd = open(dir, O_RDONLY);
|
||||
if (fd != -1) {
|
||||
long flags = 0;
|
||||
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0)
|
||||
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) {
|
||||
debug("reset FS_XFLAG_IMMUTABLE\n");
|
||||
}
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user