Commit 9e51183e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux-kselftest-fixes-5.10-rc1' of...

Merge tag 'linux-kselftest-fixes-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest updates from Shuah Khan:

 - a selftests harness fix to flush stdout before forking to avoid
   parent and child printing duplicates messages. This is evident when
   test output is redirected to a file.

 - a tools/ wide change to avoid comma separated statements from Joe
   Perches. This fix spans tools/lib, tools/power/cpupower, and
   selftests.

* tag 'linux-kselftest-fixes-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  tools: Avoid comma separated statements
  selftests/harness: Flush stdout before forking
parents 2fc61f25 aa803771
......@@ -65,12 +65,14 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
ci = cj = ei = 0;
while (ci < cmds->cnt && ei < excludes->cnt) {
cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);
if (cmp < 0)
if (cmp < 0) {
cmds->names[cj++] = cmds->names[ci++];
else if (cmp == 0)
ci++, ei++;
else if (cmp > 0)
} else if (cmp == 0) {
ci++;
ei++;
} else if (cmp > 0) {
ei++;
}
}
while (ci < cmds->cnt)
......
......@@ -99,13 +99,17 @@ static unsigned long string_to_frequency(const char *str)
continue;
if (str[cp] == '.') {
while (power > -1 && isdigit(str[cp+1]))
cp++, power--;
while (power > -1 && isdigit(str[cp+1])) {
cp++;
power--;
}
if (power >= -1) /* not enough => pad */
}
if (power >= -1) { /* not enough => pad */
pad = power + 1;
else /* to much => strip */
pad = 0, cp += power + 1;
} else { /* too much => strip */
pad = 0;
cp += power + 1;
}
/* check bounds */
if (cp <= 0 || cp + pad > NORM_FREQ_LEN - 1)
return 0;
......
......@@ -971,6 +971,11 @@ void __run_test(struct __fixture_metadata *f,
ksft_print_msg(" RUN %s%s%s.%s ...\n",
f->name, variant->name[0] ? "." : "", variant->name, t->name);
/* Make sure output buffers are flushed before fork */
fflush(stdout);
fflush(stderr);
t->pid = fork();
if (t->pid < 0) {
ksft_print_msg("ERROR SPAWNING TEST CHILD\n");
......
......@@ -105,12 +105,16 @@ int main(int argc, char **argv)
gup.flags |= FOLL_WRITE;
fd = open("/sys/kernel/debug/gup_benchmark", O_RDWR);
if (fd == -1)
perror("open"), exit(1);
if (fd == -1) {
perror("open");
exit(1);
}
p = mmap(NULL, size, PROT_READ | PROT_WRITE, flags, filed, 0);
if (p == MAP_FAILED)
perror("mmap"), exit(1);
if (p == MAP_FAILED) {
perror("mmap");
exit(1);
}
gup.addr = (unsigned long)p;
if (thp == 1)
......@@ -123,8 +127,10 @@ int main(int argc, char **argv)
for (i = 0; i < repeats; i++) {
gup.size = size;
if (ioctl(fd, cmd, &gup))
perror("ioctl"), exit(1);
if (ioctl(fd, cmd, &gup)) {
perror("ioctl");
exit(1);
}
printf("Time: get:%lld put:%lld us", gup.get_delta_usec,
gup.put_delta_usec);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment