Add a check that the CPU count is unchanged after a reboot.

Signed-off-by: John Admanski <[email protected]>

--- autotest/client/bin/job.py  2010-05-07 15:00:02.000000000 -0700
+++ autotest/client/bin/job.py  2010-05-07 15:00:02.000000000 -0700
@@ -639,9 +639,17 @@
 
     def _check_post_reboot(self, subdir, running_id=None):
         """
-        Function to perform post boot checks such as if the mounted
-        partition list has changed across reboots.
+        Function to perform post boot checks such as if the system 
configuration
+        has changed across reboots (specifically, CPUs and partitions).
+
+        @param subdir: The subdir to use in the job.record call.
+        @param running_id: An optional running_id to include in the reboot
+            failure log message
+
+        @raise JobError: Raised if the current configuration does not match the
+            pre-reboot configuration.
         """
+        # check to see if any partitions have changed
         partition_list = partition_lib.get_partition_list(self,
                                                           exclude_swap=False)
         mount_info = set((p.device, p.get_mountpoint()) for p in 
partition_list)
@@ -656,6 +664,17 @@
                                         description, running_id=running_id)
             raise error.JobError("Reboot failed: %s" % description)
 
+        # check to see if any CPUs have changed
+        cpu_count = utils.count_cpus()
+        old_count = self._state.get('client', 'cpu_count')
+        if cpu_count != old_count:
+            description = ('Number of CPUs changed after reboot '
+                           '(old count: %d, new count: %d)' %
+                           (old_count, cpu_count))
+            self._record_reboot_failure(subdir, 'reboot.verify_config',
+                                        description, running_id=running_id)
+            raise error.JobError('Reboot failed: %s' % description)
+
 
     def end_reboot(self, subdir, kernel, patches, running_id=None):
         self._check_post_reboot(subdir, running_id=running_id)
@@ -749,12 +768,12 @@
 
 
     def reboot_setup(self):
-        # save the partition list and their mount point and compare it
-        # after reboot
+        # save the partition list and mount points, as well as the cpu count
         partition_list = partition_lib.get_partition_list(self,
                                                           exclude_swap=False)
         mount_info = set((p.device, p.get_mountpoint()) for p in 
partition_list)
         self._state.set('client', 'mount_info', mount_info)
+        self._state.set('client', 'cpu_count', utils.count_cpus())
 
 
     def reboot(self, tag=LAST_BOOT_TAG):
--- autotest/client/bin/job_unittest.py 2010-05-07 15:00:02.000000000 -0700
+++ autotest/client/bin/job_unittest.py 2010-05-07 15:00:02.000000000 -0700
@@ -554,9 +554,10 @@
         self.god.check_playback()
 
 
-    def _setup_check_post_reboot(self, mount_info):
+    def _setup_check_post_reboot(self, mount_info, cpu_count):
         # setup
         self.god.stub_function(job.partition_lib, "get_partition_list")
+        self.god.stub_function(utils, "count_cpus")
 
         part_list = [self.get_partition_mock("/dev/hda1"),
                      self.get_partition_mock("/dev/hdb1")]
@@ -567,7 +568,10 @@
                 self.job, exclude_swap=False).and_return(part_list)
         for i in xrange(len(part_list)):
             part_list[i].get_mountpoint.expect_call().and_return(mount_list[i])
+        if cpu_count is not None:
+            utils.count_cpus.expect_call().and_return(cpu_count)
         self.job._state.set('client', 'mount_info', mount_info)
+        self.job._state.set('client', 'cpu_count', 8)
 
 
     def test_check_post_reboot_success(self):
@@ -575,7 +579,7 @@
 
         mount_info = set([("/dev/hda1", "/mnt/hda1"),
                           ("/dev/hdb1", "/mnt/hdb1")])
-        self._setup_check_post_reboot(mount_info)
+        self._setup_check_post_reboot(mount_info, 8)
 
         # playback
         self.job._check_post_reboot("sub")
@@ -586,7 +590,7 @@
         self.construct_job(True)
 
         mount_info = set([("/dev/hda1", "/mnt/hda1")])
-        self._setup_check_post_reboot(mount_info)
+        self._setup_check_post_reboot(mount_info, None)
 
         self.god.stub_function(self.job, "_record_reboot_failure")
         self.job._record_reboot_failure.expect_call("sub",
@@ -599,6 +603,24 @@
         self.god.check_playback()
 
 
+    def test_check_post_reboot_cpu_failure(self):
+        self.construct_job(True)
+
+        mount_info = set([("/dev/hda1", "/mnt/hda1"),
+                          ("/dev/hdb1", "/mnt/hdb1")])
+        self._setup_check_post_reboot(mount_info, 4)
+
+        self.god.stub_function(self.job, "_record_reboot_failure")
+        self.job._record_reboot_failure.expect_call(
+            'sub', 'reboot.verify_config',
+            'Number of CPUs changed after reboot (old count: 8, new count: 4)',
+            running_id=None)
+
+        # playback
+        self.assertRaises(error.JobError, self.job._check_post_reboot, "sub")
+        self.god.check_playback()
+
+
     def test_end_boot(self):
         self.construct_job(True)
         self.god.stub_function(self.job, "_check_post_reboot")
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to