Skip to content

Commit f69705f

Browse files
committed
tests/functional/test_x86_64_hotplug_cpu: Fix race condition during unplug
When unplugging the CPU, the test tries to check for a successful unplug by changing to the /sys/devices/system/cpu/cpu1 directory to see whether that fails. However, the "cd" could be faster than the unplug operation in the kernel, so there is a race condition and the test sometimes fails here. Fix it by trying to change the directory in a loop until the the CPU has really been unplugged. While we're at it, also add a "cd .." before unplugging to make the console output a little bit less confusing (since the path is echoed in the shell prompt). Reported-by: Stefan Hajnoczi <[email protected]> Message-ID: <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
1 parent 5cd37fe commit f69705f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/functional/test_x86_64_hotplug_cpu.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ def test_hotplug(self):
5959
'cd /sys/devices/system/cpu/cpu1',
6060
'cpu1#')
6161

62+
exec_command_and_wait_for_pattern(self, 'cd ..', prompt)
6263
self.vm.cmd('device_del', id='c1')
6364

6465
exec_command_and_wait_for_pattern(self,
65-
'cd /sys/devices/system/cpu/cpu1',
66-
'No such file or directory')
66+
'while cd /sys/devices/system/cpu/cpu1 ;'
67+
' do sleep 0.2 ; done',
68+
'No such file or directory')
6769

6870
if __name__ == '__main__':
6971
LinuxKernelTest.main()

0 commit comments

Comments
 (0)