Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-fixes-5.10-rc1' of git://git.kernel.org/pu…
Browse files Browse the repository at this point in the history
…b/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
  • Loading branch information
torvalds committed Oct 14, 2020
2 parents 2fc61f2 + aa80377 commit 9e51183
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 128 deletions.
10 changes: 6 additions & 4 deletions tools/lib/subcmd/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 9 additions & 5 deletions tools/power/cpupower/utils/cpufreq-set.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions tools/testing/selftests/kselftest_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
18 changes: 12 additions & 6 deletions tools/testing/selftests/vm/gup_benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 9e51183

Please sign in to comment.