Re: 2.5 kernel regression in alarm() syscall behaviour?

Amos Waterland (apw@us.ibm.com)
Mon, 14 Jul 2003 09:39:33 -0500


I think Wes' mail client mangled his testcase a bit. Here is a cleaned
up version.

Compile with:

% gcc -Wall -Werror alarm.c -o alarm

Output on 2.4 kernel is:

% ./alarm
[1058193354] alarm(0), want retval:0; got retval:0 (PASS)
...
[1058193354] alarm(9), want retval:8; got retval:8 (PASS)
0/10 tests failed

Output on 2.5 kernel is: many failures. The number of failures go down
when the system is heavily stressed.

---- Begin alarm.c ----

#include <unistd.h>
#include <stdio.h>
#include <sys/time.h>

#define MINVAL 0
#define MAXVAL 10
#define NOALARM 0

int main(int argc, char **argv)
{
int retval = 0, failed = 0, tests = MAXVAL, prev = 0, curr = 0;
struct timeval time;

if (argc > 1)
if (sscanf(argv[1], "%d", &tests) != 1)
return 1;

for (curr = MINVAL; curr < tests; curr++) {
retval = alarm(curr);
gettimeofday(&time, NULL);
printf("[%li] alarm(%d), want retval:%d; ",
time.tv_sec, curr, prev);
/* was there a previous alarm? */
if (retval == NOALARM && prev == NOALARM) {
printf("got retval:0 (PASS)");
} else if (retval == NOALARM && prev > NOALARM) {
printf("got retval:0 (FAIL)");
failed++;
} else if (retval != prev) {
printf("got retval:%d (FAIL)", retval);
failed++;
} else {
printf("got retval:%d (PASS)", retval);
}
printf("\n");
prev = curr;
}
printf("%d/%d tests failed\n", failed, tests);
return failed;
}

---- End alarm.c ----
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/