Re: thermal: add new test group

Cyril Hrubis <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
Hi!
I've been debugging the test random failures and it all boils down to
two things:

- the sysfs temperature values are in mC the increment we have is way
  too small

- we need to set the trigger value in the while(sleep_time > 0) loop
  otherwise we can end up running all the iterations with a value that
  is too high (if we enter the function when the CPU temperature was
  high)

The test runs reliably for me with -i 100 with these changes, I can push
the test with these changes added if you agree:

diff --git a/testcases/kernel/thermal/thermal_interrupt_events.c b/testcases/kernel/thermal/thermal_interrupt_events.c
index 42e1532f6..ed55632dc 100644
--- a/testcases/kernel/thermal/thermal_interrupt_events.c
+++ b/testcases/kernel/thermal/thermal_interrupt_events.c
@@ -20,10 +20,10 @@
 #include "tst_timer_test.h"

 #define        TEST_RUNTIME    ((RUNTIME + SLEEPTIME) * (SLEEPTIME / 2) + COOLDOWN)
-#define        RUNTIME         30
+#define        RUNTIME         10
 #define        SLEEPTIME       10
 #define        COOLDOWN        300
-#define        TEMP_INCREMENT  10
+#define        TEMP_INCREMENT  5000

 static bool *x86_pkg_temp_tz;
 static char temp_path[PATH_MAX], trip_path[PATH_MAX];
@@ -135,13 +135,8 @@ static void cpu_workload(double run_time)
        }
 }

-static void test_zone(int i)
+static void set_trippoint(void)
 {
-       int sleep_time = SLEEPTIME;
-       double run_time = RUNTIME;
-
-       snprintf(temp_path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/temp", i);
-       tst_res(TINFO, "Testing %s", temp_path);
        SAFE_FILE_SCANF(temp_path, "%d", &temp);
        if (temp < 0)
                tst_brk(TBROK, "Unexpected zone temperature value %d", temp);
@@ -150,10 +145,21 @@ static void test_zone(int i)

        temp_high = temp + TEMP_INCREMENT;

-       snprintf(trip_path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/trip_point_1_temp", i);
-
        tst_res(TDEBUG, "Setting new trip_point_1_temp value: %d", temp_high);
        SAFE_FILE_PRINTF(trip_path, "%d", temp_high);
+}
+
+static void test_zone(int i)
+{
+       int sleep_time = SLEEPTIME;
+       double run_time = RUNTIME;
+
+       snprintf(temp_path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/temp", i);
+       snprintf(trip_path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/trip_point_1_temp", i);
+
+       tst_res(TINFO, "Testing %s", temp_path);
+
+       set_trippoint();

        while (sleep_time > 0) {
                tst_res(TDEBUG, "Running for %f seconds, then sleeping for %d seconds", run_time, sleep_time);
@@ -173,7 +179,9 @@ static void test_zone(int i)
                if (temp > temp_high)
                        break;
                sleep(sleep_time--);
-               run_time -= 3;
+               run_time--;
+
+               set_trippoint();
        }
 }


-- 
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.