- Timestamp:
- Mar 21, 2023 12:43:25 PM (19 months ago)
- Location:
- trunk/src/VBox/ValidationKit
- Files:
-
- 2 edited
-
common/utils.py (modified) (3 diffs)
-
testdriver/base.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/common/utils.py
r98931 r99086 1460 1460 # Some other useful locations as fallback. 1461 1461 asDmpDirs.extend([ 1462 u'/var/cores/', 1463 u'/var/core/', 1462 u'/var/cores/' 1464 1463 ]); 1465 1464 # … … 1469 1468 # the host needs to be tweaked via: 1470 1469 # 1471 # ```coreadm -g / path/to/cores/core.%f.%p```1470 # ```coreadm -g /var/cores/core.%f.%p``` 1472 1471 # 1473 sMatch Suffix = '.%u.core' % (uPid,);1472 sMatchRegEx = r'core\..*\.%u' % (uPid); 1474 1473 for sDir in asDmpDirs: 1475 1474 sDir = os.path.expandvars(sDir); … … 1482 1481 for sEntry in asDirEntries: 1483 1482 fnLog('Entry: %s' % (os.path.join(sDir, sEntry))); 1484 if sEntry.endswith(sMatchSuffix):1483 if re.search(sMatchRegEx, sEntry): 1485 1484 sFull = os.path.join(sDir, sEntry); 1486 1485 fnLog('Found crash dump for %u: %s' % (uPid, sFull,)); -
trunk/src/VBox/ValidationKit/testdriver/base.py
r98655 r99086 717 717 self.sKindCrashDump = sKindCrashDump; 718 718 719 sCorePath = None;720 719 sOs = utils.getHostOs(); 721 720 if sOs == 'solaris': 722 if sKindCrashDump is not None: # Enable. 723 sCorePath = getDirEnv('TESTBOX_PATH_SCRATCH', sAlternative = '/var/cores', fTryCreate = False); 724 (iExitCode, _, sErr) = utils.processOutputUnchecked([ 'coreadm', '-e', 'global', '-e', 'global-setid', \ 725 '-e', 'process', '-e', 'proc-setid', \ 726 '-g', os.path.join(sCorePath, '%f.%p.core')]); 727 else: # Disable. 728 (iExitCode, _, sErr) = utils.processOutputUnchecked([ 'coreadm', \ 729 '-d', 'global', '-d', 'global-setid', \ 730 '-d', 'process', '-d', 'proc-setid' ]); 731 if iExitCode != 0: # Don't report an actual error, just log this. 732 reporter.log('%s coreadm failed: %s' % ('Enabling' if sKindCrashDump else 'Disabling', sErr)); 733 734 if sKindCrashDump is not None: 735 if sCorePath is not None: 736 reporter.log('Crash dumps enabled -- path is "%s"' % (sCorePath,)); 737 else: 738 reporter.log('Crash dumps disabled'); 721 # Both 'coreadm -e ...' and 'svccfg apply' only work if running with all privileges. 722 fIsRoot = os.getuid() == 0; 723 if fIsRoot is False: 724 return True; 725 726 sScratchPath = os.environ.get('TESTBOX_PATH_SCRATCH', '/var/tmp'); 727 sCoreadmXmlFile = os.path.join(sScratchPath, 'coreadm.xml'); 728 if sKindCrashDump is not None: 729 # If the current core file configuration has been modified from the system default 730 # then save the configuration to coreadm.xml so it can be restored afterwards. 731 (iExitCode, sStdOut, sStdErr) = utils.processOutputUnchecked([ 'svcprop', '-p', 'config_params', \ 732 '-l', 'admin', 'svc:/system/coreadm:default' ]); 733 if iExitCode == 0 and sStdOut != '': 734 (iExitCode, _, sStdErr) = utils.processOutputUnchecked([ 'svccfg', 'extract', '-l', 'admin', \ 735 'svc:/system/coreadm:default', '>', \ 736 sCoreadmXmlFile ]); 737 # Annoyingly svccfg(1M) returns zero for both success and failure but if the 738 # command fails errors are written to stderr. 739 if iExitCode != 0 or sStdErr != '': 740 reporter.error('Failed to backup current system-wide core dump configuration: %s' % sStdErr); 741 return False; 742 743 # Configure all core dumps, including those of setuid and setgid binaries, to be 744 # written to /var/cores using the naming pattern of core.argv0.process-ID, e.g. 745 # core.VBoxSVC.12345. 746 (iExitCode, _, sStdErr) = utils.processOutputUnchecked([ 'coreadm', '-e', 'global', '-e', 'global-setid', \ 747 '-e', 'log', '-G', 'all', \ 748 '-g', '/var/cores/core.%f.%p' ]); 749 if iExitCode != 0: 750 reporter.error('Failed to update system-wide core dump configuration: %s' % sStdErr); 751 return False; 752 753 reporter.log('Core file configuration successfully updated: All core files will be written to /var/cores.'); 754 else: 755 # Restore the core file configuration to what it was before making the 756 # changes above. 757 (iExitCode, _, sStdErr) = utils.processOutputUnchecked([ 'svccfg', '-s', 'svc:/system/coreadm:default', \ 758 'delcust' ]); 759 # Annoyingly svccfg(1M) returns zero for both success and failure but if the 760 # command fails errors are written to stderr. 761 if sStdErr == '' and os.path.exists(sCoreadmXmlFile): 762 (iExitCode, _, sStdErr) = utils.processOutputUnchecked([ 'svccfg', 'apply', sCoreadmXmlFile ]); 763 764 if sStdErr != '': 765 reporter.error('Failed to restore system-wide core dump configuration: %s' % sStdErr); 766 return False; 767 768 reporter.log('Core file configuration successfully restored to previous state.'); 739 769 740 770 return True;
Note:
See TracChangeset
for help on using the changeset viewer.

