Changeset 79160 in vbox
- Timestamp:
- Jun 16, 2019 8:32:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r79159 r79160 2619 2619 [ tdTestDirCreate(sDirectory = '..' ), tdTestResultFailure() ], 2620 2620 [ tdTestDirCreate(sDirectory = '../' ), tdTestResultFailure() ], 2621 [ tdTestDirCreate(sDirectory = '../..' ), tdTestResultFailure() ], 2621 2622 [ tdTestDirCreate(sDirectory = '../../' ), tdTestResultFailure() ], 2622 2623 [ tdTestDirCreate(sDirectory = 'C:\\' ), tdTestResultFailure() ], 2624 [ tdTestDirCreate(sDirectory = 'C:\\..' ), tdTestResultFailure() ], 2625 [ tdTestDirCreate(sDirectory = 'C:\\..\\' ), tdTestResultFailure() ], 2626 [ tdTestDirCreate(sDirectory = 'C:/' ), tdTestResultFailure() ], 2627 [ tdTestDirCreate(sDirectory = 'C:/.' ), tdTestResultFailure() ], 2628 [ tdTestDirCreate(sDirectory = 'C:/./' ), tdTestResultFailure() ], 2629 [ tdTestDirCreate(sDirectory = 'C:/..' ), tdTestResultFailure() ], 2630 [ tdTestDirCreate(sDirectory = 'C:/../' ), tdTestResultFailure() ], 2623 2631 [ tdTestDirCreate(sDirectory = '\\\\uncrulez\\foo' ), tdTestResultFailure() ], 2632 ]); 2633 else: 2634 atTests.extend([ 2635 [ tdTestDirCreate(sDirectory = '../' ), tdTestResultFailure() ], 2636 [ tdTestDirCreate(sDirectory = '../../' ), tdTestResultFailure() ], 2637 [ tdTestDirCreate(sDirectory = '/' ), tdTestResultFailure() ], 2638 [ tdTestDirCreate(sDirectory = '/..' ), tdTestResultFailure() ], 2639 [ tdTestDirCreate(sDirectory = '/../' ), tdTestResultFailure() ], 2624 2640 ]); 2625 2641 atTests.extend([ … … 2676 2692 """ 2677 2693 2678 atTests = []; 2679 if oTestVm.isWindows(): 2680 atTests.extend([ 2681 # Invalid stuff. 2682 [ tdTestDirCreateTemp(sDirectory = ''), tdTestResultFailure() ], 2683 [ tdTestDirCreateTemp(sDirectory = 'C:\\Windows', fMode = 1234), tdTestResultFailure() ], 2684 [ tdTestDirCreateTemp(sTemplate = '', sDirectory = 'C:\\Windows', fMode = 1234), tdTestResultFailure() ], 2685 [ tdTestDirCreateTemp(sTemplate = 'xXx', sDirectory = 'C:\\Windows', fMode = 0o700), tdTestResultFailure() ], 2686 [ tdTestDirCreateTemp(sTemplate = 'xxx', sDirectory = 'C:\\Windows', fMode = 0o700), tdTestResultFailure() ], 2687 # More unusual stuff. 2688 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = 'z:\\'), tdTestResultFailure() ], 2689 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = '\\\\uncrulez\\foo'), tdTestResultFailure() ], 2690 # Non-existing stuff. 2691 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = 'c:\\Apps\\nonexisting\\foo'), tdTestResultFailure() ], 2692 # FIXME: Failing test. Non Windows path 2693 # [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/tmp/non/existing'), tdTestResultFailure() ] 2694 ]); 2695 elif oTestVm.isLinux(): 2696 atTests.extend([ 2697 # Invalid stuff. 2698 [ tdTestDirCreateTemp(sDirectory = ''), tdTestResultFailure() ], 2699 [ tdTestDirCreateTemp(sDirectory = '/etc', fMode = 1234) ], 2700 [ tdTestDirCreateTemp(sTemplate = '', sDirectory = '/etc', fMode = 1234), tdTestResultFailure() ], 2701 [ tdTestDirCreateTemp(sTemplate = 'xXx', sDirectory = '/etc', fMode = 0o700), tdTestResultFailure() ], 2702 [ tdTestDirCreateTemp(sTemplate = 'xxx', sDirectory = '/etc', fMode = 0o700), tdTestResultFailure() ], 2703 # More unusual stuff. 2704 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = 'z:\\'), tdTestResultFailure() ], 2705 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = '\\\\uncrulez\\foo'), tdTestResultFailure() ], 2706 # Non-existing stuff. 2707 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = '/non/existing'), tdTestResultFailure() ], 2708 ]); 2709 2710 # FIXME: Failing tests. 2711 # atTests.extend([ 2712 # Non-secure variants. 2713 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2714 # sDirectory = sScratch), 2715 # tdTestResultSuccess() ], 2716 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2717 # sDirectory = sScratch), 2718 # tdTestResultSuccess() ], 2719 # [ tdTestDirCreateTemp(sTemplate = 'X', 2720 # sDirectory = sScratch), 2721 # tdTestResultSuccess() ], 2722 # [ tdTestDirCreateTemp(sTemplate = 'X', 2723 # sDirectory = sScratch), 2724 # tdTestResultSuccess() ], 2725 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2726 # sDirectory = sScratch, 2727 # fMode = 0o700), 2728 # tdTestResultSuccess() ], 2729 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2730 # sDirectory = sScratch, 2731 # fMode = 0o700), 2732 # tdTestResultSuccess() ], 2733 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2734 # sDirectory = sScratch, 2735 # fMode = 0o755), 2736 # tdTestResultSuccess() ], 2737 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2738 # sDirectory = sScratch, 2739 # fMode = 0o755), 2740 # tdTestResultSuccess() ], 2741 # Secure variants. 2742 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2743 # sDirectory = sScratch, fSecure = True), 2744 # tdTestResultSuccess() ], 2745 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2746 # sDirectory = sScratch, fSecure = True), 2747 # tdTestResultSuccess() ], 2748 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2749 # sDirectory = sScratch, fSecure = True), 2750 # tdTestResultSuccess() ], 2751 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2752 # sDirectory = sScratch, fSecure = True), 2753 # tdTestResultSuccess() ], 2754 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2755 # sDirectory = sScratch, 2756 # fSecure = True, fMode = 0o700), 2757 # tdTestResultSuccess() ], 2758 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2759 # sDirectory = sScratch, 2760 # fSecure = True, fMode = 0o700), 2761 # tdTestResultSuccess() ], 2762 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2763 # sDirectory = sScratch, 2764 # fSecure = True, fMode = 0o755), 2765 # tdTestResultSuccess() ], 2766 # [ tdTestDirCreateTemp(sTemplate = 'XXX', 2767 # sDirectory = sScratch, 2768 # fSecure = True, fMode = 0o755), 2769 # tdTestResultSuccess() ], 2770 # Random stuff. 2771 # [ tdTestDirCreateTemp( 2772 # sTemplate = "XXX-".join(random.choice(string.ascii_lowercase) for i in xrange(32)), 2773 # sDirectory = sScratch, 2774 # fSecure = True, fMode = 0o755), 2775 # tdTestResultSuccess() ], 2776 # [ tdTestDirCreateTemp(sTemplate = "".join('X' for i in xrange(32)), 2777 # sDirectory = sScratch, 2778 # fSecure = True, fMode = 0o755), 2779 # tdTestResultSuccess() ], 2780 # [ tdTestDirCreateTemp(sTemplate = "".join('X' for i in xrange(128)), 2781 # sDirectory = sScratch, 2782 # fSecure = True, fMode = 0o755), 2783 # tdTestResultSuccess() ] 2784 # ]); 2694 sSystemDir = self.getGuestSystemDir(oTestVm); 2695 atTests = [ 2696 # Invalid stuff (template must have one or more trailin 'X'es (upper case only), or a cluster of three or more). 2697 [ tdTestDirCreateTemp(sDirectory = ''), tdTestResultFailure() ], 2698 [ tdTestDirCreateTemp(sDirectory = sSystemDir, fMode = 1234), tdTestResultFailure() ], 2699 [ tdTestDirCreateTemp(sTemplate = 'xXx', sDirectory = sSystemDir, fMode = 0o700), tdTestResultFailure() ], 2700 [ tdTestDirCreateTemp(sTemplate = 'xxx', sDirectory = sSystemDir, fMode = 0o700), tdTestResultFailure() ], 2701 [ tdTestDirCreateTemp(sTemplate = 'XXx', sDirectory = sSystemDir, fMode = 0o700), tdTestResultFailure() ], 2702 [ tdTestDirCreateTemp(sTemplate = 'bar', sDirectory = 'whatever', fMode = 0o700), tdTestResultFailure() ], 2703 [ tdTestDirCreateTemp(sTemplate = 'foo', sDirectory = 'it is not used', fMode = 0o700), tdTestResultFailure() ], 2704 [ tdTestDirCreateTemp(sTemplate = 'X,so', sDirectory = 'pointless test', fMode = 0o700), tdTestResultFailure() ], 2705 # Non-existing stuff. 2706 [ tdTestDirCreateTemp(sTemplate = 'XXXXXXX', 2707 sDirectory = oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'non', 'existing')), 2708 tdTestResultFailure() ], 2709 # Working stuff: 2710 [ tdTestDirCreateTemp(sTemplate = 'X', sDirectory = self.getGuestTempDir(oTestVm)), tdTestResultFailure() ], 2711 [ tdTestDirCreateTemp(sTemplate = 'XX', sDirectory = self.getGuestTempDir(oTestVm)), tdTestResultFailure() ], 2712 [ tdTestDirCreateTemp(sTemplate = 'XXX', sDirectory = self.getGuestTempDir(oTestVm)), tdTestResultFailure() ], 2713 [ tdTestDirCreateTemp(sTemplate = 'XXXXXXX', sDirectory = self.getGuestTempDir(oTestVm)), tdTestResultFailure() ], 2714 [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.getGuestTempDir(oTestVm)), tdTestResultFailure() ], 2715 [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.getGuestTempDir(oTestVm)), tdTestResultFailure() ], 2716 [ tdTestDirCreateTemp(sTemplate = 'tmpXXXtst', sDirectory = self.getGuestTempDir(oTestVm)), tdTestResultFailure() ], 2717 ## @todo test fSecure and pass weird fMode values once these parameters are implemented in the API. 2718 ]; 2785 2719 2786 2720 fRc = True; 2787 for (i, aTest) in enumerate(atTests):2788 oCurTest = aTest[0]; # tdTestExec, use an index, later.2789 oCurRes = aTest[1]; #tdTestResult2721 for (i, tTest) in enumerate(atTests): 2722 oCurTest = tTest[0] # type: tdTestDirCreateTemp 2723 oCurRes = tTest[1] # type: tdTestResult 2790 2724 reporter.log('Testing #%d, sTemplate="%s", fMode=%#o, path="%s", secure="%s" ...' % 2791 2725 (i, oCurTest.sTemplate, oCurTest.fMode, oCurTest.sDirectory, oCurTest.fSecure)); 2726 2792 2727 oCurTest.setEnvironment(oSession, oTxsSession, oTestVm); 2793 fRc, oCurGuestSession = oCurTest.createSession('testGuestCtrlDirCreateTemp: Test #%d' % (i,) );2728 fRc, oCurGuestSession = oCurTest.createSession('testGuestCtrlDirCreateTemp: Test #%d' % (i,), fIsError = True); 2794 2729 if fRc is False: 2795 reporter.error('Test #%d failed: Could not create session' % (i,));2730 fRc = reporter.error('Test #%d failed: Could not create session' % (i,)); 2796 2731 break; 2797 sDirTemp = ""; 2732 2733 sDirTemp = ''; 2798 2734 try: 2799 2735 sDirTemp = oCurGuestSession.directoryCreateTemp(oCurTest.sTemplate, oCurTest.fMode, 2800 oCurTest.sDirectory, oCurTest.fSecure);2736 oCurTest.sDirectory, oCurTest.fSecure); 2801 2737 except: 2802 2738 if oCurRes.fRc is True: 2803 reporter.errorXcpt('Creating temp directory "%s" failed:' % (oCurTest.sDirectory,)); 2804 fRc = False; 2805 break; 2739 fRc = reporter.errorXcpt('Creating temp directory "%s" failed:' % (oCurTest.sDirectory,)); 2806 2740 else: 2807 2741 reporter.logXcpt('Creating temp directory "%s" failed expectedly, skipping:' % (oCurTest.sDirectory,)); 2808 oCurTest.closeSession(); 2809 if sDirTemp != "": 2810 reporter.log2('Temporary directory is: %s' % (sDirTemp,)); 2811 if self.oTstDrv.fpApiVer >= 5.0: 2812 fExists = oCurGuestSession.directoryExists(sDirTemp, False); 2742 else: 2743 reporter.log2('Temporary directory is: "%s"' % (sDirTemp,)); 2744 if not sDirTemp: 2745 fRc = reporter.error('Resulting directory is empty!'); 2813 2746 else: 2814 fExists = oCurGuestSession.directoryExists(sDirTemp); 2815 if fExists is False: 2816 reporter.error('Test #%d failed: Temporary directory "%s" does not exists' % (i, sDirTemp)); 2817 fRc = False; 2818 break; 2747 ## @todo This does not work for some unknown reason. 2748 #try: 2749 # if self.oTstDrv.fpApiVer >= 5.0: 2750 # fExists = oCurGuestSession.directoryExists(sDirTemp, False); 2751 # else: 2752 # fExists = oCurGuestSession.directoryExists(sDirTemp); 2753 #except: 2754 # fRc = reporter.errorXcpt('sDirTemp=%s' % (sDirTemp,)); 2755 #else: 2756 # if fExists is not True: 2757 # fRc = reporter.error('Test #%d failed: Temporary directory "%s" does not exists (%s)' 2758 # % (i, sDirTemp, fExists)); 2759 try: 2760 oFsObjInfo = oCurGuestSession.fsObjQueryInfo(sDirTemp, False); 2761 eType = oFsObjInfo.type; 2762 except: 2763 fRc = reporter.errorXcpt('sDirTemp="%s"' % (sDirTemp,)); 2764 else: 2765 reporter.log2('%s: eType=%s (dir=%d)' % (sDirTemp, eType, vboxcon.FsObjType_Directory,)); 2766 if eType != vboxcon.FsObjType_Directory: 2767 fRc = reporter.error('Temporary directory not created as a directory: eType=%d' 2768 % (sDirTemp, eType)); 2769 fRc = oCurTest.closeSession(True) and fRc; 2819 2770 return (fRc, oTxsSession); 2820 2771
Note:
See TracChangeset
for help on using the changeset viewer.