On വ്യാഴം 06 മെയ് 2010 02:33 വൈകു, Suzuki Poulose wrote:
On വ്യാഴം 06 മെയ് 2010 01:25 വൈകു, Garrett Cooper wrote:
On May 6, 2010, at 12:04 AM, Suzuki Poulose wrote:

<fix-timer-tests-bad-header.diff>

Maybe a better solution would be to NULL terminate the array (well, or
do similar)? Using two units of measurement just seems like it'd
complicate how things are being performed...

Used MAX_CLOCKS to mark the end of clock list array. Patch attached.

Just realized that, I sent the very old patch not the updated one. Here is the updated one:




Thanks

Suzuki
Thanks,
-Garrett


The MAX_CLOCKS supported by the kernel is 16. But the kernel may not have all
the clock sources defined in the range 0-15.

Hence, to test whether kernel returns error for an INVALID clock source id,
we should use the upper limit MAX_CLOCKS (16 at the moment).

But to verify the the defined clocks work fine, we should loop through the 
"list"
of clock sources defined for sure. MAX_CLOCKS marsk the end of the clock 
sources in the 
array.

Signed-off-by:  Suzuki K P <[email protected]>
Cc:             Garrett Cooper <[email protected]>

Index: ltp/testcases/kernel/timers/include/common_timers.h
===================================================================
--- ltp.orig/testcases/kernel/timers/include/common_timers.h    2010-06-01 
15:28:04.000000000 +0000
+++ ltp/testcases/kernel/timers/include/common_timers.h 2010-06-01 
15:34:33.000000000 +0000
@@ -28,14 +28,18 @@
 #ifndef CLOCK_MONOTONIC_RAW
 #define CLOCK_MONOTONIC_RAW 4
 #endif
+
+/* MAX_CLOCKS is the maximum number of clock sources supported by kernel */
+#define MAX_CLOCKS 16
+
 clock_t clock_list[] = {
        CLOCK_REALTIME,
        CLOCK_MONOTONIC,
        CLOCK_PROCESS_CPUTIME_ID,
        CLOCK_THREAD_CPUTIME_ID,
        CLOCK_MONOTONIC_RAW,
+       MAX_CLOCKS
 };
-#define MAX_CLOCKS (sizeof(clock_list) / sizeof(*clock_list))
 
 const char *get_clock_str(const int clock_id)
 {
Index: ltp/testcases/kernel/timers/timer_create/timer_create02.c
===================================================================
--- ltp.orig/testcases/kernel/timers/timer_create/timer_create02.c      
2010-06-01 15:28:04.000000000 +0000
+++ ltp/testcases/kernel/timers/timer_create/timer_create02.c   2010-06-01 
15:34:56.000000000 +0000
@@ -113,7 +113,7 @@
 
                        setup_test(i);
 
-                       for (j = 0; j < MAX_CLOCKS; ++j) {
+                       for (j = 0; clock_list[j] != MAX_CLOCKS; ++j) {
 
                                if (strstr(get_clock_str(clock_list[j]),
                                                "CPUTIME_ID")) {
------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to