Changeset 77501 in vbox for trunk/src/VBox/ValidationKit/tests
- Timestamp:
- Feb 28, 2019 11:17:30 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 129097
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r77480 r77501 2026 2026 ## @todo Add task which gets killed at some random time while letting the guest output something. 2027 2027 ]; 2028 2029 # Manual test, not executed automatically. 2030 aaManual = [ 2031 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '/C', 'dir /S C:\\Windows' ], 2032 sUser = sUser, sPassword = sPassword, 2033 aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), 2034 tdTestResultExec(fRc = True, cbStdOut = 497917) ] ]; 2028 elif oTestVm.isLinux(): 2029 sVBoxControl = "/usr/bin/VBoxControl"; # Symlink 2030 aaExec = [ 2031 # Basic executon. 2032 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls', '/R', 'etc' ], 2033 sUser = sUser, sPassword = sPassword), 2034 tdTestResultExec(fRc = True) ], 2035 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls /bin/sh' ], 2036 sUser = sUser, sPassword = sPassword), 2037 tdTestResultExec(fRc = True) ], 2038 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '--wrong-parameter' ], 2039 sUser = sUser, sPassword = sPassword), 2040 tdTestResultExec(fRc = True, iExitCode = 2) ], 2041 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls /non/existent' ], 2042 sUser = sUser, sPassword = sPassword), 2043 tdTestResultExec(fRc = True, iExitCode = 2) ], 2044 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls /bin/sh /wrongparam' ], 2045 sUser = sUser, sPassword = sPassword), 2046 tdTestResultExec(fRc = True, iExitCode = 2) ], 2047 # Paths with spaces. 2048 ## @todo Get path of installed Guest Additions. Later. 2049 [ tdTestExec(sCmd = sVBoxControl, aArgs = [ sVBoxControl, 'version' ], 2050 sUser = sUser, sPassword = sPassword), 2051 tdTestResultExec(fRc = True) ], 2052 # StdOut. 2053 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls /etc' ], 2054 sUser = sUser, sPassword = sPassword), 2055 tdTestResultExec(fRc = True) ], 2056 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls stdout-non-existing' ], 2057 sUser = sUser, sPassword = sPassword), 2058 tdTestResultExec(fRc = True, iExitCode = 2) ], 2059 # StdErr. 2060 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls /etc' ], 2061 sUser = sUser, sPassword = sPassword), 2062 tdTestResultExec(fRc = True) ], 2063 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls stderr-non-existing' ], 2064 sUser = sUser, sPassword = sPassword), 2065 tdTestResultExec(fRc = True, iExitCode = 2) ], 2066 # StdOut + StdErr. 2067 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls /etc' ], 2068 sUser = sUser, sPassword = sPassword), 2069 tdTestResultExec(fRc = True) ], 2070 [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '-c', 'ls stdouterr-non-existing' ], 2071 sUser = sUser, sPassword = sPassword), 2072 tdTestResultExec(fRc = True, iExitCode = 2) ] 2073 # FIXME: Failing tests. 2074 # Environment variables. 2075 # [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '/C', 'set', 'TEST_NONEXIST' ], 2076 # sUser = sUser, sPassword = sPassword), 2077 # tdTestResultExec(fRc = True, iExitCode = 1) ] 2078 # [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '/C', 'set', 'windir' ], 2079 # sUser = sUser, sPassword = sPassword, 2080 # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), 2081 # tdTestResultExec(fRc = True, sBuf = 'windir=C:\\WINDOWS\r\n') ], 2082 # [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '/C', 'set', 'TEST_FOO' ], 2083 # sUser = sUser, sPassword = sPassword, 2084 # aEnv = [ 'TEST_FOO=BAR' ], 2085 # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), 2086 # tdTestResultExec(fRc = True, sBuf = 'TEST_FOO=BAR\r\n') ], 2087 # [ tdTestExec(sCmd = sImageOut, aArgs = [ sImageOut, '/C', 'set', 'TEST_FOO' ], 2088 # sUser = sUser, sPassword = sPassword, 2089 # aEnv = [ 'TEST_FOO=BAR', 'TEST_BAZ=BAR' ], 2090 # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), 2091 # tdTestResultExec(fRc = True, sBuf = 'TEST_FOO=BAR\r\n') ] 2092 2093 ## @todo Create some files (or get files) we know the output size of to validate output length! 2094 ## @todo Add task which gets killed at some random time while letting the guest output something. 2095 ]; 2035 2096 else: 2036 2097 reporter.log('No OS-specific tests for non-Windows yet!'); … … 2042 2103 aaTests.extend(aaExec); 2043 2104 fRc = True; 2044 2045 #2046 # Single execution stuff. Nice for debugging.2047 #2048 fManual = False;2049 if fManual:2050 curTest = aaTests[1][0]; # tdTestExec, use an index, later.2051 curRes = aaTests[1][1]; # tdTestResultExec2052 curTest.setEnvironment(oSession, oTxsSession, oTestVm);2053 fRc, curGuestSession = curTest.createSession('testGuestCtrlExec: Single test 1');2054 if fRc is False:2055 reporter.error('Single test failed: Could not create session');2056 else:2057 fRc = self.gctrlExecDoTest(0, curTest, curRes, curGuestSession);2058 curTest.closeSession();2059 2060 curTest = aaTests[2][0]; # tdTestExec, use an index, later.2061 curRes = aaTests[2][1]; # tdTestResultExec2062 curTest.setEnvironment(oSession, oTxsSession, oTestVm);2063 fRc, curGuestSession = curTest.createSession('testGuestCtrlExec: Single test 2');2064 if fRc is False:2065 reporter.error('Single test failed: Could not create session');2066 else:2067 fRc = self.gctrlExecDoTest(0, curTest, curRes, curGuestSession);2068 curTest.closeSession();2069 2070 curTest = aaTests[3][0]; # tdTestExec, use an index, later.2071 curRes = aaTests[3][1]; # tdTestResultExec2072 curTest.setEnvironment(oSession, oTxsSession, oTestVm);2073 fRc, curGuestSession = curTest.createSession('testGuestCtrlExec: Single test 3');2074 if fRc is False:2075 reporter.error('Single test failed: Could not create session');2076 else:2077 fRc = self.gctrlExecDoTest(0, curTest, curRes, curGuestSession);2078 curTest.closeSession();2079 return (fRc, oTxsSession);2080 else:2081 aaManual = aaManual; # Workaround for pylint #W0612.2082 2105 2083 2106 if fRc is False: … … 2251 2274 ## @todo Test stdin! 2252 2275 ]); 2253 else: 2254 reporter.log('No OS-specific tests for non-Windows yet!'); 2276 elif oTestVm.isLinux(): 2277 aaTests.extend([ 2278 # Simple. 2279 [ tdTestExec(sCmd = sImage, aArgs = [ sImage, '-c', 'wrongcommand' ], 2280 sUser = sUser, sPassword = sPassword), 2281 tdTestResultExec(fRc = True, iExitCode = 127) ], 2282 [ tdTestExec(sCmd = sImage, aArgs = [ sImage, '-c', 'exit 22' ], 2283 sUser = sUser, sPassword = sPassword), 2284 tdTestResultExec(fRc = True, iExitCode = 22) ], 2285 [ tdTestExec(sCmd = sImage, aArgs = [ sImage, '-c', 'echo $PWD' ], 2286 sUser = sUser, sPassword = sPassword), 2287 tdTestResultExec(fRc = True, iExitCode = 0) ], 2288 [ tdTestExec(sCmd = sImage, aArgs = [ sImage, '-c', 'export MY_ERRORLEVEL=0' ], 2289 sUser = sUser, sPassword = sPassword), 2290 tdTestResultExec(fRc = True, iExitCode = 0) ], 2291 [ tdTestExec(sCmd = sImage, aArgs = [ sImage, '-c', 'ls /etc' ], 2292 sUser = sUser, sPassword = sPassword), 2293 tdTestResultExec(fRc = True, iExitCode = 0) ], 2294 [ tdTestExec(sCmd = sImage, aArgs = [ sImage, '-c', 'ls /bin/sh' ], 2295 sUser = sUser, sPassword = sPassword), 2296 tdTestResultExec(fRc = True, iExitCode = 0) ], 2297 [ tdTestExec(sCmd = sImage, aArgs = [ sImage, '-c', 'ls /non/existing/file' ], 2298 sUser = sUser, sPassword = sPassword), 2299 tdTestResultExec(fRc = True, iExitCode = 2) ], 2300 [ tdTestExec(sCmd = sImage, aArgs = [ sImage, '-c', 'ls /non/existing/dir/' ], 2301 sUser = sUser, sPassword = sPassword), 2302 tdTestResultExec(fRc = True, iExitCode = 2) ] 2303 ]); 2255 2304 2256 2305 fRc = True; … … 2376 2425 2377 2426 aaTests = []; 2378 if oTestVm.isWindows(): 2379 aaTests.extend([ 2380 # Invalid stuff. 2381 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = '' ), 2382 tdTestResult(fRc = False) ], 2383 # More unusual stuff. 2384 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = '..\\..\\' ), 2385 tdTestResult(fRc = False) ], 2386 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = '../../' ), 2387 tdTestResult(fRc = False) ], 2388 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = 'z:\\' ), 2389 tdTestResult(fRc = False) ], 2390 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = '\\\\uncrulez\\foo' ), 2391 tdTestResult(fRc = False) ], 2392 # Creating directories. 2393 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = sScratch ), 2394 tdTestResult(fRc = False) ], 2395 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = os.path.join(sScratch, 'foo\\bar\\baz'), 2396 aFlags = [ vboxcon.DirectoryCreateFlag_Parents ] ), 2397 tdTestResult(fRc = True) ], 2398 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = os.path.join(sScratch, 'foo\\bar\\baz'), 2399 aFlags = [ vboxcon.DirectoryCreateFlag_Parents ] ), 2400 tdTestResult(fRc = True) ], 2401 # Long (+ random) stuff. 2402 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, 2403 sDirectory = os.path.join(sScratch, 2404 "".join(random.choice(string.ascii_lowercase) for i in range(32))) ), 2405 tdTestResult(fRc = True) ], 2406 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, 2407 sDirectory = os.path.join(sScratch, 2408 "".join(random.choice(string.ascii_lowercase) for i in range(128))) ), 2409 tdTestResult(fRc = True) ], 2410 # Following two should fail on Windows (paths too long). Both should timeout. 2411 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, 2412 sDirectory = os.path.join(sScratch, 2413 "".join(random.choice(string.ascii_lowercase) for i in range(255))) ), 2414 tdTestResult(fRc = False) ], 2415 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, 2416 sDirectory = os.path.join(sScratch, 2417 "".join(random.choice(string.ascii_lowercase) for i in range(1024))) 2418 ), 2419 tdTestResult(fRc = False) ] 2420 ]); 2421 else: 2422 reporter.log('No OS-specific tests for non-Windows yet!'); 2427 aaTests.extend([ 2428 # Invalid stuff. 2429 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = '' ), 2430 tdTestResult(fRc = False) ], 2431 # More unusual stuff. 2432 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = '..\\..\\' ), 2433 tdTestResult(fRc = False) ], 2434 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = '../../' ), 2435 tdTestResult(fRc = False) ], 2436 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = 'z:\\' ), 2437 tdTestResult(fRc = False) ], 2438 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = '\\\\uncrulez\\foo' ), 2439 tdTestResult(fRc = False) ], 2440 # Creating directories. 2441 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = sScratch ), 2442 tdTestResult(fRc = False) ], 2443 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = os.path.join(sScratch, 'foo\\bar\\baz'), 2444 aFlags = [ vboxcon.DirectoryCreateFlag_Parents ] ), 2445 tdTestResult(fRc = True) ], 2446 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, sDirectory = os.path.join(sScratch, 'foo\\bar\\baz'), 2447 aFlags = [ vboxcon.DirectoryCreateFlag_Parents ] ), 2448 tdTestResult(fRc = True) ], 2449 # Long (+ random) stuff. 2450 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, 2451 sDirectory = os.path.join(sScratch, 2452 "".join(random.choice(string.ascii_lowercase) for i in range(32))) ), 2453 tdTestResult(fRc = True) ], 2454 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, 2455 sDirectory = os.path.join(sScratch, 2456 "".join(random.choice(string.ascii_lowercase) for i in range(128))) ), 2457 tdTestResult(fRc = True) ], 2458 # Following two should fail on Windows (paths too long). Both should timeout. 2459 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, 2460 sDirectory = os.path.join(sScratch, 2461 "".join(random.choice(string.ascii_lowercase) for i in range(255))) ), 2462 tdTestResult(fRc = not oTestVm.isWindows()) ], 2463 [ tdTestDirCreate(sUser = sUser, sPassword = sPassword, 2464 sDirectory = os.path.join(sScratch, 2465 "".join(random.choice(string.ascii_lowercase) for i in range(255))) 2466 ), 2467 tdTestResult(fRc = not oTestVm.isWindows()) ] 2468 ]); 2423 2469 2424 2470 fRc = True; … … 2486 2532 # tdTestResult(fRc = False) ] 2487 2533 ]); 2488 else: 2489 reporter.log('No OS-specific tests for non-Windows yet!'); 2534 elif oTestVm.isLinux(): 2535 aaTests.extend([ 2536 # Invalid stuff. 2537 [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sDirectory = ''), 2538 tdTestResult(fRc = False) ], 2539 [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sDirectory = '/etc', 2540 fMode = 1234), 2541 tdTestResult(fRc = False) ], 2542 [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = '', 2543 sDirectory = '/etc', fMode = 1234), 2544 tdTestResult(fRc = False) ], 2545 [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'xXx', 2546 sDirectory = '/etc', fMode = 0o700), 2547 tdTestResult(fRc = False) ], 2548 [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'xxx', 2549 sDirectory = '/etc', fMode = 0o700), 2550 tdTestResult(fRc = False) ], 2551 # More unusual stuff. 2552 [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'foo', 2553 sDirectory = 'z:\\'), 2554 tdTestResult(fRc = False) ], 2555 [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'foo', 2556 sDirectory = '\\\\uncrulez\\foo'), 2557 tdTestResult(fRc = False) ], 2558 # Non-existing stuff. 2559 [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'bar', 2560 sDirectory = '/non/existing'), 2561 tdTestResult(fRc = False) ] 2562 ]); 2490 2563 2491 2564 # FIXME: Failing tests. … … 2643 2716 tdTestResultDirRead(fRc = True, numDirs = 3, numFiles = 49) ] 2644 2717 ]); 2645 else: 2646 reporter.log('No OS-specific tests for non-Windows yet!'); 2718 elif oTestVm.isLinux(): 2719 aaTests.extend([ 2720 # Invalid stuff. 2721 [ tdTestDirRead(sUser = sUser, sPassword = sPassword, sDirectory = ''), 2722 tdTestResultDirRead(fRc = False) ], 2723 [ tdTestDirRead(sUser = sUser, sPassword = sPassword, sDirectory = '/etc', aFlags = [ 1234 ]), 2724 tdTestResultDirRead(fRc = False) ], 2725 [ tdTestDirRead(sUser = sUser, sPassword = sPassword, sDirectory = '/etc', sFilter = '*.foo'), 2726 tdTestResultDirRead(fRc = False) ], 2727 # More unusual stuff. 2728 [ tdTestDirRead(sUser = sUser, sPassword = sPassword, sDirectory = 'z:/'), 2729 tdTestResultDirRead(fRc = False) ], 2730 [ tdTestDirRead(sUser = sUser, sPassword = sPassword, sDirectory = '\\\\uncrulez\\foo'), 2731 tdTestResultDirRead(fRc = False) ], 2732 # Non-existing stuff. 2733 [ tdTestDirRead(sUser = sUser, sPassword = sPassword, sDirectory = '/etc/non/existing'), 2734 tdTestResultDirRead(fRc = False) ] 2735 ]); 2647 2736 2648 2737 fRc = True; … … 2680 2769 if oTestVm.isWindows(): 2681 2770 sUser = "Administrator"; 2771 sFileToDelete = "c:\\Windows\\Media\\chord.wav"; 2682 2772 else: 2683 2773 sUser = "vbox"; 2774 sFileToDelete = "/home/vbox/.profile"; 2684 2775 sPassword = "password"; 2685 2776 … … 2689 2780 # Invalid stuff. 2690 2781 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = ''), 2691 tdTestResult(fRc = False) ],2692 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'C:\\Windows'),2693 2782 tdTestResult(fRc = False) ], 2694 2783 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'C:\\Windows'), … … 2702 2791 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'c:\\Apps\\nonexisting'), 2703 2792 tdTestResult(fRc = False) ], 2704 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'c:\\Apps\\testFileRemove'),2705 tdTestResult(fRc = False) ],2706 2793 # Try to delete system files. 2707 2794 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'c:\\pagefile.sys'), … … 2718 2805 # Second attempt should fail. 2719 2806 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'c:\\Windows\\Media\\chimes.wav'), 2720 tdTestResult(fRc = False) ],2721 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'c:\\Windows\\Media\\chord.wav'),2722 tdTestResult(fRc = True) ],2723 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'c:\\Windows\\Media\\chord.wav'),2724 2807 tdTestResult(fRc = False) ] 2725 2808 ]); 2726 else: 2727 reporter.log('No OS-specific tests for non-Windows yet!'); 2809 elif oTestVm.isLinux(): 2810 aaTests.extend([ 2811 # Invalid stuff. 2812 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = ''), 2813 tdTestResult(fRc = False) ], 2814 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'C:\\Windows'), 2815 tdTestResult(fRc = False) ], 2816 # More unusual stuff. 2817 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = 'z:/'), 2818 tdTestResult(fRc = False) ], 2819 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = '//uncrulez/foo'), 2820 tdTestResult(fRc = False) ], 2821 # Non-existing stuff. 2822 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = '/non/existing'), 2823 tdTestResult(fRc = False) ], 2824 # Try to delete system files. 2825 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = '/etc'), 2826 tdTestResult(fRc = False) ], 2827 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = '/bin/sh'), 2828 tdTestResult(fRc = False) ] 2829 ]); 2830 2831 aaTests.extend([ 2832 # Try delete some unimportant stuff. 2833 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = sFileToDelete), 2834 tdTestResult(fRc = True) ], 2835 # Second attempt should fail. 2836 [ tdTestFileRemove(sUser = sUser, sPassword = sPassword, sFile = sFileToDelete), 2837 tdTestResult(fRc = False) ] 2838 ]); 2728 2839 2729 2840 fRc = True; … … 2923 3034 cbProcessed = 31, cbOffset = 17769 + 31) ] 2924 3035 ]); 3036 elif oTestVm.isLinux(): 3037 aaTests.extend([ 3038 # Create a file which must not exist (but it hopefully does). 3039 [ tdTestFileReadWrite(sUser = sUser, sPassword = sPassword, sFile = '/etc/issue', \ 3040 sOpenMode = 'w', sDisposition = 'ce'), 3041 tdTestResultFileReadWrite(fRc = False) ], 3042 # Open a file which must exist. 3043 [ tdTestFileReadWrite(sUser = sUser, sPassword = sPassword, sFile = '/etc/issue', \ 3044 sOpenMode = 'r', sDisposition = 'oe'), 3045 tdTestResultFileReadWrite(fRc = True) ], 3046 # Try truncating a file which already is opened with a different sharing mode (and thus should fail). 3047 [ tdTestFileReadWrite(sUser = sUser, sPassword = sPassword, sFile = '/etc/issue', \ 3048 sOpenMode = 'w', sDisposition = 'ot'), 3049 tdTestResultFileReadWrite(fRc = False) ] 3050 ]); 2925 3051 2926 3052 fRc = True; … … 3011 3137 if oTestVm.isWindows(): 3012 3138 sScratch = "C:\\Temp\\vboxtest\\testGuestCtrlFileWrite\\"; 3139 else: 3140 sScratch = "/tmp/"; 3013 3141 3014 3142 if oTxsSession.syncMkDir('${SCRATCH}/testGuestCtrlFileWrite') is False: … … 3158 3286 else: 3159 3287 sUser = "vbox"; 3160 sScratchGst = "/tmp/ testGuestCtrlCopyTo/";3288 sScratchGst = "/tmp/"; ## @todo Use "${SCRATCH}/testGuestCtrlCopyTo" as soon as TXS CHMOD is implemented. 3161 3289 sScratchGstNotExist = "/tmp/does-not-exist/"; 3162 3290 sScratchGstInvalid = "/"; … … 3182 3310 3183 3311 aaTests = []; 3184 if oTestVm.isWindows(): 3312 aaTests.extend([ 3313 # Destination missing. 3314 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = ''), 3315 tdTestResult(fRc = False) ], 3316 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = '/placeholder', 3317 aFlags = [ 80 ] ), 3318 tdTestResult(fRc = False) ], 3319 # Source missing. 3320 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sDst = ''), 3321 tdTestResult(fRc = False) ], 3322 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sDst = '/placeholder', 3323 aFlags = [ 80 ] ), 3324 tdTestResult(fRc = False) ], 3325 # Testing DirectoryCopyFlag flags. 3326 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3327 sDst = sScratchGstInvalid, aFlags = [ 80 ] ), 3328 tdTestResult(fRc = False) ], 3329 # Testing FileCopyFlag flags. 3330 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3331 sDst = sScratchGstInvalid, aFlags = [ 80 ] ), 3332 tdTestResult(fRc = False) ], 3333 # Nothing to copy (source and/or destination is empty). 3334 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = 'z:\\'), 3335 tdTestResult(fRc = False) ], 3336 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = '\\\\uncrulez\\foo'), 3337 tdTestResult(fRc = False) ], 3338 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = 'non-exist', 3339 sDst = os.path.join(sScratchGst, 'non-exist.dll')), 3340 tdTestResult(fRc = False) ] 3341 ]); 3342 3343 # 3344 # Single file handling. 3345 # 3346 if self.oTstDrv.fpApiVer > 5.2: 3185 3347 aaTests.extend([ 3186 # Destination missing.3187 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = ''),3348 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3349 sDst = sScratchGstInvalid), 3188 3350 tdTestResult(fRc = False) ], 3189 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = '/placeholder',3190 aFlags = [ 80 ]),3351 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3352 sDst = sScratchGstNotExist), 3191 3353 tdTestResult(fRc = False) ], 3192 # Source missing.3193 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sDst = ''),3354 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3355 sDst = sScratchGstNotExist), 3194 3356 tdTestResult(fRc = False) ], 3195 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, s Dst = '/placeholder',3196 aFlags = [ 80 ]),3357 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3358 sDst = os.path.join(sScratchGstNotExist, 'renamedfile.dll')), 3197 3359 tdTestResult(fRc = False) ], 3198 # Testing DirectoryCopyFlag flags.3199 3360 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3200 sDst = sScratchGstInvalid, aFlags = [ 80 ] ), 3201 tdTestResult(fRc = False) ], 3202 # Testing FileCopyFlag flags. 3361 sDst = os.path.join(sScratchGst, 'HostGABig.dat')), 3362 tdTestResult(fRc = True) ], 3203 3363 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3204 sDst = sScratchGstInvalid, aFlags = [ 80 ] ), 3205 tdTestResult(fRc = False) ], 3206 # Nothing to copy (source and/or destination is empty). 3207 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = 'z:\\'), 3208 tdTestResult(fRc = False) ], 3209 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = '\\\\uncrulez\\foo'), 3210 tdTestResult(fRc = False) ], 3211 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = 'non-exist', 3212 sDst = os.path.join(sScratchGst, 'non-exist.dll')), 3213 tdTestResult(fRc = False) ] 3364 sDst = os.path.join(sScratchGst, 'HostGABig.dat')), 3365 tdTestResult(fRc = True) ], 3366 # Note: Copying files into directories via Main is supported only in versions > 5.2. 3367 # Destination is a directory. 3368 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3369 sDst = sScratchGst), 3370 tdTestResult(fRc = True) ], 3371 # Copy over file again into same directory (overwrite). 3372 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3373 sDst = sScratchGst), 3374 tdTestResult(fRc = True) ] 3214 3375 ]); 3215 3376 3216 # 3217 # Single file handling. 3218 # 3219 if self.oTstDrv.fpApiVer > 5.2: 3220 aaTests.extend([ 3221 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3222 sDst = sScratchGstInvalid), 3223 tdTestResult(fRc = False) ], 3224 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3225 sDst = sScratchGstNotExist), 3226 tdTestResult(fRc = False) ], 3227 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3228 sDst = sScratchGstNotExist), 3229 tdTestResult(fRc = False) ], 3230 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3231 sDst = os.path.join(sScratchGstNotExist, 'renamedfile.dll')), 3232 tdTestResult(fRc = False) ], 3233 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3234 sDst = os.path.join(sScratchGst, 'HostGABig.dat')), 3235 tdTestResult(fRc = True) ], 3236 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3237 sDst = os.path.join(sScratchGst, 'HostGABig.dat')), 3238 tdTestResult(fRc = True) ], 3239 # Note: Copying files into directories via Main is supported only in versions > 5.2. 3240 # Destination is a directory. 3241 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3242 sDst = sScratchGst), 3243 tdTestResult(fRc = True) ], 3244 # Copy over file again into same directory (overwrite). 3245 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3246 sDst = sScratchGst), 3247 tdTestResult(fRc = True) ] 3248 ]); 3249 3377 if oTestVm.isWindows(): 3250 3378 aaTests.extend([ 3251 3379 # Copy the same file over to the guest, but this time store the file into the former 3252 3380 # file's ADS (Alternate Data Stream). Only works on Windows, of course. 3253 3381 [ tdTestCopyTo(sUser = sUser, sPassword = sPassword, sSrc = sTestFileBig, 3254 sDst = os.path.join(sScratchGst, 'HostGABig.dat:ADS-Test')),3382 sDst = os.path.join(sScratchGst, 'HostGABig.dat:ADS-Test')), 3255 3383 tdTestResult(fRc = True) ] 3256 3384 ]); … … 3276 3404 tdTestResult(fRc = True) ] 3277 3405 ]); 3278 else:3279 reporter.log('No OS-specific tests for non-Windows yet!');3280 3406 3281 3407 fRc = True; … … 3332 3458 if oTestVm.isWindows(): 3333 3459 sUser = "Administrator"; 3460 sPathSep = "\\"; 3461 sSrcDirExisting = "C:\\Windows\\Web"; 3462 sSrcFileExisting = "C:\\Windows\\system32\\ole32.dll"; 3334 3463 else: 3335 3464 sUser = "vbox"; 3465 sPathSep = "/"; 3466 sSrcDirExisting = "/bin"; 3467 sSrcFileExisting = "/etc/issue"; 3336 3468 sPassword = "password"; 3337 3469 … … 3356 3488 3357 3489 aaTests = []; 3358 if oTestVm.isWindows(): 3490 aaTests.extend([ 3491 # Destination missing. 3492 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = ''), 3493 tdTestResult(fRc = False) ], 3494 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'Something', 3495 aFlags = [ 80 ] ), 3496 tdTestResult(fRc = False) ], 3497 # Source missing. 3498 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sDst = ''), 3499 tdTestResult(fRc = False) ], 3500 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sDst = 'Something', 3501 aFlags = [ 80 ] ), 3502 tdTestResult(fRc = False) ], 3503 # Testing DirectoryCopyFlag flags. 3504 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcDirExisting, 3505 sDst = sScratchHstInvalid, aFlags = [ 80 ] ), 3506 tdTestResult(fRc = False) ], 3507 # Testing FileCopyFlag flags. 3508 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcFileExisting, 3509 sDst = sScratchHstInvalid, aFlags = [ 80 ] ), 3510 tdTestResult(fRc = False) ], 3511 # Nothing to copy (sDst is empty / unreachable). 3512 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'z:\\'), 3513 tdTestResult(fRc = False) ], 3514 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = '\\\\uncrulez\\foo'), 3515 tdTestResult(fRc = False) ], 3516 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'non-exist', 3517 sDst = os.path.join(sScratchHst, 'non-exist')), 3518 tdTestResult(fRc = False) ] 3519 ]); 3520 3521 # 3522 # Single file handling. 3523 # 3524 if self.oTstDrv.fpApiVer > 5.2: 3525 reporter.log(("Single file handling")); 3359 3526 aaTests.extend([ 3360 # Destination missing. 3361 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = ''), 3527 # Copying single files. 3528 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcFileExisting, 3529 sDst = sScratchHstInvalid), 3362 3530 tdTestResult(fRc = False) ], 3363 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'Something',3364 aFlags = [ 80 ]),3531 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcFileExisting, 3532 sDst = os.path.join(sScratchHstInvalid, 'tstCopyFrom-renamedfile')), 3365 3533 tdTestResult(fRc = False) ], 3366 # Source missing. 3367 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sDst = ''), 3368 tdTestResult(fRc = False) ], 3369 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sDst = 'Something', 3370 aFlags = [ 80 ] ), 3371 tdTestResult(fRc = False) ], 3372 # Testing DirectoryCopyFlag flags. 3373 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32', 3374 sDst = sScratchHstInvalid, aFlags = [ 80 ] ), 3375 tdTestResult(fRc = False) ], 3376 # Testing FileCopyFlag flags. 3377 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll', 3378 sDst = sScratchHstInvalid, aFlags = [ 80 ] ), 3379 tdTestResult(fRc = False) ], 3380 # Nothing to copy (sDst is empty / unreachable). 3381 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'z:\\'), 3382 tdTestResult(fRc = False) ], 3383 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = '\\\\uncrulez\\foo'), 3384 tdTestResult(fRc = False) ], 3385 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'non-exist', 3386 sDst = os.path.join(sScratchHst, 'non-exist.dll')), 3534 # Copy over file using a different destination name. 3535 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcFileExisting, 3536 sDst = os.path.join(sScratchHst, 'tstCopyFrom-renamedfile')), 3537 tdTestResult(fRc = True) ], 3538 # Copy over same file (and overwrite existing one). 3539 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcFileExisting, 3540 sDst = os.path.join(sScratchHst, 'tstCopyFrom-renamedfile')), 3541 tdTestResult(fRc = True) ], 3542 # Note: Copying files into directories via Main is supported only in versions > 5.2. 3543 # Destination is a directory with a trailing slash (should work). 3544 # See "cp" syntax. 3545 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcFileExisting, 3546 sDst = sScratchHst + "/"), 3547 tdTestResult(fRc = True) ], 3548 # Destination is a directory (without a trailing slash, should also work). 3549 # See "cp" syntax. 3550 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcFileExisting, 3551 sDst = sScratchHst), 3552 tdTestResult(fRc = True) ], 3553 # Destination is a non-existing directory. 3554 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcFileExisting, 3555 sDst = sScratchHstNotExist), 3387 3556 tdTestResult(fRc = False) ] 3388 3557 ]); 3389 3390 #3391 # Single file handling.3392 #3393 if self.oTstDrv.fpApiVer > 5.2:3394 aaTests.extend([3395 # Copying single files.3396 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll',3397 sDst = sScratchHstInvalid),3398 tdTestResult(fRc = False) ],3399 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll',3400 sDst = os.path.join(sScratchHstInvalid, 'renamedfile.dll')),3401 tdTestResult(fRc = False) ],3402 # Copy over file using a different destination name.3403 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll',3404 sDst = os.path.join(sScratchHst, 'renamedfile.dll')),3405 tdTestResult(fRc = True) ],3406 # Copy over same file (and overwrite existing one).3407 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll',3408 sDst = os.path.join(sScratchHst, 'renamedfile.dll')),3409 tdTestResult(fRc = True) ],3410 # Note: Copying files into directories via Main is supported only in versions > 5.2.3411 # Destination is a directory with a trailing slash (should work).3412 # See "cp" syntax.3413 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll',3414 sDst = sScratchHst + "/"),3415 tdTestResult(fRc = True) ],3416 # Destination is a directory (without a trailing slash, should also work).3417 # See "cp" syntax.3418 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll',3419 sDst = sScratchHst),3420 tdTestResult(fRc = True) ],3421 # Destination is a non-existing directory.3422 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll',3423 sDst = sScratchHstNotExist),3424 tdTestResult(fRc = False) ]3425 ]);3426 3558 3427 3559 # … … 3429 3561 # 3430 3562 if self.oTstDrv.fpApiVer > 5.2: # Copying directories via Main is supported only in versions > 5.2. 3563 reporter.log(("Directory handling")); 3431 3564 aaTests.extend([ 3432 3565 # Copying entire directories (destination is "<sScratchHst>\Web"). 3433 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\Web',3566 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcDirExisting, 3434 3567 sDst = sScratchHst), 3435 3568 tdTestResult(fRc = True) ], 3436 3569 # Repeat -- this time it should fail, as the destination directory already exists (and 3437 3570 # DirectoryCopyFlag_CopyIntoExisting is not specified). 3438 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\Web',3439 sDst = sScratchHst + "/"),3571 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcDirExisting, 3572 sDst = sScratchHst), 3440 3573 tdTestResult(fRc = False) ], 3441 3574 # Next try with the DirectoryCopyFlag_CopyIntoExisting flag being set. 3442 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\Web',3575 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcDirExisting, 3443 3576 sDst = sScratchHst, aFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), 3444 3577 tdTestResult(fRc = True) ], 3445 3578 # Ditto, with trailing slash. 3446 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\Web',3579 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcDirExisting, 3447 3580 sDst = sScratchHst + "/", aFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), 3448 3581 tdTestResult(fRc = True) ], 3449 3582 # Copying contents of directories into a non-existing directory chain on the host which fail. 3450 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\Web\\',3583 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcDirExisting + sPathSep, 3451 3584 sDst = sScratchHstNotExistChain, 3452 3585 aFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), 3453 3586 tdTestResult(fRc = False) ], 3454 3587 # Copying contents of directories into a non-existing directory on the host, which should succeed. 3455 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\Web\\',3588 [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = sSrcDirExisting + sPathSep, 3456 3589 sDst = sScratchHstNotExist, 3457 3590 aFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), 3458 3591 tdTestResult(fRc = True) ] 3459 3592 ]); 3460 else:3461 reporter.log('No OS-specific tests for non-Windows yet!');3462 3593 3463 3594 fRc = True;
Note:
See TracChangeset
for help on using the changeset viewer.