def log_after_each_test(self, test): """ Logging hook called after a test finishs. """ test_sysinfodir = self._get_sysinfodir(test.outputdir) # create a symlink in the test sysinfo dir to the current boot reboot_dir = self._get_boot_subdir() assert os.path.exists(reboot_dir) symlink_dest = os.path.join(test_sysinfodir, "reboot_current") os.symlink( # create a relative symlink utils.get_relative_path(reboot_dir, os.path.dirname(symlink_dest)), symlink_dest) # run all the standard logging commands for log in self.test_loggables: log.run(test_sysinfodir) # grab any new data from /var/log/messages self._log_messages(test_sysinfodir) # log some sysinfo data into the test keyval file keyval = self.log_test_keyvals(test_sysinfodir) test.write_test_keyval(keyval) # log any changes to installed packages old_packages = set(self._installed_packages) new_packages = set(package.list_all()) added_path = os.path.join(test_sysinfodir, "added_packages") added_packages = "\n".join(new_packages - old_packages) + "\n" utils.open_write_close(added_path, added_packages) removed_path = os.path.join(test_sysinfodir, "removed_packages") removed_packages = "\n".join(old_packages - new_packages) + "\n" utils.open_write_close(removed_path, removed_packages)
def log_after_each_test(self, test): """ Logging hook called after a test finishs. """ test_sysinfodir = self._get_sysinfodir(test.outputdir) # create a symlink in the test sysinfo dir to the current boot reboot_dir = self._get_boot_subdir() assert os.path.exists(reboot_dir) symlink_dest = os.path.join(test_sysinfodir, "reboot_current") symlink_src = utils.get_relative_path(reboot_dir, os.path.dirname(symlink_dest)) try: os.symlink(symlink_src, symlink_dest) except Exception, e: raise Exception, "%s: whilst linking %s to %s" % (e, symlink_src, symlink_dest)
def log_after_each_test(self, test): """ Logging hook called after a test finishs. """ test_sysinfodir = self._get_sysinfodir(test.outputdir) # create a symlink in the test sysinfo dir to the current boot reboot_dir = self._get_boot_subdir() assert os.path.exists(reboot_dir) symlink_dest = os.path.join(test_sysinfodir, "reboot_current") symlink_src = utils.get_relative_path(reboot_dir, os.path.dirname(symlink_dest)) try: os.symlink(symlink_src, symlink_dest) except Exception, e: raise Exception, '%s: whilst linking %s to %s' % (e, symlink_src, symlink_dest)