[K42-discussion] [PATCH] invalid assumption in setitimer01.c

Amos Waterland apw at us.ibm.com
Sat Oct 1 15:25:41 EST 2005


The K42 open source research operating system recently stumbled upon a
problem in testcases/kernel/syscalls/setitimer/setitimer01.c.

The logic therein assumes that two successive calls to 
setitimer(which, value, ovalue) will result in the tv_sec field of the
`ovalue' returned by the second being equal to the tv_sec field of the
'value' passed to the first.  In other words, that no time measurable in
seconds will transpire between the two calls.  This is an invalid
assumption, as demonstrated by the following:

 $ stress -m 16 -d 2 -i 4 --timeout 10m &
 $ for ((i=0; ; i++)); do setitimer01 || { echo FAIL: $i runs; break; }; done
 setitimer01    1  PASS  :  functionality is correct
 setitimer01    1  PASS  :  functionality is correct
 ...
 setitimer01    1  FAIL  :  old timer value is not equal to expected value
 FAIL: 15078 runs

The fix that seems most in keeping with the intent of the original
author (who is CC'ed) is to just assert that the seconds remaining is less
than or equal to the starting value, rather than exactly equal to the
starting value.

Signed-off-by: Amos Waterland <apw at us.ibm.com>

--- testcases/kernel/syscalls/setitimer/setitimer01.c.orig
+++ testcases/kernel/syscalls/setitimer/setitimer01.c
@@ -130,7 +130,7 @@
 					 "call failed");
 			}
 
-			if (ovalue->it_value.tv_sec == SEC1) {
+			if (ovalue->it_value.tv_sec <= SEC1) {
 				tst_resm(TPASS, "functionality is correct");
 			} else {
 				tst_brkm(TFAIL, cleanup, "old timer value is "



More information about the K42-discussion mailing list