summaryrefslogtreecommitdiffstats
path: root/recipes-test/virt-test/files/qemu-tests-tsc-sync-build-avoidance.patch
blob: 2e078ff142ac0dcc84d8eff7ea1c0b42f240312c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
commit 58b79263adaaee08a7a913268f36e2f957b330db
Author: Jonas Eriksson <jonas.eriksson@enea.com>
Date:   Fri Mar 21 15:21:18 2014 +0100

    tsc_sync tests: Avoid build and parameterize
    
    Signed-off-by: Jonas Eriksson <jonas.eriksson@enea.com>
    Upstream-Status: Pending

diff --git a/qemu/tests/timerdevice_clock_drift_with_ntp.py b/qemu/tests/timerdevice_clock_drift_with_ntp.py
index 4498519..28f22c0 100644
--- a/qemu/tests/timerdevice_clock_drift_with_ntp.py
+++ b/qemu/tests/timerdevice_clock_drift_with_ntp.py
@@ -26,9 +26,11 @@ def run(test, params, env):
     :param params: Dictionary with test parameters.
     :param env: Dictionary with the test environment.
     """
+    drift_filename = params.get("drift_filename", "/var/lib/ntp/drift")
+
     def _drift_file_exist():
         try:
-            session.cmd("test -f /var/lib/ntp/drift")
+            session.cmd("test -f %s" % drift_filename)
             return True
         except Exception:
             return False
@@ -46,20 +48,25 @@ def run(test, params, env):
     timeout = int(params.get("login_timeout", 360))
     sess_guest_load = vm.wait_for_login(timeout=timeout)
 
-    error.context("Copy time-warp-test.c to guest", logging.info)
-    src_file_name = os.path.join(data_dir.get_deps_dir(), "time_warp",
-                                 "time-warp-test.c")
-    vm.copy_files_to(src_file_name, "/tmp")
+    time_warp_test_cmd = params.get("time_warp_test_cmd", "/tmp/time-warp-test")
+
+    if sess_guest_load.get_command_status("test -x %s" % time_warp_test_cmd):
+        error.context("Copy time-warp-test.c to guest", logging.info)
+        src_file_name = os.path.join(data_dir.get_deps_dir(), "time_warp",
+                                     "time-warp-test.c")
+        vm.copy_files_to(src_file_name, "/tmp")
 
-    error.context("Compile the time-warp-test.c", logging.info)
-    cmd = "cd /tmp/;"
-    cmd += " yum install -y popt-devel;"
-    cmd += " rm -f time-warp-test;"
-    cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt"
-    sess_guest_load.cmd(cmd)
+        error.context("Compile the time-warp-test.c", logging.info)
+        cmd = "cd /tmp/;"
+        cmd += " yum install -y popt-devel;"
+        cmd += " rm -f time-warp-test;"
+        cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt"
+        sess_guest_load.cmd(cmd)
 
     error.context("Stop ntpd and apply load on guest", logging.info)
-    sess_guest_load.cmd("yum install -y ntp; service ntpd stop")
+    default_ntp_stop_cmd = "yum install -y ntp; service ntpd stop; rm -f %s" % drift_filename
+    ntp_stop_cmd = params.get("ntp_stop_cmd", default_ntp_stop_cmd)
+    sess_guest_load.cmd(ntp_stop_cmd)
     load_cmd = "for ((I=0; I<`grep 'processor id' /proc/cpuinfo| wc -l`; I++));"
     load_cmd += " do taskset -c $I /bin/bash -c 'for ((;;)); do X=1; done &';"
     load_cmd += " done"
@@ -80,12 +87,12 @@ def run(test, params, env):
 
     error.context("Run time-warp-test", logging.info)
     session = vm.wait_for_login(timeout=timeout)
-    cmd = "/tmp/time-warp-test > /dev/null &"
+    cmd = "%s > /dev/null &" % time_warp_test_cmd
     session.sendline(cmd)
 
     error.context("Start ntpd on guest", logging.info)
-    cmd = "service ntpd start; sleep 1; echo"
-    session.cmd(cmd)
+    ntp_start_cmd = params.get("ntp_start_cmd", "service ntpd start; sleep 1; echo")
+    session.cmd(ntp_start_cmd)
 
     error.context("Check if the drift file exists on guest", logging.info)
     test_run_timeout = float(params["test_run_timeout"])
@@ -93,10 +100,12 @@ def run(test, params, env):
         utils_misc.wait_for(_drift_file_exist, test_run_timeout, step=5)
     except aexpect.ShellCmdError, detail:
         raise error.TestError("Failed to wait for the creation of"
-                              " /var/lib/ntp/drift file. Detail: '%s'" % detail)
+                              " %s file. Detail: '%s'" %
+                              (drift_filename, detail))
 
     error.context("Verify the drift file content on guest", logging.info)
-    output = session.cmd("cat /var/lib/ntp/drift")
+    output = session.cmd("cat %s" % drift_filename)
     if int(abs(float(output))) > 20:
         raise error.TestFail("Failed to check the ntp drift."
-                             " Output: '%s'" % output)
+                             " Output from 'cat %s': '%s'" %
+                             (drift_filename, output))
diff --git a/qemu/tests/timerdevice_tscsync_change_host_clksource.py b/qemu/tests/timerdevice_tscsync_change_host_clksource.py
index 5339fce..3ea6cb2 100644
--- a/qemu/tests/timerdevice_tscsync_change_host_clksource.py
+++ b/qemu/tests/timerdevice_tscsync_change_host_clksource.py
@@ -43,23 +43,27 @@ def run(test, params, env):
     if not '0' in output:
         raise error.TestFail("Failed to check vsyscall. Output: '%s'" % output)
 
-    error.context("Copy time-warp-test.c to guest", logging.info)
-    src_file_name = os.path.join(data_dir.get_deps_dir(), "tsc_sync",
-                                 "time-warp-test.c")
-    vm.copy_files_to(src_file_name, "/tmp")
-
-    error.context("Compile the time-warp-test.c", logging.info)
-    cmd = "cd /tmp/;"
-    cmd += " yum install -y popt-devel;"
-    cmd += " rm -f time-warp-test;"
-    cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt"
-    session.cmd(cmd)
-
-    error.context("Run time-warp-test", logging.info)
+    time_warp_test_cmd = params.get("time_warp_test_cmd", "/tmp/time-warp-test")
+
+    if session.get_command_status("test -x %s" % time_warp_test_cmd):
+        error.context("Copy time-warp-test.c to guest", logging.info)
+        src_file_name = os.path.join(data_dir.get_deps_dir(), "tsc_sync",
+                                     "time-warp-test.c")
+        vm.copy_files_to(src_file_name, "/tmp")
+
+        error.context("Compile the time-warp-test.c", logging.info)
+        cmd = "cd /tmp/;"
+        cmd += " yum install -y popt-devel;"
+        cmd += " rm -f time-warp-test;"
+        cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt"
+        session.cmd(cmd)
+
+        time_warp_test_cmd = "/tmp/time-warp-test"
+
+    error.context("Run %s" % time_warp_test_cmd, logging.info)
     test_run_timeout = int(params.get("test_run_timeout", 10))
     session.sendline("$(sleep %d; pkill time-warp-test) &" % test_run_timeout)
-    cmd = "/tmp/time-warp-test"
-    _, output = session.cmd_status_output(cmd, timeout=(test_run_timeout + 60))
+    _, output = session.cmd_status_output(time_warp_test_cmd, timeout=(test_run_timeout + 60))
 
     re_str = "fail:(\d+).*?fail:(\d+).*fail:(\d+)"
     fail_cnt = re.findall(re_str, output)
@@ -83,8 +87,7 @@ def run(test, params, env):
                       logging.info)
         cmd = "$(sleep %d; pkill time-warp-test) &"
         session.sendline(cmd % test_run_timeout)
-        cmd = "/tmp/time-warp-test"
-        _, output = session.cmd_status_output(cmd,
+        _, output = session.cmd_status_output(time_warp_test_cmd,
                                               timeout=(test_run_timeout + 60))
 
         fail_cnt = re.findall(re_str, output)
diff --git a/qemu/tests/timerdevice_tscsync_longtime.py b/qemu/tests/timerdevice_tscsync_longtime.py
index 47cc659..841be62 100644
--- a/qemu/tests/timerdevice_tscsync_longtime.py
+++ b/qemu/tests/timerdevice_tscsync_longtime.py
@@ -40,23 +40,25 @@ def run(test, params, env):
     timeout = int(params.get("login_timeout", 360))
     session = vm.wait_for_login(timeout=timeout)
 
-    error.context("Copy time-warp-test.c to guest", logging.info)
-    src_file_name = os.path.join(data_dir.get_root_dir(), "shared", "deps",
-                                 "time-warp-test.c")
-    vm.copy_files_to(src_file_name, "/tmp")
+    time_warp_test_cmd = params.get("time_warp_test_cmd", "/tmp/time-warp-test")
 
-    error.context("Compile the time-warp-test.c", logging.info)
-    cmd = "cd /tmp/;"
-    cmd += " yum install -y popt-devel;"
-    cmd += " rm -f time-warp-test;"
-    cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt"
-    session.cmd(cmd)
+    if sess_guest_load.get_command_status("test -x %s", time_warp_test_cmd):
+        error.context("Copy time-warp-test.c to guest", logging.info)
+        src_file_name = os.path.join(data_dir.get_root_dir(), "shared", "deps",
+                                     "time-warp-test.c")
+        vm.copy_files_to(src_file_name, "/tmp")
+
+        error.context("Compile the time-warp-test.c", logging.info)
+        cmd = "cd /tmp/;"
+        cmd += " yum install -y popt-devel;"
+        cmd += " rm -f time-warp-test;"
+        cmd += " gcc -Wall -o time-warp-test time-warp-test.c -lrt"
+        session.cmd(cmd)
 
     error.context("Run time-warp-test for minimum 4 hours", logging.info)
     test_run_timeout = int(params.get("test_run_timeout", 14400))
     session.sendline("$(sleep %d; pkill time-warp-test) &" % test_run_timeout)
-    cmd = "/tmp/time-warp-test"
-    _, output = session.cmd_status_output(cmd, timeout=(test_run_timeout + 60))
+    _, output = session.cmd_status_output(time_warp_test_cmd, timeout=(test_run_timeout + 60))
 
     re_str = "fail:(\d+).*?fail:(\d+).*fail:(\d+)"
     fail_cnt = re.findall(re_str, output)